[OpenLayers-Users] Capture Events

Alexandre Dube adube at mapgears.com
Mon Sep 28 08:32:04 EDT 2009


Hi,

  You could listen to the "featureadded" event of your Vector layer.  
When the polygon feature is added to the layer, get its coordinates.

<<<

  polygon.events.register("featureadded", polygon, onFeatureAdded);

  function roadFeatureAdded(event){
    var oFeature = event.feature;
    // add your stuff
  }

 >>>

Hope this helps,

Alexandre


Diego Roberto wrote:
> I need to capture an event after drawing a polygon on the map. At the 
> User map enables the control to draw a polygon on the map and the 
> final design of the desire to capture the coordinates of this polygon 
> to generate a search space. I can not make it through an event.
> Currently I use a search button that has a onclick function that calls 
> for the following item caught the coordinates:
>
> var strPoligono = geojson.write (poligono.features, true);
>
> Now how to make it through when it finishes drawing the polygon ta 
> screen? I tried using the onClick function but without success:
>
>   onClick: function (evt) (
>                          / / Capture the screen coordinates
>                                  var strPoligono = geojson.write 
> (poligono.features, true);
>                                  / / Capture the zoom level of the map
>                                  nivelZoom map.getZoom = ();
>                                / / Call the function as parameter is 
> the level of zoom and the coordinates
>                                 query (strPoligono, nivelZoom);
>
>                  )
>
> I also tried with no success onDblclickporém:
>
>   ondblclick: function (evt) (
>                          / / Capture the screen coordinates
>                                  var strPoligono = geojson.write 
> (poligono.features, true);
>                                  / / Capture the zoom level of the map
>                                  nivelZoom map.getZoom = ();
>                                / / Call the function as parameter is 
> the level of zoom and the coordinates
>                                 query (strPoligono, nivelZoom);
>
>                  )
>
> I use the following layer:
>
>      / / Layer to design for polygon generation of space research
>                  polygon = new OpenLayers.Layer.Vector ( 'Search 
> Polygon',
>                                      / / Blue Style applied to the 
> polygon
>                                      (
>                          Style: OpenLayers.StyleMap new ((
>                              fillColor: "# 333399"
>                              fillOpacity: 0.5
>                          ))
>                          )
>            );
>                
>
> Can anyone help me?
>
> Thank you for your attention. Have a great week.
> -- 
> ________________________________________________
> Diego Roberto
> + 55 (62) 9619-0902
> "Run after your dream ... They are the only thing you care even when 
> you're sleeping!"
>
> ________________________________________________
>
> ------------------------------------------------------------------------
> Veja quais são os assuntos do momento no Yahoo! + Buscados: Top 10 
> <http://br.rd.yahoo.com/mail/taglines/mail/*http://br.maisbuscados.yahoo.com/> 
> - Celebridades 
> <http://br.rd.yahoo.com/mail/taglines/mail/*http://br.maisbuscados.yahoo.com/celebridades/> 
> - Música 
> <http://br.rd.yahoo.com/mail/taglines/mail/*http://br.maisbuscados.yahoo.com/m%C3%BAsica/> 
> - Esportes 
> <http://br.rd.yahoo.com/mail/taglines/mail/*http://br.maisbuscados.yahoo.com/esportes/> 
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>   


-- 
Alexandre Dubé
Mapgears
www.mapgears.com




More information about the Users mailing list