Skip to content

Commit

Permalink
Openstreetmap: Load current coords instead of default ones
Browse files Browse the repository at this point in the history
* Improve styling
  • Loading branch information
wowu committed Apr 19, 2019
1 parent 19fe2fc commit 5d6ee6a
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 5d6ee6a

Please sign in to comment.