ThinkGeo.com    |     Documentation    |     Premium Support

Centering on lat/long with Google overlay

Given a latitude and longitude in DMS, what's the best way to center on that lat/long at street level?


  For instance, let's say I have coordinates of -80.0612, 26.8495. I would like to center the Google overlay using those coordinates at street level...



We have a client API - SetCenter(lon,lat) - to center your map, please have a look at the javascirpt as following. 

Do not forget to replace the “Map1” with the ID of your map. 




 [script removed]
        function setCenter(lon, lat) {

            //Convert the coordinates in DMS to coordinates in Google projection
            var pointInDMS = new OpenLayers.Geometry.Point(lon, lat);
            var pointInGoogle = pointInDMS.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));

            <%=Map1.ClientID%>.SetCenter(pointInGoogle.x, pointInGoogle.y);
        }
    [script removed]


Ben.



263-post5055.txt (549 Bytes)