[OpenLayers-Users] inconsistent click handling

Gert-Jan Braas braas at steckelfisch.nl
Tue Mar 9 04:44:10 EST 2010


Hello list,

I'm having a persistent problem, which is not very consistently
reproducible.

I have a small application with a button, which when beeing clicked,
places a marker
on a map. The marker can be moved.
When double clicked, the marker dis-appears and a popup-window is shown.
In 50% (a guestimate) of the 'double-clicks' there is no reaction at al

This page is as clean as I can create the example:
http://ligplekwijzer.steckelfisch.nl/feature-not-responding-test1.html

This code creates the layer:
function addNewLigplekLayer() {
  var SHADOW_Z_INDEX = 10;
  var MARKER_Z_INDEX = 11;

  try {
	newLigplekLayer = new OpenLayers.Layer.Vector( "Aanmelden nieuwe ligplek",
		{
		    styleMap: new OpenLayers.StyleMap({
			externalGraphic: "/ligplekwijzer_files/img/Cross.png",
			backgroundXOffset: 0,
			backgroundYOffset: -7,
			graphicZIndex: MARKER_Z_INDEX,
			backgroundGraphicZIndex: SHADOW_Z_INDEX,
			pointRadius: 15
		    }),
		    isBaseLayer: false,
		    displayInLayerSwitcher: false
		}
	);

	// Toevoegen drag feature control voor het verslepen van een feature
	var dragFeature = new OpenLayers.Control.DragFeature(newLigplekLayer);
	map.addControl( dragFeature );
	dragFeature.activate();

	var newLigplekControlOptions = {   onSelect: onNieuweLigplekSelect,
 		                            onUnselect: onNieuweLigplekUnselect };

	newLigplekControl = new OpenLayers.Control.SelectFeature(newLigplekLayer,
		                                                    newLigplekControlOptions)
;
	map.addControl( newLigplekControl );
	newLigplekControl.activate();

	map.addLayers([newLigplekLayer]);
	newLigplekLayer.setVisibility( true, true);
  } catch(e) {
    alert("Opbouwen van de data-laag AanmeldenNieuweLigplek is verkeerd
gegeaan. " + e.name + ". Error message: " + e.message);
  }

}



this is the code that adds the marker to the layer:

function addNewLigplekFeature() {
    //alert("addNewLigplekFeature");
    try {
	if( newLigplekLayer != null) {
		try {
                   newLigplekLayer.destroyFeatures(newLigplekLayer.features);
                }
                catch( err) {
	           //ignore.
	           alert(err);
	        }

		var features = [];
		var center = map.getViewPortPxFromLonLat(map.getCenter());
		var pixel = new OpenLayers.Pixel(center.x, center.y);
	        var lonLat = map.getLonLatFromViewPortPx(pixel);
		features.push(
			    new OpenLayers.Feature.Vector(
			        new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat)
			    )
		);

		newLigplekLayer.addFeatures(features);
		newLigplekLayer.setVisibility( true, true);
	}
    }
    catch( err) {
	alert( "Error in addNewLigplekFeature: "+err );
    }
}


I hope someone can provide me a handle or a pointer to solve this issue.

Regards,
Gert-Jan Braas

====================
Scholen dienen methodes te onderwijzen,
niet het gebruik van Microsoft producten.




More information about the Users mailing list