OpenLayers: Automatically transform EPSG 4326 -Coordinates from Text Layer into map`s projection (EPSG:900913)

currently, I`m implementing a map App with Mono4Droid and there I`m using a WebView to present a map which is provided by my own tileserver. I`m using OpenLayers to show this map and now I want to use a Text Layer to show some custom POI`s. Unfortunately, the map uses 90013 projection: So when I want to display the Markes provided by the TextLayer, I have to use coordinates in the right format. To center the map is easy: But how can I do this transformation automatically for the TextLayer? I want to have the lat lon values according to the well-known EPSG4326 into the Text Layer data file (columns lat long) and not the values according to 900913 (what I`m doing at the moment to have it work). Is there a way to let OpenLayers transform the Text Layer`s coordinates automatically to the format used in the map? Maybe a callback function to override like onShow? Thanks for your help! Otherwise I would have to translate the lat lon values myself and put the calculated value in the text file which will make performance to suffer... Finally, I found the answer myself and I must say I`m very impressed! OpenLayers is quite powerful! Here is my solution: In the options of the map-object you have to set displayOptions to the projection of your layer, in my case it`s the following to support EPSG:4326: Then you only have to take care that the layer uses this projection (if it`s not the default value already). In my case, Text Layer didn`t work correctly on Android (in a WebView): I couldn`t open a popup when clicking on the image of a marker from the textfile. Instead, I`m using a Vector-Layer according to the sundials-Example: Source.


Яндекс.Метрика Рейтинг@Mail.ru Free Web Counter
page counter
Last Modified: April 22, 2016 @ 1:02 pm