As indicated in my other <a href="http://osgeo-org.1560.n6.nabble.com/Problem-dynamic-loading-a-KML-file-refresh-td5015133.html#a5015310" target="_top" rel="nofollow" link="external">posting</a> I've a problem with a function in IE8 and Google Chrome. Works well in Mozilla Firefox.<br>Started a new thread for this issue.<br><br>
<pre> function AddLayer()
{
// If layer (kml_layer) already exists, remove it before adding the new one
if (kml_layer)
{
map.removeLayer(kml_layer);
//kml_layer.destroyFeatures(); // not sure if this is necessary. Works well without it.
}
// Get file name (.kml file)
filename = document.getElementById('theFile').value;
kml_layer = new OpenLayers.Layer.Vector("KML", {
projection: map.displayProjection,
strategies: [new OpenLayers.Strategy.Fixed(),
new OpenLayers.Strategy.BBOX({resFactor: 1.1}),
//new OpenLayers.Strategy.Cluster()], // only usefull if you want to cluster your markers
protocol: new OpenLayers.Protocol.HTTP({
url: filename,
format: new OpenLayers.Format.KML({
extractStyles: true,
extractAttributes: true,
maxDepth: 10
})
})
});
map.addLayer(kml_layer);
}
</pre>
Also added the function to the 'onClick' event of the button;
<br><pre>
<input type="button" value="Show Markers" onClick="AddLayer()">
</pre><br>
Webpage error details
<pre>
Message: Invalid argument.
Line: 747
Char: 153
Code: 0
URI: file:///D:/openlayers/OpenLayers.js
</pre><br>
>From OpenLayers.js<br><pre>
....,p=this.readyState,q;
if(h&&i){q=function()
{if(p!=b.DONE){e(o);o.abort()}};
window.attachEvent("onunload",q)}b.onopen&&b.onopen.apply(this,arguments);
arguments.length>4?this._object.open(a,f,i,m,n):arguments.length>3?this._object.open(a,f,i,m):this._object.open(a,f,i);
this.readyState=b.OPENED;
c(this);
this._object.onreadystatechange=function(){if(!g||i){o.readyState=o._object.readyState;
d(o);
if(o._aborted)o.readyState=b.UNSENT;
else{if(o.readyState==b.DONE){delete o._data;e(o);
h&&i&&window.detachEvent("onunload",....</pre><br>
Error at this part;<br>
<pre>
arguments.length>4
</pre><br>Any advice is appreciated !!!<br><br>
<br/><hr align="left" width="300" />
View this message in context: <a href="http://osgeo-org.1560.n6.nabble.com/Error-in-IE8-and-Google-Chrome-tp5015312.html">Error in IE8 and Google Chrome</a><br/>
Sent from the <a href="http://osgeo-org.1560.n6.nabble.com/OpenLayers-Users-f3910695.html">OpenLayers Users mailing list archive</a> at Nabble.com.<br/>