diff --git a/people/static/js/location_picker.js b/people/static/js/location_picker.js index fc15d4d..188644b 100644 --- a/people/static/js/location_picker.js +++ b/people/static/js/location_picker.js @@ -1,5 +1,4 @@ -let marker = null; let search_markers = [] /** @@ -7,9 +6,9 @@ let search_markers = [] * @param {Event} event - Click event from a Google Map. */ function selectLocation(event) { - if (marker === null) { + if (selected_marker === null) { // Generate a new marker - marker = new google.maps.Marker({ + selected_marker = new google.maps.Marker({ position: event.latLng, map: map, icon: { @@ -24,10 +23,10 @@ function selectLocation(event) { }, }); } else { - marker.setPosition(event.latLng); + selected_marker.setPosition(event.latLng); } - const pos = marker.getPosition(); + const pos = selected_marker.getPosition(); document.getElementById('id_latitude').value = pos.lat(); document.getElementById('id_longitude').value = pos.lng(); } diff --git a/people/static/js/map.js b/people/static/js/map.js index 5945c99..905601e 100644 --- a/people/static/js/map.js +++ b/people/static/js/map.js @@ -11,6 +11,7 @@ const marker_edge_alpha = 1.0; const marker_edge_width = 1.0; let map = null; +let selected_marker = null; let selected_marker_info = null; function createMarker(map, marker_data) { @@ -75,6 +76,9 @@ function initMap() { try { const marker = createMarker(map, marker_data); bounds.extend(marker.position); + if (markers_data.length === 1) { + selected_marker = marker; + } } catch (exc) { // Just skip and move on to next