Skip to content

Commit 6f96fa7

Browse files
authored
Merge pull request #304 from Resgrid/develop
RE1-T105 Map fixes
2 parents c306095 + 5e8c9ea commit 6f96fa7

7 files changed

Lines changed: 86 additions & 17 deletions

File tree

Web/Resgrid.Web/Areas/User/Views/Dispatch/AddArchivedCall.cshtml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@
6666
<div class="row">
6767
<div class="col-md-8 col-md-offset-1">
6868
@Html.AntiForgeryToken()
69-
@Html.HiddenFor(m => m.Latitude)
70-
@Html.HiddenFor(m => m.Longitude)
7169
@Html.HiddenFor(m => m.Call.ReportingUserId)
7270
@Html.HiddenFor(m => m.Call.CallFormData)
7371
<div asp-validation-summary="All" class="text-danger"></div>
@@ -181,7 +179,20 @@
181179
<span class="help-inline">@localizer["W3wHelp"] <a href="https://what3words.com/about/" target="_blank">@localizer["LearnMore"]</a></span>
182180
</div>
183181
</div>
184-
<div id="callMap" name="callMap" style="position: relative; width: 90%; height: 500px;"></div>
182+
<div class="row" style="margin-top: 8px;">
183+
<div class="col-md-11">
184+
<div class="input-group input-group-sm">
185+
<span class="input-group-addon">Lat</span>
186+
<input type="text" class="form-control" asp-for="Latitude" placeholder="Latitude">
187+
<span class="input-group-addon">Lng</span>
188+
<input type="text" class="form-control" asp-for="Longitude" placeholder="Longitude">
189+
<span class="input-group-btn">
190+
<a id="setPinButton" href="#" class="btn btn-warning">Set Pin on Map</a>
191+
</span>
192+
</div>
193+
</div>
194+
</div>
195+
<div id="callMap" name="callMap" style="position: relative; width: 90%; height: 500px; margin-top: 8px;"></div>
185196
</div>
186197
</div>
187198
<div class="form-group">

Web/Resgrid.Web/Areas/User/Views/Dispatch/NewCall.cshtml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@
6363
<div class="row">
6464
<div class="col-md-8 col-md-offset-1">
6565
@Html.AntiForgeryToken()
66-
@Html.HiddenFor(m => m.Latitude)
67-
@Html.HiddenFor(m => m.Longitude)
6866
@Html.HiddenFor(m => m.Call.ReportingUserId)
6967
@Html.HiddenFor(m => m.Call.CallFormData)
7068
<div asp-validation-summary="All" class="text-danger"></div>
@@ -174,7 +172,20 @@
174172
<span class="help-inline">@localizer["W3wHelp"] <a href="https://what3words.com/about/" target="_blank">@localizer["LearnMore"]</a></span>
175173
</div>
176174
</div>
177-
<div id="callMap" name="callMap" style="position: relative; width: 90%; height: 500px;"></div>
175+
<div class="row" style="margin-top: 8px;">
176+
<div class="col-md-11">
177+
<div class="input-group input-group-sm">
178+
<span class="input-group-addon">Lat</span>
179+
<input type="text" class="form-control" asp-for="Latitude" placeholder="Latitude">
180+
<span class="input-group-addon">Lng</span>
181+
<input type="text" class="form-control" asp-for="Longitude" placeholder="Longitude">
182+
<span class="input-group-btn">
183+
<a id="setPinButton" href="#" class="btn btn-warning">Set Pin on Map</a>
184+
</span>
185+
</div>
186+
</div>
187+
</div>
188+
<div id="callMap" name="callMap" style="position: relative; width: 90%; height: 500px; margin-top: 8px;"></div>
178189
</div>
179190
</div>
180191
<div class="form-group">

Web/Resgrid.Web/Areas/User/Views/Dispatch/UpdateCall.cshtml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@
6363
<div class="row">
6464
<div class="col-md-8 col-md-offset-1">
6565
@Html.AntiForgeryToken()
66-
@Html.HiddenFor(m => m.Latitude)
67-
@Html.HiddenFor(m => m.Longitude)
6866
@Html.HiddenFor(m => m.Call.CallId)
6967
@Html.HiddenFor(m => m.Call.ReportingUserId)
7068
@Html.HiddenFor(m => m.Call.CallFormData)
@@ -175,7 +173,20 @@
175173
<span class="help-inline">@localizer["W3wHelp"] <a href="https://what3words.com/about/" target="_blank">@localizer["LearnMore"]</a></span>
176174
</div>
177175
</div>
178-
<div id="callMap" name="callMap" style="position: relative; width: 90%; height: 500px;"></div>
176+
<div class="row" style="margin-top: 8px;">
177+
<div class="col-md-11">
178+
<div class="input-group input-group-sm">
179+
<span class="input-group-addon">Lat</span>
180+
<input type="text" class="form-control" asp-for="Latitude" placeholder="Latitude">
181+
<span class="input-group-addon">Lng</span>
182+
<input type="text" class="form-control" asp-for="Longitude" placeholder="Longitude">
183+
<span class="input-group-btn">
184+
<a id="setPinButton" href="#" class="btn btn-warning">Set Pin on Map</a>
185+
</span>
186+
</div>
187+
</div>
188+
</div>
189+
<div id="callMap" name="callMap" style="position: relative; width: 90%; height: 500px; margin-top: 8px;"></div>
179190
</div>
180191
</div>
181192
<div class="form-group">

Web/Resgrid.Web/wwwroot/js/app/internal/dispatch/resgrid.dispatch.addArchivedCall.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ var resgrid;
115115
if (result && result.Data && result.Data.Latitude && result.Data.Longitude) {
116116
var lat = result.Data.Latitude;
117117
var lng = result.Data.Longitude;
118-
map.panTo(new L.LatLng(lat, lng));
118+
map.setView(new L.LatLng(lat, lng), 16);
119119
$("#Latitude").val(lat.toString());
120120
$("#Longitude").val(lng.toString());
121121
resgrid.dispatch.addArchivedCall.setMarkerLocation(lat, lng);
@@ -126,6 +126,17 @@ var resgrid;
126126
.catch(function(err) { console.error("Geocode error:", err); });
127127
evt.preventDefault();
128128
});
129+
$("#setPinButton").click(function (evt) {
130+
var lat = parseFloat($("#Latitude").val());
131+
var lng = parseFloat($("#Longitude").val());
132+
if (isNaN(lat) || isNaN(lng)) {
133+
alert("Please enter valid numeric latitude and longitude values.");
134+
return false;
135+
}
136+
map.setView(new L.LatLng(lat, lng), 16);
137+
resgrid.dispatch.addArchivedCall.setMarkerLocation(lat, lng);
138+
evt.preventDefault();
139+
});
129140
$("#findw3wButton").click(function (evt) {
130141
var word = jQuery.trim($("#What3Word").val());
131142
if (word.length < 1)
@@ -136,7 +147,7 @@ var resgrid;
136147
type: 'GET'
137148
}).done(function (data) {
138149
if (data && data.Latitude && data.Longitude) {
139-
map.panTo(new L.LatLng(data.Latitude, data.Longitude));
150+
map.setView(new L.LatLng(data.Latitude, data.Longitude), 16);
140151

141152
$("#Latitude").val(data.Latitude);
142153
$("#Longitude").val(data.Longitude);

Web/Resgrid.Web/wwwroot/js/app/internal/dispatch/resgrid.dispatch.editcall.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ var resgrid;
124124
if (result && result.Data && result.Data.Latitude != null && result.Data.Longitude != null) {
125125
var lat = result.Data.Latitude;
126126
var lng = result.Data.Longitude;
127-
map.panTo(new L.LatLng(lat, lng));
127+
map.setView(new L.LatLng(lat, lng), 16);
128128
$("#Latitude").val(lat.toString());
129129
$("#Longitude").val(lng.toString());
130130
resgrid.dispatch.editcall.setMarkerLocation(lat.toString(), lng.toString());
@@ -146,7 +146,7 @@ var resgrid;
146146
type: 'GET'
147147
}).done(function (data) {
148148
if (data && data.Latitude && data.Longitude) {
149-
map.panTo(new L.LatLng(data.Latitude, data.Longitude));
149+
map.setView(new L.LatLng(data.Latitude, data.Longitude), 16);
150150

151151
$("#Latitude").val(data.Latitude);
152152
$("#Longitude").val(data.Longitude);
@@ -162,6 +162,18 @@ var resgrid;
162162
evt.preventDefault();
163163
});
164164

165+
$("#setPinButton").click(function (evt) {
166+
var lat = parseFloat($("#Latitude").val());
167+
var lng = parseFloat($("#Longitude").val());
168+
if (isNaN(lat) || isNaN(lng)) {
169+
alert("Please enter valid numeric latitude and longitude values.");
170+
return false;
171+
}
172+
map.setView(new L.LatLng(lat, lng), 16);
173+
resgrid.dispatch.editcall.setMarkerLocation(lat.toString(), lng.toString());
174+
evt.preventDefault();
175+
});
176+
165177
$('#protocolQuestionWindow').on('show.bs.modal', function (event) {
166178
var protocolId = $(event.relatedTarget).data('protocolid');
167179

Web/Resgrid.Web/wwwroot/js/app/internal/dispatch/resgrid.dispatch.newcall.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ var resgrid;
120120
if (result && result.Data && result.Data.Latitude != null && result.Data.Longitude != null) {
121121
var lat = result.Data.Latitude;
122122
var lng = result.Data.Longitude;
123-
map.panTo(new L.LatLng(lat, lng));
123+
map.setView(new L.LatLng(lat, lng), 16);
124124
$("#Latitude").val(lat.toString());
125125
$("#Longitude").val(lng.toString());
126126
resgrid.dispatch.newcall.setMarkerLocation(lat, lng);
@@ -141,7 +141,7 @@ var resgrid;
141141
type: 'GET'
142142
}).done(function (data) {
143143
if (data && data.Latitude != null && data.Longitude != null) {
144-
map.panTo(new L.LatLng(data.Latitude, data.Longitude));
144+
map.setView(new L.LatLng(data.Latitude, data.Longitude), 16);
145145

146146
$("#Latitude").val(data.Latitude);
147147
$("#Longitude").val(data.Longitude);
@@ -156,6 +156,17 @@ var resgrid;
156156
});
157157
evt.preventDefault();
158158
});
159+
$("#setPinButton").click(function (evt) {
160+
var lat = parseFloat($("#Latitude").val());
161+
var lng = parseFloat($("#Longitude").val());
162+
if (isNaN(lat) || isNaN(lng)) {
163+
alert("Please enter valid numeric latitude and longitude values.");
164+
return false;
165+
}
166+
map.setView(new L.LatLng(lat, lng), 16);
167+
resgrid.dispatch.newcall.setMarkerLocation(lat, lng);
168+
evt.preventDefault();
169+
});
159170
var personnelTable = $("#personnelGrid").DataTable({
160171
ajax: { url: resgrid.absoluteBaseUrl + '/User/Personnel/GetPersonnelForCallGrid?callLat=' + $("#Latitude").val() + '&callLong=' + $("#Longitude").val(), dataSrc: '' },
161172
paging: false,

Web/Resgrid.Web/wwwroot/js/app/internal/routes/resgrid.routes.edit.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ $(document).ready(function () {
3737
editStops.forEach(function (stop, index) {
3838
if (stop.lat != null && stop.lng != null && Number.isFinite(Number(stop.lat)) && Number.isFinite(Number(stop.lng))) {
3939
var m = L.marker([stop.lat, stop.lng]).addTo(map);
40+
m.bindTooltip((index + 1) + '. ' + escapeHtml(stop.Name), { permanent: true, direction: 'right' });
4041
m.bindPopup('<strong>' + (index + 1) + '. ' + escapeHtml(stop.Name) + '</strong>');
4142
group.push(m);
4243
}
@@ -288,8 +289,9 @@ $(document).ready(function () {
288289
editStops = editStops.filter(function (s) { return s.id !== stopId; });
289290
editStops.forEach(function (stop, index) {
290291
if (stop.lat != null && stop.lng != null && Number.isFinite(Number(stop.lat)) && Number.isFinite(Number(stop.lng))) {
291-
L.marker([stop.lat, stop.lng]).addTo(map)
292-
.bindPopup('<strong>' + (index + 1) + '. ' + escapeHtml(stop.Name) + '</strong>');
292+
var m = L.marker([stop.lat, stop.lng]).addTo(map);
293+
m.bindTooltip((index + 1) + '. ' + escapeHtml(stop.Name), { permanent: true, direction: 'right' });
294+
m.bindPopup('<strong>' + (index + 1) + '. ' + escapeHtml(stop.Name) + '</strong>');
293295
}
294296
});
295297
}

0 commit comments

Comments
 (0)