text,view,rotation,openlayers,openlayers-3 , How to rotate text with view using OpenLayers 3


How to rotate text with view using OpenLayers 3

Question:

Tag: text,view,rotation,openlayers,openlayers-3

I am developing a navigation application, which draws planned route on a map. Planned route consists of points connected with a line. Each point is labelled with distance and direction. When I initially draw the route on the map, I calculate text position in a way, where it doesn't interfere with the line - I use offsetX, offsetY and rotation style attributes. Unfortunately, when the map view is rotated, not of the mentioned attributes is changed - text is not rotated. Is there a way, how to rotate the text with the view, so it will remain on it's position relative to the point? I have already tried rotateWithView: true with both image and text parts.

My style is defined like:

return [new ol.style.Style({
        image: new ol.style.Circle({
            radius: 20,
            fill: new ol.style.Fill({color: 'black'}),
            stroke: new ol.style.Stroke({color: 'black', width: 1})
        }),
        text: new ol.style.Text({
            textAlign: "center",
            textBaseline: "middle",
            font: 'normal 1.5rem Arial',
            text: "This is my text",
            fill: new ol.style.Fill({color: 'black'}),
            stroke: new ol.style.Stroke({color: 'black', width: 1}),
            offsetX: 10,
            offsetY: 15,
            rotation: 0.3
        })
    })];

Answer:

Update feature rotation on map view property change event.

map.getView().on('propertychange', function(event) {
    textStyle.setRotation(this.getRotation());
    mySource.changed();
});

var textStyle = new ol.style.Text({
    // ...
});

var layer = new ol.layer.Vector({
    source: mySource,
    style: new ol.style.Style({
        text: textStyle,
        // ...
    })
});

Related:


Python - Select specific value from test file


python,file,text
I'm absolute beginner in python, and I'd like to get field i.e. from 2nd column, 3rd row from text file like this: 176a AUGCACGUACGUA ACGUA AGUCU 156b GACUACAUGCAUG GCAUA AGCUA 172e AGCUCAGCUAGGC CGAGA CGACU (text is separated by spaces). is there any simple way to do that?...

Advancing text in a text file using user input


java,text,user-input
So in my first year of college for my christmas project I needed to make a basic game using if statements, I chose a text adventure but me being a novice I chose to write out every print out: System.out.println("You approach the two cupboards one on the right and one...

Changing a read-only file [on hold]


python,text
I need to change text documents. The way I've been doing it is making a new file, copying everything line by line from the old file and making changes on the way, then saving the new file as the old file's name. This becomes a problem when I only have...

Android popup like IOS


android,view,popup
I need to implement popup dialog like in iOS, and show above some view (map point in this case), but don't know how to implement it. Screenshot attached. Will be glad any proposals.

FatFree pass array to a view using Jig data mapper


view,render,fat-free-framework
I have data/faqs.json like this. { "section-1" : { "sub-section-1" : { "557aef62e0629": { "question": "how are you?", "answer": "fine.. you?" }, "557af3d40b041": { "question": "Question", "answer": "Answer to question" } }, "sub-section-2": { "557af3d80b041": { "question": "another section question?", "answer": "another section answer?" } } }, "section-2" : {...

Is it possible to index views in Apache Solr


sql,view,solr
Let me first give you an example. I have two tables -table1 and table2. table1 has a field id_table2, which is a foreign key and references one of the fields in table2. So, when I want to scan table1, I make a query like: SELECT t1.attr_1_, t1.attr_2_, t2.attr_3_ FROM table1...

Managing user login segues in swift iOS


ios,iphone,swift,view
I am trying to build an initial user login system for an iPhone app. I have created an API which holds all the user data. I have successfully made a HTTP connection from my swift code to my API, where I sent the users login details the API authenticates the...

Extract lines from File2 already found File1


linux,text,awk,sed,grep
Using linux commandline, i need to output the lines from text file2 that are already found in file1. File1: C A G E B D H F File2: N I H J K M D L A Output: A D H Thanks!...

RichTextbox write in place to current line


c#,text,visual-studio-2013,richtextbox
Clarification: I want to output line of text to the same "position" in a RichTextBox, replacing the previous line. In C# Windows Forms Application trying to use RichTextBox for displaying messages. Most of the messages are appended, so that is fine but at one point in the program it has...

How to display text in browsers tab bar in a javaserver page [closed]


html,jsp,browser,text,tabs
I have heard of being able to display images in a browsers tab bar here: http://stackoverflow.com/questions/120420/image-icon-beside-the-site-url But I was wondering if there might be an easier way to do this for just some simple text? I am trying to display just two lines, last login and IP address in this...

How can I create large ASCII text from a string?


html,text
Given a string, for example 'imgur', how can I generate large ASCII text like the following? Thanks. _ (_) _ _ __ ___ __ _ _ _ _ __ | | '_ ` _ \ / _` | | | | '__| | | | | | | | (_|...

How to get the whole bitmap of all views below?


android,view
I have a view which has some transparent area. Through the transparent area , I can see the view below it, now I want the view I see trough transparent area become blur. I have found some code to make a bitmap blur but how can I get the bitmap...

odoo v8 - Field(s) `arch` failed against a constraint: Invalid view definition


python,xml,view,odoo,add-on
I want to create a new view with a DB-view. When I try to install my app, DB-view was created then I get error: 2015-06-22 12:59:10,574 11988 ERROR odoo openerp.addons.base.ir.ir_ui_view: Das Feld `datum` existiert nicht Fehler Kontext: Ansicht `overview.tree.view` [view_id: 1532, xml_id: k. A., model: net.time.overview, parent_id: k. A.] 2015-06-22...

Refreshing SQL view after adding a default constraint to one of its tables


sql,table,view,refresh
How exactly can I refresh the view after adding a default constraint to one of the tables that makes up the view? I tried to use the sp_refreshview stored procedure but that didn't actually update the view. Here is the code I wrote to update one of columns with a...

Python outputs a .txt file, which's format differs depending on the text editor I use to open it


python,text,output
So I have some python code taht outputs some data to a .txt file like this: f3 = codecs.open(r'C:\Users\dimrizo\Desktop\PythonData\GTFS\routes.txt','w+',"UTF-8") f3.write('route_id,agency_id,route_short_name,route_long_name,route_desc,route_type,route_url,route_color,route_text_color\n') f3.write('blah,blah,blah,blah,blah,blah,blah,blah,blah\n') Problem is that if I open the produced file with the simple windows text editor the text is not properly formatted. The "\n" don't even count. If I open...

How can I wrap text in QGraphicsItem?


qt,text,word-wrap,qgraphicsitem
1) How can I wrap text in a QGraphicsTextItem to fit a fixed rectangle, with width and height ? Right now I am experimenting with creating a text, getting its bounding rectangle, and resizing it to fit the box - but I can't get wrapping. class TTT: public QGraphicsTextItem {...

“Undefined variable” error, when rendering data in a view


php,view,yii2
I want to render static array in _form.php view, using actionCreate method in Yii2. Here is my code: if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { $data = array('1'=>'AA','2'=>'BB'); return $this->render('create', [ 'model' => $model, 'data' => $data , ]); } When I try to...

Removing the blank positions (x,y) from a text file in Python?


python,text
I'm working on object tracking from video files, I have 5 to 6 objects in each frame of the video. Due to some bugs in the code there are some frames that are skipped and show as blank spaces in the text file . Like below 5.0 2.3 5.4 5.2...

x axis text overlapping in matlab


matlab,text,overlap
My x axis text are overlapping. I am using this code-- clear all A=[1 2 3 4 5 6 7]'; b=1:length(A); figure(1) bar(A) title('Loss Diagram') xlabel('Loss factor') ylabel('kWh/year','fontsiz`enter code here`e',20) grid on set(gca,'Xtick',b,'XtickLabel',{'Horizntl Global Irr. ' 'Effective irr. on coll. ' 'Array nominal energy ' 'PV module loss ' 'charge...

jQuery text animation from right to left


jquery,animation,text
I try to achieve the same animation with jQurey animate for social sharing what this site uses in footer when you click on Share. I was trying to build the animation but the list on toggle does not behave as expected. my markup <div id="social-media"> <a href="#" class="social-shares"> SHARE</a> <ul...

search string in textfile [on hold]


c++,c,string,text
Say you have a text file like this all you want from the text is the "size value" but repeats more that thousand time with different value "field_pic_flag : 0 bottom_field_flag : 0 idr_pic_id : 0 Found NAL at offset ,size 28813 !! Found NAL" "field_pic_flag : 0 bottom_field_flag :...

Batch - Comparing two txt files


windows,batch-file,text,comparison
I have some difficulties comparing two txt files with batch. I used the "findstr" function with many option matchings but none works (for example FINDSTR /I /V /B /G:file1.txt file2.txt). I have a first txt file as following: File1.txt Object 1 Argument 50 Object 2 Argument 10 Object 3 Argument...

Trying to get just the text from a node with filter(), but is returning an object?


javascript,jquery,dom,text
I am simply trying to extract the text without any of the elements from a DOM node with var textIWant = $('.classname').contents().filter(function(){ return this.nodeType === 3; })[1]; This returns to me what looks like a string in the console, something untrimmed like.. " text I want " so when I...

change the content of a select option


jquery,forms,select,text,options
I'd like to change the text shown in a select form, without changing the HTML elements. This is an example: <select class="myclass" name="myselect"> <option value="0">1</option> <option value="1">2</option> </select> I would like to change the "2" string into "TWO", for example, like: <option value="1">TWO</option> I'm not able to select the right...

Display Popup when text is clicked in wordpress


wordpress,text,popup,wordpress-plugin
I have a Html code In wordpress.: '<a href="">example</a>' When this "example" is clicked, it needs to show a popup window with some texts. i came across some wordpress popup plugins like uji popup,etc.. they given some short codes. how can i use this shortcodes into my "href". or any...

Entity Framework code-first: querying a view with no primary key


sql,oracle,entity-framework,view,ef-code-first
Our customer has given the access to views in which there is no primary key is defined. I know Entity Framework needs a primary key for table to identify. But for views not having primary key is it still possible to query. I try to find but always Entity Framework...

Text showing on two lines with span


html,css,text
Please see below HTML and CSS code. HTML: <a class="navbar-brand" href="/index.php"> <img src="/img/logo.png" alt="logo"></a> <span class="navbar-brand" style="font-family:'Arial';font-size:24pt">WEBSITE NAME</span> CSS: .navbar-brand { width: 88px; height: 88px; } .navbar-brand img { width: 100%; height: auto; } The problem I'm having is that the text in the span (WEBSITE NAME) is showing on...

Stop text from leaking out of div [on hold]


html,css,text
I have some text which is contained in a div, however if it's too long, it leaks outside of the div and I don't want that. I dont want to use the overflow attribute and give it a scroll bar. Id like it to put the "..." at the end...

DirectWrite align text center


c++,text,directx,direct2d,directwrite
I am trying to align center the text I have to draw. I use ID2D1RenderTarget::DrawTextLayout method. The problemn is that if I set the text horizontal alignment to DWRITE_TEXT_ALIGNMENT_LEADING (the default value) the text is drawn proberly, but if I change this value to DWRITE_TEXT_ALIGNMENT_CENTER the text is shifted right....

Text justification C language


c,text,alignment
I have to solve a problem that involves left justification string length and leading zeros. I have the following table : BEGIN CLOSE CONCATENATE DELETE END INITIALIZE PRINT WRITE This is produced by a simple program. My problem is to find out how to convert it like that : It...

HTML make your own