Skip to content

Commit

Permalink
Merge pull request #23 from Wowu/fix/load-current-cords
Browse files Browse the repository at this point in the history
Openstreetmap: Load form coords instead of default ones
  • Loading branch information
forsaken1 authored Apr 20, 2019
2 parents 19fe2fc + 5d6ee6a commit 2512e55
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/activeadmin/views/templates/openstreetmap.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@
});
},

getCoordinates: function() {
return {
lat: parseFloat($("#" + osmObject.idLat).val()) || <%= default_lat %>,
lng: parseFloat($("#" + osmObject.idLng).val()) || <%= default_lng %>,
};
},

newLocation: function(item) {
$("#"+osmObject.idLat).val(item.lat);
$("#"+osmObject.idLng).val(item.lon);
Expand All @@ -88,20 +95,21 @@
}

$(document).ready(function () {
osmObject.init(<%= default_lat %>, <%= default_lng %>);
var coordinates = osmObject.getCoordinates();
osmObject.init(coordinates.lat, coordinates.lng);
});
</script>
<style>
#latlng-search-box {
height: 18px;
position: relative;
left: 52px;
top: 39px;
top: 44px;
max-width: 400px;
z-index: 2;
border-radius: 4px;
}
</style>
<input id="latlng-search-box" class="leaflet-bar" type="text" style="" placeholder="Search address...">
<input id="latlng-search-box" class="leaflet-bar" type="text" style="" placeholder="Type address and hit enter...">
<div id="locationPicker" style="width: auto; height: <%= height %>px;"></div>
</li>

0 comments on commit 2512e55

Please sign in to comment.