[OpenLayers-Users] Extent with Spherical Mercator
Eric Lemoine
eric.lemoine at camptocamp.com
Sun May 3 06:51:14 EDT 2009
On Sunday, May 3, 2009, Albin Blaschka
<albin.blaschka at standortsanalyse.net> wrote:
>
> Dear List,
>
> I have the following code:
>
> var map;
> function initMap() {
> var proj = new OpenLayers.Projection("EPSG:4326");
>
> var options = {
> projection: new OpenLayers.Projection("EPSG:900913"),
> displayProjection: new OpenLayers.Projection("EPSG:4326"),
> units: "m"
> };
>
> map = new OpenLayers.Map('map', options);
>
> var gsat = new OpenLayers.Layer.Google(
> "Google Satellite",
> {type: G_SATELLITE_MAP,
> 'sphericalMercator': true,
> numZoomLevels: 22}
> );
> var ghyb = new OpenLayers.Layer.Google(
> "Google Hybrid",
> {type: G_HYBRID_MAP,
> 'sphericalMercator': true}
> );
> map.addLayers([gsat, ghyb]);
>
> var bounds = new OpenLayers.Bounds(12.5, 47.0, 13.5, 48.0);
> bounds.transform(proj, map.getProjectionObject());
>
> var point = new OpenLayers.LonLat(13.0, 47.41);
> point.transform(proj, map.getProjectionObject());
> map.setCenter(point);
> }
> I have the following problem: I do not get my wished extent, but the
> whole world two times... Online at http://maps.sabotag.at
>
> What did I wrong? Any tips appreciated...
>
> Thank you in advance,
> best wishes from Salzburg, Austria,
Either use map.zoomToExtent(bounds) or map.setCenter(lonlat,
zoomLevel) (you don't give setCenter a zoom level in the code you
provided above)
Hope this helps
>
> Albin
>
> --
> ---------------------------------------------------------------------
> | Albin Blaschka, Mag. rer.nat - Salzburg, Austria
> | http://www.albinblaschka.info http://www.thinkanimal.info
> | It's hard to live in the mountains, hard, but not hopeless!
> ---------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
--
Eric Lemoine
Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex
Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com
More information about the Users
mailing list