From 552c060857e00a188ab65c437293dacacb730cec Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 26 Apr 2019 15:58:51 -0400 Subject: [PATCH] Working on setup of lat lon boundries. Showing a rectangle with two markers. Moving the markers updates the rectangle and the fields. TODO: add management options to save bounds_enable bool bounds_lat_min float bounds_lat_max float bounds_lon_min float bounds_lon_max float --- views/admin/management/index.html | 63 +++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/views/admin/management/index.html b/views/admin/management/index.html index d3babe0c..39cbee46 100755 --- a/views/admin/management/index.html +++ b/views/admin/management/index.html @@ -254,6 +254,22 @@
Please enter values in decimal degrees. + {if $genSettings.fieldData.selected_map_interface.value == 1} + + Lat Lon Bounds: + + +
+ + +
+ +
+ + + + + {/if} @@ -738,6 +754,11 @@ var startLon = $('#glmLng').val(); var defZoom = Number($('#mapDefZoom').val()); + var latMin = $('#glmBoundsLatMin').val(); + var latMax = $('#glmBoundsLatMax').val(); + var lonMin = $('#glmBoundsLonMin').val(); + var lonMax = $('#glmBoundsLonMax').val(); + {if $genSettings.fieldData.selected_map_interface.value == 1} /* @@ -778,6 +799,48 @@ $('#glmLng').val(position.lng.toFixed(6)); }); + var glmArea = [[latMin, lonMax],[latMax, lonMin]]; + var glmRec = L.rectangle(glmArea, { + color: '#ff7800', weight: 1 + }).addTo(leafletMap); + + var swMarker = L.marker([latMin, lonMin], { + draggable: true + }).addTo(leafletMap); + swMarker.on('dragend', function(event){ + var tMarker = event.target; + var position = tMarker.getLatLng(); + console.log( 'position', position ); + tMarker.setLatLng(new L.LatLng(position.lat, position.lng),{ draggable:'true' }); + + glmRec.removeFrom(leafletMap); + glmArea = [[position.lat.toFixed(6), lonMax],[latMax, position.lng.toFixed(6)]]; + glmRec = L.rectangle(glmArea, { + color: '#ff7800', weight: 1 + }).addTo(leafletMap); + + $('#glmBoundsLatMin').val(position.lat.toFixed(6)); + $('#glmBoundsLonMin').val(position.lng.toFixed(6)); + }); + var neMarker = L.marker([latMax, lonMax], { + draggable: true + }).addTo(leafletMap); + neMarker.on('dragend', function(event){ + var tMarker = event.target; + var position = tMarker.getLatLng(); + console.log( 'position', position ); + tMarker.setLatLng(new L.LatLng(position.lat, position.lng),{ draggable:'true' }); + + glmRec.removeFrom(leafletMap); + glmArea = [[latMin, position.lng.toFixed(6)],[position.lat.toFixed(6), lonMin]]; + glmRec = L.rectangle(glmArea, { + color: '#ff7800', weight: 1 + }).addTo(leafletMap); + + $('#glmBoundsLatMax').val(position.lat.toFixed(6)); + $('#glmBoundsLonMax').val(position.lng.toFixed(6)); + }); + } // Set map zoom when changing default zoom level -- 2.17.1