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:


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...

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...

how can I add text to these rectangles?


python,text,menu,pygame,python-3.4
This is the code I have started to use to make a start menu. # we need some colours!! black = (0,0,0) white = (255,255,200) red = (200,0,0) green = (0, 200, 0) bright_red = (255, 0 ,0) bright_green = (0, 255, 0) bright_white = (255, 255, 255) def main():...

Unable to modify variables from separate thread


c#,multithreading,winforms,text,file-io
So I'm making a C# app which has to continuously read and display the contents of a text file, while allowing the user to enter something into a text box and append it to the end of that very file. I'm doing this by running my read method on a...

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...

Win 8 App Get text from datatemplate listview


listview,text,windows-8
I'm trying to learn how to make datatemplate in listviews in my win 8 app I have the following code in my Xaml code <!-- Vertical scrolling item list --> <ListView x:Name="itemListView" Margin="0,4.714,10,0.429" ItemsSource="{Binding Source={StaticResource itemsViewSource}}" SelectionChanged="itemListView_SelectionChanged" Loaded="itemListView_Loaded" Grid.Row="4" Tapped="itemListView_Tapped_1"> <ListView.ItemTemplate> <DataTemplate> <Grid Height="110" Margin="6"> <Grid.ColumnDefinitions>...

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...

Save user input into a Text widget Tkinter when using classes


python,text,tkinter
I want to know how to save text entered by the user in a Text widget when pressing a "submit" button. At the moment, I have the function submitbutton but it comes up with an error when clicking "submit." On another note, I want the top right Label widget to...

Parsing html using Selenium - class name contains spaces


python,html,parsing,selenium,text
I'm trying to parse some html using Selenium. The problem is that it raises error in case the class name contains spaces. Here is the tag I'm searching for: <p class="p0 ng-binding">text</p> I've tried these two options: result.find_element_by_class_name('departure').find_element_by_css_selector('p.p0 ng-binding').text result.find_element_by_class_name('departure').find_element_by_class_name('p0 ng-binding').text >>> selenium.common.exceptions.InvalidSelectorException: Message: The given selector p0 ng-binding is...

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...

SQL : Create view using multiple tables and a cursor


sql,view
I have two tables : 'pc' and 'results'. the table 'results' contains so many results of every pc. I need to create view that contains all pc columns and the last result of every pc. I'v tried this but it didn't work. select * from pc,resultat where pc.code_pc=result.code_pc order by...

HTML make your own