Hi, Below some code to get the idea
//http://yourServer/someSide/page.html?CENTER=100,120&ZOOM=8 function init() { var CENTER = [2627000, 5685625]; var ZOOM = 0; objParams = OpenLayers.Util.getParameters(); var CENTER = objParams.CENTER ? objParams.CENTER.split(",") : CENTER; var ZOOM = objParams.ZOOM ? parseInt(objParams.ZOOM) : ZOOM; var theID = objParams.ID ? objParams.ID : null; ... ... map.setCenter(new OpenLayers.LonLat(CENTER[0], CENTER[1]), ZOOM); if(theID != null) { vectorLayer.events.register("loadend", vectorLayer, function (e) { var objFs = this.features; for(var i=0;i<objFs.length;i++) { if(objFs[i].ID = theID; { var objBounds = objFs[i].geometry.getBounds(); var x = (objBounds.left+objBounds.right )/2; var y = (objBounds.top +objBounds.bottom)/2; CENTER = [x, y]; break; } } }); map.setCenter(new OpenLayers.LonLat(CENTER[0], CENTER[1]), ZOOM); } } To center your map by a feature of a vector layer you have to be sure, that your features are loaded. I would center my map to default values, register a loadend for the vector layer, and then would parse for the feature by id and then set the center by the new value. Arnd -----Ursprüngliche Nachricht----- Von: [email protected] [mailto:[email protected]] Im Auftrag von giraam Gesendet: Mittwoch, 30. Juni 2010 15:15 An: [email protected] Betreff: [OpenLayers-Users] Zoom to point given feature ID by GET Hi folks! I want to know if it's possible to zoom to a point, I mean, i.e.: setCenter(point, 2) but having the feature ID at the URL... This is just on the first load..! Any idea? Thanks! ----- just another web developer -- View this message in context: http://osgeo-org.1803224.n2.nabble.com/Zoom-to-point-given-feature-ID-by-GET -tp5237659p5237659.html Sent from the OpenLayers Users mailing list archive at Nabble.com. _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
