check if a layer has a wrong format openlayers

المشرف العام

Administrator
طاقم الإدارة
I have two vector layers that can be added to the map - KML and GeoRSS. The format of the layer is applied based on the dropdownbox value. I need to find a way to check when the loaded layer has a wrong format (that causes map tiles to display incorrectly) and don't add the vector to the map based on this condition.

if (selectedOption.text == "KML") { var formatValue = new OpenLayers.Format.KML(); layer = this.loadVectorLayer("test1", formatValue, pURL); //check if the url corresponds to the selected dropdownbox value this.checkFormatAndLoadVector(layer);} else if (selectedOption.text == "GeoRSS") { var formatValue = new OpenLayers.Format.GeoRSS(); layer = this.loadVectorLayer("test2", formatValue, pURL); this.checkFormatAndLoadVector(layer);};function checkFormatAndLoadVector (layer) { if (layer.renderer.map != null) { //need to find a condition to check on when the layer uses a wrong format this.loadLayer(layer); } else { alert("Problem occured while rendering the layer."); }};function loadVectorLayer(vectorLayerName, formatValue, pURL) { return layer = new OpenLayers.Layer.Vector(vectorLayerName, { projection: this.map.displayProjection, strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({ url: pURL, currentInterval: undefined, format: formatValue }) });};

أكثر...
 
أعلى