OpenSeaMap Forum

For new registrations: Please create and activate an account. Afterwards send an email to including a short message and your username to get write access to this forum. Thanks!
Für neue Registrierungen: Bitte erstelle einen neuen Account und schalte ihn frei. Anschließend sende eine kurze Mail mit deinem Nutzernamen an um Schreibzugriff für dieses Forum zu bekommen. Danke!

You are not logged in.

#1 2017-05-22 19:30:05

Registered: 2017-05-22
Posts: 1

Using KML in OpenLayers 3

Hello, I'm starting in Openlayers and I'm having a problem visualizing polygons on maps.
I have a set of polygons being returned from a query in the database (postgres / postgis) this set of polygons is passed via json by an ajax request to the frontend where I intend to use the OpenLayers3 library to display those polygons on a map.

Return example as KML:
{st_askml=<MultiGeometry><Polygon><outerBoundaryIs><LinearRing><coordinates>-53.460269936027402,-24.954734829872194 -53.460072335178054,-24.954744520125182 -53.460093771307605,-24.955104793997403 -53.460291372725941,-24.955095103672289 -53.460269936027402,-24.954734829872194</coordinates></LinearRing></outerBoundaryIs></Polygon></MultiGeometry>}
{st_askml=<MultiGeometry><Polygon><outerBoundaryIs><LinearRing><coordinates>-53.459896169834188,-24.955114484062349 -53.459874734273619,-24.9547542101181 -53.459701833437066,-24.954762688648493 -53.459723268499758,-24.955122962655768 -53.459896169834188,-24.955114484062349</coordinates></LinearRing></outerBoundaryIs></Polygon></MultiGeometry>}

What would be the best way to create the vector layer with these polygons using OL3?
Saving the set of polygons in a file and using this file as source for the layer?
Using json itself as source for the layer? (Is there such a possibility?)
And how would the syntax of this layer look in OL3?


Board footer

Powered by FluxBB