[OpenLayers-Users] Trying to draw a box on a map, and get the coordinates back.

Arnd Wippermann arnd.wippermann at web.de
Thu Feb 11 16:20:07 EST 2010


Hi,

function findcoords (event) {
     var vertices = event.feature.geometry.getVertices();
     var brackets =
vertices.toString().replace(/POINT\(/g,"[").replace(/\),/g,"],").replace(/
/g,",").replace(/\)/,"]");
     alert('ID:' + brackets);
} 

This is one way to get what you want. If there is a simple way to get the
coordinates in this form from a geojson string or object, i don't know.

Arnd

-----Ursprüngliche Nachricht-----
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von Jtrsmith
Gesendet: Donnerstag, 11. Februar 2010 18:16
An: users at openlayers.org
Betreff: Re: [OpenLayers-Users] Trying to draw a box on a map,and get the
coordinates back.


Thanks again Arnd.

I was able to get the coordinates back, however they are formatted
differently.
i get a csv list i.e. 50, 0, 50, 50, 0, 50, 0, 0, 50, 0 instead of brackets
i.e. [50, 0], [50, 50], [0, 50], [0, 0], [50, 0]

i am using the value to get the coordinates of a polygon added to my map so
i can save it to a database and dynamically create a json file for my
openlayers map, it looks like the only issue is the brackets, it crashes
without them and i cannot fiigure out how to get them.

should i save them to the database the way they are and try to add the
brackets in my php code when creating the json?
--
View this message in context:
http://n2.nabble.com/Trying-to-draw-a-box-on-a-map-and-get-the-coordinates-b
ack-tp4251287p4556020.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users




More information about the Users mailing list