[OpenLayers-Users] Get feature Lon and Lat

adidas xkadidas at gmail.com
Tue Jul 3 03:36:35 PDT 2012


Hello! How to get Lon and Lat when i clicked on feature (line)?

/selectControl = new OpenLayers.Control.SelectFeature(lineLayer,
              {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect});
drawControls = {
                 point: new OpenLayers.Control.DrawFeature(lineLayer,
                             OpenLayers.Handler.Point),
                 select: selectControl
             };
for(var key in drawControls) {
             map.addControl(drawControls[key]);
     }
function onPopupClose(evt) {
                 selectControl.unselect(selectedFeature);
             }
             function onFeatureSelect(feature) {
                 selectedFeature = feature;
                 id = feature.id;
                 popup = new OpenLayers.Popup.FramedCloud("chicken",
feature.geometry.getBounds().getCenterLonLat(), //need to get the lon 
and lat, where I clicked
                                         null,
                                         "<div style='font-size:.8em'>" 
+CableLineText_arr[id] +"</div>",
                                         null, true, onPopupClose);
                 feature.popup = popup;
                 map.addPopup(popup);
             }
             function onFeatureUnselect(feature) {
                 map.removePopup(feature.popup);
                 feature.popup.destroy();
                 feature.popup = null;
             }/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120703/28f29f78/attachment.html>


More information about the Users mailing list