[OpenLayers-Users] id of polygon feature created on a vector layer
Andreas Hocevar
ahocevar at opengeo.org
Fri Nov 4 03:07:04 EDT 2011
Dragons ahead! Accessing rendered geometries through the DOM is not part of
the API. What do you want to do with the geometry?
Andreas.
On Nov 3, 2011 9:51 PM, "Puneet Kishor" <punk.kish at gmail.com> wrote:
> I have code like so
>
> var sLyr = new OpenLayers.Layer.Vector("s");
> map.addLayers([sLyr]);
>
> var polyCtrl = new OpenLayers.Control.DrawFeature(
> sLyr,
> OpenLayers.Handler.Polygon,
> {featureAdded: foo}
> );
>
> function foo(evt){
> var elem = document.getElementById(evt.feature.geometry.id);
>
> // do something with elem
> }
>
> map.addControl(polyCtrl);
> polyCtrl.activate();
>
> I get an error: "TypeError: 'undefined' is not an object (evaluating
> 'evt.feature.geometry')"
>
> So, foo() is getting fired alright. What is my error above, and how do I
> solve it? Essentially, I want to access the id of the polygon just created.
>
>
> --
> Puneet Kishor_______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20111104/20bc0cc4/attachment.html
More information about the Users
mailing list