Need show pop-up where user clicked. Doing as, but does not work:
            var ClickLon;
            var ClickLat;

OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
                defaultHandlerOptions: {
                    'single': true,
                    'double': false,
                    'pixelTolerance': 0,
                    'stopSingle': false,
                    'stopDouble': false
                },

                initialize: function(options) {
                    this.handlerOptions = OpenLayers.Util.extend(
                        {}, this.defaultHandlerOptions
                    );
                    OpenLayers.Control.prototype.initialize.apply(
                        this, arguments
                    );
                    this.handler = new OpenLayers.Handler.Click(
                        this, {
                            'click': this.trigger
                        }, this.handlerOptions
                    );
                },

                trigger: function(e) {
                    var lonlat = map.getLonLatFromPixel(e.xy);
                    ClickLon = lonlat.lon;
                    ClickLat = lonlat.lat;
                }

            });


            function onPopupClose(evt) {
                selectControl.unselect(selectedFeature);
            }
            function onFeatureSelect(feature) {
                selectedFeature = feature;
                id = feature.id;
                alert(ClickLon);
var lonLat = new OpenLayers.LonLat(ClickLon, ClickLat).transform(new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326"));

                popup = new OpenLayers.Popup.FramedCloud("chicken",
                                        lonLat,
                                        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;
            }
...
var lineLayer = new OpenLayers.Layer.Vector("Line Layer");
map.addLayer(lineLayer);
map.addControl(new OpenLayers.Control.DrawFeature(lineLayer, OpenLayers.Handler.Path));

Help me! Thanks!
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to