[OpenLayers-Users] Map isn't shown in IE

luke82 lukas.baehler at fhnw.ch
Wed Mar 24 04:03:34 EDT 2010


Hi List

We set up a OL-app including a WMS as baselayer and some KML-overlays by the
following code:

var map;
var select;
var lon = 7.825916722;
var lat = 47.58665024;
var zoom = 6;
var pinsKml =
'de/mein-profil/kalenderuebersicht.html?type=465&tx_cabagsteps_pi4%5Bteam%5D=1&cHash=84af82daadca27666768e7fb8061e4e3';
var etappenKml = 'typo3conf/ext/cabag_steps/Resources/Public/KML/e3.kml';
var sponsorsKml =
"typo3conf/ext/cabag_steps/Resources/Public/KML/schrittauftrittsponsors.kml";

document.observe("dom:loaded", init);

function init(){
	var options = {
		controls: [new OpenLayers.Control.Navigation(), 
					 new OpenLayers.Control.PanZoomBar()], 
		projection: new OpenLayers.Projection("EPSG:900913"),
		displayProjection: new OpenLayers.Projection("EPSG:4326"),
		units: "m",
		numZoomLevels: 7,
		scales: [10000, 20000, 50000, 100000, 200000, 500000, 1500000],
		maxScale: 10000,
		minScale: 1500000,
		maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
										 20037508.34, 20037508.34)
	};
	   
	map = new OpenLayers.Map('map', options);
	
	if (isNaN(map.size.w) || isNaN(map.size.h)) {
		map.updateSize();
	}
	
	// Swisstopo-Layer
	var swisstopo = new OpenLayers.Layer.WMS( "Swisstopo",
		"http://prod.swisstopogeodata.ch/wms-fhnw", {layers: 'WMS-FHNW'} );

	// Pins-Layer
	var pins = new OpenLayers.Layer.GML("Teilnehmer", pinsKml,{
		projection: map.displayProjection,
		format: OpenLayers.Format.KML, 
		formatOptions: {
		  extractStyles: true, 
		  extractAttributes: true,
		  maxDepth: 2
		}
	});

	// Etappen-Layer
	var etappen = new OpenLayers.Layer.GML("Route", etappenKml,{
		projection: map.displayProjection,
		format: OpenLayers.Format.KML, 
		formatOptions: {
		  extractStyles: true, 
		  extractAttributes: true,
		  maxDepth: 2
		}
	});
	
	// Sponsor-Layer
	var sponsoren = new OpenLayers.Layer.GML("Sponsoren", sponsorsKml,{
		projection: map.displayProjection,
		format: OpenLayers.Format.KML, 
		formatOptions: {
		  extractStyles: true, 
		  extractAttributes: true,
		  maxDepth: 2
		}
	});

	map.addLayers([swisstopo, etappen, pins, sponsoren]);
	
	select = new OpenLayers.Control.SelectFeature([etappen, pins, sponsoren]);
			
	pins.events.on({
		"featureselected": onFeatureSelect,
		"featureunselected": onFeatureUnselect
	});
	
	sponsoren.events.on({
		"featureselected": onFeatureSelect,
		"featureunselected": onFeatureUnselect
	});

	map.addControl(select);
	select.activate();   
	
	var point = new OpenLayers.LonLat(lon,lat); 
	map.setCenter(point.transform(map.displayProjection,
map.getProjectionObject()), zoom); 

	var LayerSwitcher = new
OpenLayers.Control.LayerSwitcher();//{'activeColor': "darkblue",
'fontColor': "black"}
	map.addControl(LayerSwitcher);
}
function onPopupClose(evt) {
	select.unselectAll();
}
function onFeatureSelect(event) {
	var feature = event.feature;
	var selectedFeature = feature;
	var popup = new OpenLayers.Popup.FramedCloud("Schritt", 
		feature.geometry.getBounds().getCenterLonLat(),
		new OpenLayers.Size(100,100),
		feature.attributes.description,
		null, true, onPopupClose
	);
	feature.popup = popup;
	map.addPopup(popup);
}
function onFeatureUnselect(event) {
	var feature = event.feature;
	if(feature.popup) {
		map.removePopup(feature.popup);
		feature.popup.destroy();
		delete feature.popup;
	}
}

All works fine in FF, Opera, Safari, Chrome. But on some XP-computers we’ve
got problems with IE (once again), especially with IE7. No map is shown, but
the navigation-buttons are there (see ScreenShot). No error is reported in
IE.
We use Prototype, so the call for the init-function is made by
document.observe("dom:loaded", init); which should be the same like
document.onload = ...
Or could this be a problem?
Perhaps I’m wrong, but I think OL doesn’t need any addons (the SVG-renderer
is used in FF and not in IE ).
Thanks for any idea.

Cheers!
http://n2.nabble.com/file/n4789595/Screenprint_Karte.jpg 

-- 
View this message in context: http://n2.nabble.com/Map-isn-t-shown-in-IE-tp4789595p4789595.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list