[OpenLayers-Users] How to make OpenLayers.Map.panTo() work?

Vincent Gulinao vincent.gulinao at gmail.com
Sat Feb 6 23:37:31 EST 2010


Sorry, accidentally sent...

I copied this from an example somewhere to start:

    map = new OpenLayers.Map('map',
        {
            numZoomLevels: 19,
              maxResolution: 156543.0399,
              units: 'm',
              projection: new OpenLayers.Projection("EPSG:900913"),
              displayProjection: new OpenLayers.Projection("EPSG:4326")
        });


    var layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
    map.addLayers([layerMapnik]);

Then I call this function from html drop-down list's onchange:

function setCenter(region) {
    lon = Math.random() * 360 - 180;
    lat = Math.random() * 180 - 90;
    var lonlat = new OpenLayers.LonLat(lon, lat);
    map.panTo(lonlat);
}

... but it only brings me to (I believe) 0,0.

I've been trying to figure it out for hours but with no luck. Please help.

TIA.

On Sun, Feb 7, 2010 at 12:30 PM, Vincent Gulinao
<vincent.gulinao at gmail.com>wrote:

> I'm a newbie, I copied this from an example somewhere to start:
>
> map = new OpenLayers.Map('map',
>         {
>             numZoomLevels: 19,
>               maxResolution: 156543.0399,
>               units: 'm',
>               projection: new OpenLayers.Projection("EPSG:900913"),
>               displayProjection: new OpenLayers.Projection("EPSG:4326")
>         });
>
>
>     var layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
> map.addLayers([layerMapnik,layerTah]);
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100207/49a1db84/attachment.html


More information about the Users mailing list