[OpenLayers-Users] Click Event

Donal donal_regan10 at YAHOO.CO.UK
Thu Jun 21 06:34:19 EDT 2007



Is there a solution to this? I have a similar problem in IE6.



Brian Krebs-2 wrote:
> 
> I implemented the click example(click.html) to capture the position of
> the click and place a marker there.  I only want it to do this on a
> single click, but it is also being called at the end of a pan upon
> mouseup and also when I click on the zoom bar anywhere in between + and
> -.  Is there anyway to disable the click event during these actions?
> 
>  
> 
> Here is the code where the click event is being registered:
> 
>  
> 
> function initializeMapStart(Lon, Lat, Zoom)
> 
> {
> 
>       layerData.maxExtent = new OpenLayers.Bounds(-94.807800, 35.638191,
> -94.472656, 36.161896);
> 
>     
> 
>       var options = 
> 
>             { 
> 
>                   'controls':[],
> 
>                   'maxExtent': layerData.maxExtent,
> 
>                   'maxResolution': 'auto',
> 
>                   scales: [2000000, 1000000, 500000, 250000, 125000,
> 62500, 31250, 15625, 7812, 3906, 1953],
> 
>                   projection: 'EPSG:4326',
> 
>                   'tileSize': new OpenLayers.Size(200, 200)
> 
>             };
> 
>       openLayersMap = new OpenLayers.Map('mapDiv', options);
> 
>     
> 
>       OpenLayers.Util.onImageLoadErrorColor = null;
> 
>       
> 
>     //Base layer
> 
>       layer = new OpenLayers.Layer.KaMap('basemap',
> 
>                   kamapUrl,
> 
>                   { 
> 
>                         'map': 'oklahoma', 
> 
>                         'g': 'all', 
> 
>                         'i': 'gif'
> 
>                   },
> 
>                   {
> 
>                         'buffer': 1
> 
>                   }
> 
>             );
> 
>       layer.displayOutsideMaxExtent = true;
> 
>       openLayersMap.addLayer(layer);
> 
>       
> 
>       //Marker layer
> 
>       var markersLayer = new OpenLayers.Layer.Markers("Locate");
> 
>       if (Lon != 0.0 && Lat != 0.0)
> 
>       {
> 
>         var marker = new OpenLayers.Marker(new OpenLayers.LonLat(Lon,
> Lat), new
> OpenLayers.Icon("http://kormap/MapService/Images/okiemarker.png", new
> OpenLayers.Size(30,60)));
> 
>         markersLayer.addMarker(marker);
> 
>         openLayersMap.addLayer(markersLayer); 
> 
>         var markerbounds = new OpenLayers.Bounds(Lon, Lat, Lon, Lat);
> 
>         var newLonLat = markerbounds.getCenterLonLat();
> 
>         openLayersMap.setCenter(newLonLat, Zoom);
> 
>     }
> 
>     
> 
>     if (Zoom == 0)
> 
>         zoomToExtent(markerbounds);
> 
>         
> 
> THE CLICK EVENT
> 
>     openLayersMap.events.register("click", openLayersMap, function(e) 
> 
>     { 
> 
>         markersLayer.clearMarkers();
> 
>         var lonlat = openLayersMap.getLonLatFromViewPortPx(e.xy);
> 
>         var marker = new OpenLayers.Marker(new
> OpenLayers.LonLat(lonlat.lon, lonlat.lat), new
> OpenLayers.Icon("http://kormap/MapService/Images/okiemarker.png", new
> OpenLayers.Size(30,60)));
> 
> //        alert("You clicked " + lonlat.lon + ", " + lonlat.lat);
> 
>         markersLayer.addMarker(marker);
> 
>         openLayersMap.addLayer(markersLayer);  
> 
>         
> 
>         document.forms[0].txtLatitude.value = lonlat.lat;
> 
>         document.forms[0].txtLongitude.value = lonlat.lon;
> 
>     });
> 
>  
> 
> }
> 
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> 

-- 
View this message in context: http://www.nabble.com/Click-Event-tf3526939.html#a11230441
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list