Select to view content in your preferred language

building custom zoom buttons for a basemap gallery

1030
6
12-13-2011 11:54 AM
PaulJereb
Emerging Contributor
Hello!

I'm using a basemap gallery with three maps (two static, one dynamic) in a mobile webapp.

How can I build custom zoom buttons?

I tried to find out what methods the built in buttons are using, without success and I also couldn't find anything in the API Reference...

BR Paul
0 Kudos
6 Replies
KellyHutchins
Esri Frequent Contributor
One way to accomplish this would be to use the Navigation toolbar. Here's a link to a sample:

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/toolbar_naviga...
0 Kudos
PaulJereb
Emerging Contributor
Thanks Kelly, that would be exactly what I need. I tried to add it to my project but it didn't work. Also when trying to zoom in/out using the buttons in the demo you posted nothing happens...

(I tested it with firefox, chrome and safari)

BR Paul
0 Kudos
KellyHutchins
Esri Frequent Contributor
After clicking on the zoom buttons you'll need to draw a zoom extent on the map in order for the zoom action to occur.

You mentioned that it doesn't work in your project. Can you post code?
0 Kudos
PaulJereb
Emerging Contributor
ah ok, that explains a lot 😉 I'd need the zoom functionality for a mobile webapp (iOS), so it should zoom right on the click of the button. Like the built-in zoom-buttons in this sample:

http://help.arcgis.com/en/webapi/javascript/arcgis/demos/mobile/mobile_simplemap.html
0 Kudos
KellyHutchins
Esri Frequent Contributor
Paul,

You could create zoom buttons that modify the map's extent. Something like this:

 <div data-dojo-type="dijit.form.Button" id="zoomin"  data-dojo-props="iconClass:'zoominIcon', onClick:function(){map.setExtent(map.extent.expand(0.5));}">Zoom In</div>
      <div data-dojo-type="dijit.form.Button" id="zoomout" data-dojo-props="iconClass:'zoomoutIcon', onClick:function(){map.setExtent(map.extent.expand(2));}">Zoom Out</div>
0 Kudos
PaulJereb
Emerging Contributor
PERFECT!
Thank you, Kelly!
0 Kudos