OpenLayers OpenLayers

Ticket #780 (closed bug: fixed)

Opened 1 year ago

Last modified 10 months ago

MouseUp vs. Click

Reported by: euzuro Assigned to:
Priority: minor Milestone: 2.5 Release
Component: Control.MouseDefaults Version: 2.4
Keywords: Cc:
State:

Description

As reported to the users list by Brian K (and corroborated ((in IE6)) by 'Donal'):

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;

    });

Change History

10/10/07 01:18:28 changed by crschmidt

  • status changed from new to closed.
  • resolution set to fixed.
  • milestone set to 2.5 Release.

I think this is fixed. If not, please reopen.