Select to view content in your preferred language

Changing extent of an ArcGIS Online map

1507
10
Jump to solution
10-10-2013 05:20 AM
HeiJo
by
Deactivated User
Hi everyone,
I follow this example: https://developers.arcgis.com/en/javascript/jssamples/ags_createwebmapitem.html
It's said those lines of code below can do changing the extent of the map, but when I try to modify the values of XMin, YMin, XMax, YMax it seems does not effect anymore:
//By default the extent will be that of the web map. Here we change it to a custom extent.            var extent = new Extent({             "xmin": "-13529153",             "ymin": "4665612",             "xmax": "-13281497",             "ymax": "872422882",             "spatialReference": {"wkid": 102100}           });            map.setExtent(extent);


So could any of you explain me why?
Thank you!
0 Kudos
1 Solution

Accepted Solutions
ChristopherBlinn1
Deactivated User
The ymax value is too large, and also the quotes around the extent values need to be removed.

I downloaded the example and have it working on my machine with this extent:

var extent = new esri.geometry.Extent({      "xmin": -13529153,      "ymin": 4665612,      "xmax": -13281497,      "ymax": 4865612,      "spatialReference": {"wkid": 102100} });  map.setExtent(extent);


Hope this helps!

Chris B.

View solution in original post

0 Kudos
10 Replies
ChristopherBlinn1
Deactivated User
Hei Jo,

Check your ymax value.

You are probably missing a decimal.

I know this website was created for flex viewer but it can still be used to define your web mercator extent values.

Hope this helps!

Best,
Chris B.
0 Kudos
HeiJo
by
Deactivated User
Thanks for your quick response!
I already change the value based on the app you provided.
But it still doesn't work.
And I found that those lines of code make the example hang (when zoom in or zoom out, the map disappear). When I remove those lines, it works properly.
0 Kudos
HeiJo
by
Deactivated User
And my bigger question is an ArcGIS Online web map is treated the sample like normal map or not?
The information I found about "esri/arcgis/utils" is quite little.
0 Kudos
ChristopherBlinn1
Deactivated User
Hei Jo,

I am trying to get the sample page you posted to work, but it keeps having issues (same to the issues you are having with the map not functioning correctly).

I see when adding the webmap.item you can specify the extent.  Have you tried editing these values with your custom extent values?

Also, be sure your namespaces are loaded and any preceding tasks on your page load have completed successfully.

-Chris B.
0 Kudos
HeiJo
by
Deactivated User
Dear Chris,
I tried changing extent in webmap.item, but the issue still come...

I think maybe the reason come from: the new extent need to make the map meet the specific scales of Web Mercator?
0 Kudos
ChristopherBlinn1
Deactivated User
Hei Jo,

Try this:

var extent = new esri.geometry.Extent({
     "xmin": -13529153,
     "ymin": 4665612,
     "xmax": -13281497,
     "ymax": 872422882,
     "spatialReference": {"wkid": 102100}
}); 
map.setExtent(extent);


-Chris B.
0 Kudos
HeiJo
by
Deactivated User
It still not work, Chris
0 Kudos
ChristopherBlinn1
Deactivated User
The ymax value is too large, and also the quotes around the extent values need to be removed.

I downloaded the example and have it working on my machine with this extent:

var extent = new esri.geometry.Extent({      "xmin": -13529153,      "ymin": 4665612,      "xmax": -13281497,      "ymax": 4865612,      "spatialReference": {"wkid": 102100} });  map.setExtent(extent);


Hope this helps!

Chris B.
0 Kudos
HeiJo
by
Deactivated User
It works perfectly, Chris 🙂
So it needed to remove the quotes around the values also

Thanks again for your kind help!
0 Kudos