Select to view content in your preferred language

Single Click Zoom in\Zoom Out with esri.toolbars.Navigation

1495
2
10-22-2012 03:46 PM
MeleKoneya
Frequent Contributor
We have implemented the esri.toolbars.Navigation in an application and I would like to make it work so that when someone clicks once on the map,  the map either zooms in or zooms out depending on the tool selection using the click point as center.

I would also like to have rubber band zoom enabled when using the Zoom in tool.

Has anyone implemented something like this?

Thanks for your assistance.

Mele
0 Kudos
2 Replies
MichalGasparovic
Occasional Contributor
Well, isn't one of the already existing implementations enough?
- mouse wheel scroll
- double-click the map to zoom

In case you still want to use the map navigation toolbar and have that sort of a combination of a single click-or-draw rectangle then just listen to to map mouse events. If the there is a combination of mousedown and mousemove while no mouseup was called, then call the standard esri tool. If there is a combo of mousedown and mouseup, zoom one level in (or whatever fixed extent you are going to have)
0 Kudos
JeffPace
MVP Alum
i use an HTML snippet to determine tool (in my if statements)
Yes i know i should use switch/case instead of ifs
(my code actually uses onDblClick, but there is an onClick event for the map object as well).


dojo.connect(map, "onClick", dojo.hitch(this, function(evt) {
                    if(dojo.byId("controllerStatus").innerHTML=="Current Action: Zoom Out"){   
                        this.map.centerAndZoom(this.map.toMap(evt.screenPoint),this.map.getLevel()-1);
                    }
                    else if(dojo.byId("controllerStatus").innerHTML=="Current Action: Zoom In"){
                        this.map.centerAndZoom(this.map.toMap(evt.screenPoint),this.map.getLevel()+1);
                    }
                    else if(dojo.byId("controllerStatus").innerHTML=="Current Action: Move Map"){
                        this.map.centerAt(this.map.toMap(evt.screenPoint));
                    }else if(dojo.byId("controllerStatus").innerHTML==""||!dojo.byId("controllerStatus").innerHTML){
                         this.map.centerAndZoom(this.map.toMap(evt.screenPoint),this.map.getLevel()+1);
                          this.map.centerAt(this.map.toMap(evt.screenPoint));
                    }
                }));
0 Kudos