[Spanish] Re: centrar dinamicamente un mapa openlayer
juanluep
juanlu at grupoitalica.com
Fri Mar 30 07:20:37 EDT 2012
Gracias pero... no me sale
Te pongo el codigo que estoy usando
function init() {
var latlon = new OpenLayers.LonLat(-5.972416,37.427214);
map = new OpenLayers.Map("basicMap");
var mapnik = new OpenLayers.Layer.OSM();
map.addLayer(mapnik);
map.setCenter(latlon
.transform(
new OpenLayers.Projection("EPSG:4326"), // transform from WGS
1984
new OpenLayers.Projection("EPSG:900913") // to Spherical
Mercator Projection
), 15 // Zoom level
);
var wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0",
{layers: 'basic'}
);
var kml = new OpenLayers.Layer.Vector("KML", {
projection: map.displayProjection,
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: "./kml/140320121446134.kml",
format: new OpenLayers.Format.KML({
extractStyles: true,
extractAttributes: true,
maxDepth: 3
})
})
});
map.addLayers([wms, kml]);
var centrado = kml.getDataExtent();
map.zoomToExtent(centrado);
seleccionar = new OpenLayers.Control.SelectFeature(kml);
kml.events.on({
"featureselected": onSeleccionarIcono,
"featureunselected": onDesseleccionarIcono
});
map.addControl(seleccionar);
seleccionar.activate();
}
centrado me da null y claro esta un error al hacer zoomToExtent.
Saludos
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/centrar-dinamicamente-un-mapa-openlayer-tp4670904p4670981.html
Sent from the OSGeo Spanish Local Chapter mailing list archive at Nabble.com.
More information about the Spanish
mailing list