[OpenLayers-Users] Why won't this map re-center?
Andreas Hocevar
ahocevar at opengeo.org
Mon Feb 27 01:59:56 EST 2012
Hi,
you have to pass the coordinates in the map's SRS (EPSG:900913 for the
OSM layer) to setCenter, and you can combine setCenter with zoomTo. So
the following will center your map at and zoom to zoom level 2:
var wgs84 = new OpenLayers.Projection("EPSG:4326");
var mercator = new OpenLayers.Projection("EPSG:900913");
map.setCenter(
new OpenLayers.LonLat(-98.4375,39.774769).transform(wgs84, mercator),
2
);
Andreas.
On Mon, Feb 27, 2012 at 7:10 AM, Scott Chapman <scott at mischko.com> wrote:
> Here's my code to build a map in the qooxdoo framework.
> The map displays correctly and zooms to the level I tel it to but it
> won't recenter to the LatLon I tell it to.
>
> Any clues?
>
> Thanks!
> Scott
>
> qx.Class.define("kiosk_portal.OpenLayersMap",
> {
> extend : qx.ui.core.Widget,
> construct : function()
> {
> this.base(arguments);
> this.set({
> width: 950,
> height: 650
> });
> console.log("G A");
> this.addListenerOnce("appear", function() {
>
> var arrayOSM =
> ["http://otile1.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.jpg",
>
> "http://otile2.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.jpg",
>
> "http://otile3.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.jpg",
>
> "http://otile4.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.jpg"];
> var baseOSM = new OpenLayers.Layer.OSM("MapQuest-OSM Tiles", arrayOSM);
>
> var map = new OpenLayers.Map( this.getContentElement().getDomElement(),
> {controls: [
> new OpenLayers.Control.PanZoom(),
> new OpenLayers.Control.ScaleLine(),
> new OpenLayers.Control.OverviewMap(),
> new OpenLayers.Control.Navigation(
> {mouseWheelOptions: {interval: 100}}
> )
> ]
> } );
> map.addLayer(baseOSM);
> map.addControl(new OpenLayers.Control.Attribution());
> map.setCenter(new OpenLayers.LonLat(-98.4375,39.774769));
> map.zoomTo(2);
> this.__map = map;
> });
> }
> });
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
More information about the Users
mailing list