From 719148aa1cc40bfe2a22989174e828522837eb97 Mon Sep 17 00:00:00 2001 From: Tim Head Date: Sun, 23 Nov 2014 12:07:19 +0100 Subject: [PATCH 1/2] Do not move marker on double click Zoom but do not move the marker on double click on the map. --- static/js/app.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/static/js/app.js b/static/js/app.js index 51d1b31..e615a60 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -60,7 +60,8 @@ var These3Words = (function () { }); google.maps.event.addListener(that.map, 'click', function (evt) { - that.moveTo(evt.latLng); + that.mapZoom = that.map.getZoom(); + setTimeout(function() {that.moveTo(evt.latLng)}, 300); }); that.searchInput = document.createElement('input'); @@ -111,6 +112,12 @@ var These3Words = (function () { Map.prototype.moveTo = function (latLng) { var that = this; + // if zoom level has changed then the user + // double clicked instead of single clicked + // so we do not want to move, just zoom + if (that.map.getZoom() != that.mapZoom) { + return; + } apiGetFromLatLng(latLng, function (status, data) { if (status >= 200 && status < 400) { that.update(latLng, data.three); From e7eb6c22833995a8346d36235abb2acf754e355e Mon Sep 17 00:00:00 2001 From: Tim Head Date: Sun, 23 Nov 2014 12:24:59 +0100 Subject: [PATCH 2/2] Move code that prevents moveTo from running --- static/js/app.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/static/js/app.js b/static/js/app.js index e615a60..ee404b9 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -61,7 +61,16 @@ var These3Words = (function () { google.maps.event.addListener(that.map, 'click', function (evt) { that.mapZoom = that.map.getZoom(); - setTimeout(function() {that.moveTo(evt.latLng)}, 300); + setTimeout(function() { + // if zoom level has changed then the user + // double clicked instead of single clicked + // so we do not want to move, just zoom + if (that.map.getZoom() != that.mapZoom) { + return; + } + that.moveTo(evt.latLng); + }, + 300); }); that.searchInput = document.createElement('input'); @@ -112,12 +121,6 @@ var These3Words = (function () { Map.prototype.moveTo = function (latLng) { var that = this; - // if zoom level has changed then the user - // double clicked instead of single clicked - // so we do not want to move, just zoom - if (that.map.getZoom() != that.mapZoom) { - return; - } apiGetFromLatLng(latLng, function (status, data) { if (status >= 200 && status < 400) { that.update(latLng, data.three);