Ticket #3251 (new feature)

Opened 2 years ago

OpenLayers.Layer.Vector.addFeatures() causes Chrome to reload page

Reported by: kkelley4va Owned by: crschmidt
Priority: major Milestone: 2.10 Release
Component: Layer.Vector Version: 2.10
Keywords: Chrome addFeatures Cc:
State:

Description

Background We are using OpenLayers on top of the Google map api. This is only an issue on Chrome (10.0.648.204) and not IE or FF. We also have dojo 1.5 included in our application to generate menus and other controls.

Adding a marker on top of a google map works fine. However, once the page completes loading, it is requested a second time. I noticed because I had some breakpoints set on code used to render some dynamic fields. Before the map/marker is rendered the breakpoint is hit. After the page completes loading it is hit again.

If I comment out "map.vectorLayer.addFeatures([feature]);" from the code below, the page doesn't get requested twice, but of course the marker isn't created.

function createMarker(input) 
{	
	if(input.longitude==undefined || input.latitude==undefined && input.address!=undefined)
	{
		createAddressMarker(input);
		return null;
	}
	
	if(input.longitude==undefined || input.latitude==undefined)
		return null;
	
	var iconURL = null;
	var iconW = (input.options.iconW!=undefined) ? input.options.iconW : 20;
	var iconH = (input.options.iconH!=undefined) ? input.options.iconH : 20;
	
	if(input.options.icon!=undefined)
		iconURL = input.options.icon;
	else
		iconURL = DEFAULT_MAP_ICON;
	
	input.options.icon = iconURL; //re-assigned
	input.options.iconW = iconW;
	input.options.iconH = iconH;
	
	var map = TheMaps[input.mapid];
	map.vectorLayer = new OpenLayers.Layer.Vector("Markers", {displayInLayerSwitcher: false, reproject: true});
	map.vectorLayer.events.includeXY = true;
	map.vectorLayer.display(true);
	map.vectorLayer.projection = map.displayProjection;
	
	map.vectorLayer.preFeatureInsert = function(feature) 
	{ 
		//we always with with EPSG:4326, need to convert it to map projection
		feature.geometry.transform(map.displayProjection, map.projection);
	}
	map.addLayer(map.vectorLayer);
	
	map.selectControl = new OpenLayers.Control.SelectFeature(map.vectorLayer, {clickout: true});
            
	map.vectorLayer.events.on({"featureselected": onFeatureSelect, "featureunselected": onFeatureUnselect});
	map.addControl(map.selectControl);
	map.selectControl.activate();
	
	var feature = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(input.longitude, input.latitude), null,
 	{externalGraphic: iconURL, graphicHeight: iconH, graphicWidth: iconW});
    
	feature.input = input;
	feature.id = input.id;
	
	if(input.checked==true)
		feature.style.display = 'block';
	else
		feature.style.display = 'none';
	
	map.vectorLayer.addFeatures([feature]);
	map.vectorLayer.redraw();
	
	return [feature];
}
Note: See TracTickets for help on using tickets.