Hi all,
This situation: I add a vector layer with GPX file to my map. After this I will
get the features from vector layer with GPX data to set a new center and zoom
of map. To get the features I have to add a delay about 15 ms else the features
are undefined.
Here a code snip:
var routeGpx, map;
function newOverlayLayer(routeName, routeUrl, timeOut){
routeGpx = new OpenLayers.Layer.Vector(
routeName,
{
protocol: new OpenLayers.Protocol.HTTP({
url: routeUrl,
format: new OpenLayers.Format.GPX()
}),
strategies: [new OpenLayers.Strategy.Fixed()],
displayInLayerSwitcher: false,
style: {strokeColor: "blue", strokeWidth: 4, strokeOpacity: 0.5},
projection: new OpenLayers.Projection("EPSG:4326")
}
);
routeGpx.setVisibility(true);
map.addLayer(routeGpx);
setTimeout("setNewMapCenter()", timeOut);
}
function setNewMapCenter(){
myFeature = routeGpx.features[0];
if(myFeature){
layerBounds = myFeature.geometry.getBounds();
mapCenter = layerBounds.getCenterLonLat();
mapZoom = map.getZoomForExtent(layerBounds, false);
map.setCenter(mapCenter, mapZoom - 1);
}
else {
alert("myFeature " + myFeature);
}
}
I have this illustrated here:
http://www.hareck.lima-city.de/OL/testol-wms-if-vector.html
Is this behavior normal, what is the reason for such long delay?
Or is there a better solution for feature request available?
Thanks Hareck
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users