Select to view content in your preferred language

Accessing Zoom To Point On ArcGIS JavaScript API

6702
7
Jump to solution
01-13-2017 11:51 AM
BehrouzHosseini
Regular Contributor

Can you please let me know how we can enable ArcGIS JavaScript API to use custom ZoomIn function?

For example let's say I have a code Like

<button id="zoom-to-point" > Zoom To </button>

 and in Js Part

$("#zoom-to-point").on('click', function(){
 var zoomLat = 49.2898
 var zoomLong = -123.1364;
 map.zoomTo(zoomLat,zoomLong );
});‍‍‍‍‍

As you know we have not such a .zoomTo function in API so can you please let me know how can I get it done?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Behrouz,

   location is a point class. So you just create a point class and pass it to the centerAndZoom method.

View solution in original post

0 Kudos
7 Replies
BehrouzHosseini
Regular Contributor

Thanks Robert,

so how can I pass the

var zoomLat = 49.2898
var zoomLong = -123.1364;

 to location in :

map.centerAndZoom(location,12);

Thanks again

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Behrouz,

   location is a point class. So you just create a point class and pass it to the centerAndZoom method.

0 Kudos
BehrouzHosseini
Regular Contributor

Thanks Robert

0 Kudos
BehrouzHosseini
Regular Contributor

I Tried this and it is working, but not sure if it is the best way to do?

 var location = new Point(zoomLong,zoomLat);
 map.centerAndZoom(location,16);

can you please let me know if there is a better way to do this?

0 Kudos
EvonFranklin
Regular Contributor

What version of the API are you using?

0 Kudos
BehrouzHosseini
Regular Contributor

Hi Evon,

Thanks for reply, I am using 3.19

0 Kudos