diff --git a/js/id/behavior/hash.js b/js/id/behavior/hash.js index af2c3b296..8004287f4 100644 --- a/js/id/behavior/hash.js +++ b/js/id/behavior/hash.js @@ -40,12 +40,14 @@ iD.behavior.Hash = function(context) { // the hash can declare that the map should select a feature, but it can // do so before any features are loaded. thus wait for the feature to // be loaded and then select - function willselect(id) { - context.connection().loadEntity(id, function(error, entity) { - if (entity) { - context.map().zoomTo(entity); - } - }); + function willselect(id, hasMap) { + if (!hasMap) { + context.connection().loadEntity(id, function(error, entity) { + if (entity) { + context.map().zoomTo(entity); + } + }); + } context.map().on('drawn.hash', function() { if (!context.hasEntity(id)) return; @@ -71,7 +73,7 @@ iD.behavior.Hash = function(context) { if (location.hash) { var q = iD.util.stringQs(location.hash.substring(1)); - if (q.id) willselect(q.id); + if (q.id) willselect(q.id, q.map); hashchange(); if (q.map) hash.hadHash = true; } diff --git a/js/id/renderer/map.js b/js/id/renderer/map.js index 1b7ac2595..9a6b7a224 100644 --- a/js/id/renderer/map.js +++ b/js/id/renderer/map.js @@ -350,10 +350,11 @@ iD.Map = function(context) { return redraw(); }; - map.zoomTo = function(entity) { + map.zoomTo = function(entity, zoomLimits) { var extent = entity.extent(context.graph()), zoom = map.extentZoom(extent); - map.centerZoom(extent.center(), zoom); + zoomLimits = zoomLimits || [16, 20]; + map.centerZoom(extent.center(), Math.min(Math.max(zoom, zoomLimits[0]), zoomLimits[1])); }; map.centerZoom = function(loc, z) {