You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I put together a simple control that allows the user to zoom to the minScale of a layer if there is one set. It works just like the opacity control: there is an icon the user hovers over with the cursor (or taps on mobile) and it pops up a small box with two selections in it: Zoom to scale and Zoom to center.
I have those two options specifically for project needs on WLERA, but we could tweak them for more generic appeal.
Icons, for hover/tap
The dialog. Can be closed by mouse-out or by tapping the close X.
Logic for zoom to (esri api):
$(".zoomto").hover(function(e){$(".zoomDialog").remove();varlayerToChange=this.parentNode.id;varzoomDialog=$('<div class="zoomDialog"><label class="zoomClose pull-right">X</label><br><div class="list-group"><a href="#" id="zoomscale" class="list-group-item zoomscale">Zoom to scale</a> <a id="zoomcenter" href="#" class="list-group-item zoomcenter">Zoom to center</a></div></div>');$("body").append(zoomDialog);$(".zoomDialog").css('left',event.clientX-80);$(".zoomDialog").css('top',event.clientY-5);$(".zoomDialog").mouseleave(function(){$(".zoomDialog").remove();});$(".zoomClose").click(function(){$(".zoomDialog").remove();});$('#zoomscale').click(function(e){//logic to zoom to layer scalevarlayerMinScale=map.getLayer(layerToChange).minScale;map.setScale(layerMinScale);});$("#zoomcenter").click(function(e){//logic to zoom to layer centervarlayerCenter=map.getLayer(layerToChange).fullExtent.getCenter();map.centerAt(layerCenter);});});
An option, in place of the zoom to center, is zoom to extent, which would look like this:
I've tested, and all these methods work. The weakness with zoom to layer extent is it does not respect scale dependency. All three methods have strengths and weaknesses, so want to know what you guys think.
The text was updated successfully, but these errors were encountered:
I went ahead and incorporated this to the esri track with pull request #83. As stated in the PR notes, what I put together has 3 options, and the one most in question is the zoom to center. As currently merged in the master branch, that button brings the user to the map default center. Could easily be updated to the layer's center, or maybe we don't need that button at all - seems the least useful.
I put together a simple control that allows the user to zoom to the minScale of a layer if there is one set. It works just like the opacity control: there is an icon the user hovers over with the cursor (or taps on mobile) and it pops up a small box with two selections in it: Zoom to scale and Zoom to center.
I have those two options specifically for project needs on WLERA, but we could tweak them for more generic appeal.
Icons, for hover/tap
The dialog. Can be closed by mouse-out or by tapping the close X.
Logic for zoom to (esri api):
An option, in place of the zoom to center, is zoom to extent, which would look like this:
I've tested, and all these methods work. The weakness with zoom to layer extent is it does not respect scale dependency. All three methods have strengths and weaknesses, so want to know what you guys think.
The text was updated successfully, but these errors were encountered: