yozawiratama
yozawiratama

Reputation: 4328

esri javascript zoom to place

i have a problem that i want to zoom to place using esri javascript api

i have this class from esriGetStarted javascript

function zoomToPlace(lon, lat, scale) {
          mapDeferred.centerAndZoom([lon, lat], scale);
      }

i have tried to zoom to place using this html element :

<a href="#place" class="buttonStyle" onclick="javascript:zoomToPlace('118.12', '-5.52', '9');">zoom to place </a>

but it never work untill now, please help me how to zoom to place, or may be is there alternative.

Upvotes: 0

Views: 1619

Answers (2)

BretW
BretW

Reputation: 199

Not sure if this will help, but there is a Locate Widget in the ESRI API:

require(["esri/dijit/LocateButton"],

geoLocate = new LocateButton({
            map: map
        }, "LocateButton");
        geoLocate.startup();

Upvotes: 0

Juffy
Juffy

Reputation: 1220

You may be having spatial reference issues (first port of call for any error with a mapping engine :) ). My code from an existing project converts the coordinates to web mercator before attempting to zoom to it:

var pt = esri.geometry.geographicToWebMercator(new esri.geometry.Point(lon, lat));
_map.centerAndZoom(pt, scale);

Upvotes: 1

Related Questions