Skip to content

Commit

Permalink
Changed map functionality in device overview
Browse files Browse the repository at this point in the history
Changed map in overview page for devices so that it is possible to move and drop the marker to update position, and possible to pan/move map without marker being stuck in center, marker stays in its fixed position.
  • Loading branch information
kimhaak committed Sep 10, 2021
1 parent 258505e commit 591ba37
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions includes/html/dev-overview-data.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,21 @@
<script>
var device_marker, device_location, device_map;
$("#toggle-map").on("shown.bs.collapse", function () {
if (device_marker == null) {
if (device_marker == null) {
device_location = new L.LatLng(' . (float) $location->lat . ', ' . (float) $location->lng . ');
config = {"tile_url": "' . Config::get('leaflet.tile_url', '{s}.tile.openstreetmap.org') . '"};
device_map = init_map("location-map", "' . $maps_engine . '", "' . $maps_api . '", config);
device_marker = init_map_marker(device_map, device_location);
device_marker = L.marker(device_location).addTo(device_map);
device_map.setView(device_location);
device_map.setZoom(18);
device_marker.dragging.enable();
';

if (Auth::user()->isAdmin()) {
echo ' device_map.on("dragend", function () {
echo ' device_marker.on("dragend", function () {
var new_location = device_marker.getLatLng();
if (confirm("Update location to " + new_location + "? This will update this location for all devices!")) {
update_location(' . $location->id . ', new_location, function(success) {
Expand Down

0 comments on commit 591ba37

Please sign in to comment.