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

Arnd Wippermann arnd.wippermann at web.de
Thu Jan 7 12:37:15 EST 2010


Hi,

That should it be. 

function findcoords (event) {
     var vertices = event.feature.geometry.getVertices();
     alert('ID:' + vertices); 
} 

Arnd

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


i am not sure i explained what i was looking for correctly. here is an
example.

vectors.events.register('featureadded', vectors, findcoords); function
findcoords (feature) {
     var vertices = feature.geometry.getVertices();
     document.getElementById('output').value = 'ID:' + vertices; }

the event does actually trigger, however, feature.geometry.getVertices()
does not work.

i am using geojson to display other polygons on the map, and would like the
variable vertices to get the coordinates of the polygon vertices so that i
can add a new polygon to the map and save the coordinates in a database.

John


micklesh wrote:
> 
> Hi, John.
> if i understood your requirements, there is an example in the docs 
> http://dev.openlayers.org/docs/files/OpenLayers/Control-js.html
> 
> regards, michael.
> 
> 2010/1/4 John Smith <jtrsmith at gmail.com>
> 
>> i just saw this post and was wondering if the solution was ever 
>> found. i am basically trying to do the same thing. I need to draw a 
>> box around an area of my map and show the coordinates in a form 
>> field, so i can post the coordinates and a description to my 
>> database.
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>>
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> 

--
View this message in context:
http://n2.nabble.com/Trying-to-draw-a-box-on-a-map-and-get-the-coordinates-b
ack-tp4251287p4267311.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