URL Parameters

4165
4
07-31-2012 07:33 AM
by Anonymous User
Not applicable
I'm trying to use url parameters on a web map with a map ID, specifically center on an X,Y point. After first opening my web map, the web address has &extent=x,y,x,y. When I try to change that to &center=x,y, the map simply zooms to the whole globe, not to my point. If I put an X,Y coordinate in the search box, the map zooms to my point. But using the center= parameter does not zoom to a point.

The reason I need this is I have a list of sites on a webpage and want to be able to have a user click the site and have the web map open and zoom right to that point. The help shows using center= on just a fresh web map in the viewer, but nothing about adding parameters to a web map with an ID.
Tags (2)
0 Kudos
4 Replies
MikeMinami
Esri Notable Contributor
Try specifying a level too.

http://www.arcgis.com/home/webmap/viewer.html?webmap=2def3f0c7be74f05af33ac87b8d03ef2&center=0,51&le...

I believe if you don't specify a level, the current zoom level of the map is used. Is your map currently saved at a small scale?

Thanks,

Mike
0 Kudos
PaulLohr
Occasional Contributor III

What is the deal with encoding URL parameters? The ArcGIS Online help page linked below states that URL parameters must be encoded. But the link provided by Mike M. works without encoding.

http://doc.arcgis.com/en/arcgis-online/create-maps/use-url-parameters.htm#ESRI_SECTION1_907DD20534E1...

From the page linked above:

All query parameters must be encoded. URL encoding ensures that valid characters are sent to ArcGIS Online. Encoding replaces invalid characters with % followed by their hex equivalent.

0 Kudos
MikeMinami
Esri Notable Contributor

I think this article explains URL encoding better than I can...

Percent-encoding - Wikipedia, the free encyclopedia

"When a character from the reserved set (a "reserved character") has special meaning (a "reserved purpose") in a certain context, and a URI scheme says that it is necessary to use that character for some other purpose, then the character must be percent-encoded."

Basically you encode reserved characters when they can be interpreted in the wrong context. I am by no means an expert in this area, but hopefully this example is correct and will make sense... Suppose the Center parameter required the use of ampersand before the coordinate value and didn't require a comma to separate (because the ampersand worked to separate). You might form the center parameter like this.

Center=&20&50

However, since ampersand is a reserved character that indicates a parameter on the URL, in order for the coordinates to be passed on and not interpreted as URL parameters, you'd need to encode it

Center=%2620%2650

where the %26 is the URL encoding of ampersand.

The article does say that where there isn't any confusion over context, you don't necessarily have to encode the character. But I'd say do it as a general rule...

by Anonymous User
Not applicable
Yep, that was it. Thanks Mike.

Hope the examples in the help reflect this in the future.
0 Kudos