For an upcoming project I was curious about visualizing a line layer using OpenLayers. Therefore I digitized a way with googlemaps. After creating a kml with “my places” in googlemaps I exported the coordinates to libre office calc and converted them to fit the needed code in OpenLayers: This will be the basis for our ongoing tutorial. First off all: keep in mind that you will need a good basemap for displaying vectors especially routes/ways. Therefore I will add a googlemap basemap and as a comparison an OpenStreetMap WMS using this: As you may know, a line vector is build up by so called vertices and each of them is a point for itself. So instead of adding multiple points we need to create a list of points (minimal example): That’s where the Excel-file comes into play And you need something like a container for all the points which is another variable called vector whith the label “trip”: You may have noticed the {style: sm} which is unknown. So you need to define a style for line beforehand. The style will be blue (#0000ff) with a width of 5 and only 50% opacity: Now there is a another problem. The coordinates given by googlemaps are WGS 84 coordinates which corresponds to EPSG:4326. Googlemaps as well as OSM operates on the Spherical Mercator Projection EPSG:900913. Of course you can reproject your locations. We combine that with adding the points to our container: And lets do the last steps as you have seen them already. The last step sets the zoom extent with new coordinates and the zoom level (10 in this case): In 2008 I finished my degree in geography and mathematics at the FU in Berlin. After a short stay in science as a research assistant I am an IT consultant in banking and co-owner of Geolicious. Subscribe to our Newsletter and don't miss a post! Tragen Sie sich in unserem Newsletter ein und verpassen Sie keinen Artikel Source.


Яндекс.Метрика Рейтинг@Mail.ru Free Web Counter
page counter
Last Modified: April 18, 2016 @ 5:05 am