Skip to content

Commit

Permalink
Merge pull request #129 from Resgrid/develop
Browse files Browse the repository at this point in the history
CU-8687yhbz5 adding google maps back in some pages
  • Loading branch information
ucswift authored May 24, 2024
2 parents 1c3aaf2 + 39c7e74 commit 3a68bce
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 97 deletions.
3 changes: 2 additions & 1 deletion Web/Resgrid.WebCore/Areas/User/Views/Groups/Geofence.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@

@section Scripts
{
<script src="https://maps.googleapis.com/maps/api/[email protected]"></script>
@if (String.IsNullOrWhiteSpace(Model.Group.Geofence))
{
<script type="text/javascript">
Expand All @@ -89,4 +90,4 @@
</script>

<script src="~/js/app/internal/groups/resgrid.groups.geofence.js"></script>
}
}
193 changes: 97 additions & 96 deletions Web/Resgrid.WebCore/Areas/User/Views/Mapping/LiveRouting.cshtml
Original file line number Diff line number Diff line change
@@ -1,127 +1,128 @@
@model Resgrid.WebCore.Areas.User.Models.Mapping.StationRoutingView
@{
ViewBag.Title = "Resgrid | Live Navigation";
ViewBag.Title = "Resgrid | Live Navigation";
}

@section Styles
{
<style>
#dvMap {
height: 500px;
}
</style>
<style>
#dvMap {
height: 500px;
}
</style>
}

<div class="row wrapper border-bottom white-bg page-heading">
<div class="col-sm-4">
<h2>Live Routing</h2>
<ol class="breadcrumb">
<li>
<a asp-controller="Home" asp-action="Dashboard" asp-route-area="User">Home</a>
</li>
<li>
<a asp-controller="Mapping" asp-action="Index" asp-route-area="User">Mapping</a>
</li>
<li class="active">
<strong>Live Routing</strong>
</li>
</ol>
</div>
<div class="col-sm-4">
<h2>Live Routing</h2>
<ol class="breadcrumb">
<li>
<a asp-controller="Home" asp-action="Dashboard" asp-route-area="User">Home</a>
</li>
<li>
<a asp-controller="Mapping" asp-action="Index" asp-route-area="User">Mapping</a>
</li>
<li class="active">
<strong>Live Routing</strong>
</li>
</ol>
</div>
</div>

<div class="row">
<div class="col-xs-8">
<div class="wrapper wrapper-content">
<div class="ibox float-e-margins">
<div class="ibox-content">
<div id="dvDistance" style="font-size:x-large; text-align: center">
</div>
<div id="dvMap">
</div>
<div class="col-xs-8">
<div class="wrapper wrapper-content">
<div class="ibox float-e-margins">
<div class="ibox-content">
<div id="dvDistance" style="font-size:x-large; text-align: center">
</div>
<div id="dvMap">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-xs-4">
<div class="wrapper wrapper-content">
<div class="ibox float-e-margins">
<div class="ibox-content">
<div id="dvPanel">
</div>
<div class="col-xs-4">
<div class="wrapper wrapper-content">
<div class="ibox float-e-margins">
<div class="ibox-content">
<div id="dvPanel">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>


@section Scripts
{
<script type="text/javascript">
var unit;
var destination;
var directionsDisplay;
var directionsService;
<script src="https://maps.googleapis.com/maps/api/[email protected]"></script>
<script type="text/javascript">
var unit;
var destination;
var directionsDisplay;
var directionsService;
function route() {
var call = new google.maps.LatLng(@Model.EndLat, @Model.EndLon);
function route() {
var call = new google.maps.LatLng(@Model.EndLat, @Model.EndLon);
var mapOptions = {
zoom: 9,
center: unit
};
map = new google.maps.Map(document.getElementById('dvMap'), mapOptions);
directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById('dvPanel'));
var mapOptions = {
zoom: 9,
center: unit
};
map = new google.maps.Map(document.getElementById('dvMap'), mapOptions);
directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById('dvPanel'));
var request = {
origin: unit,
destination: call,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function (response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
var request = {
origin: unit,
destination: call,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function (response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix({
origins: [unit],
destinations: [call],
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC,
avoidHighways: false,
avoidTolls: false
}, function (response, status) {
if (status == google.maps.DistanceMatrixStatus.OK && response.rows[0].elements[0].status != "ZERO_RESULTS") {
var distance = response.rows[0].elements[0].distance.text;
var duration = response.rows[0].elements[0].duration.text;
var dvDistance = document.getElementById("dvDistance");
dvDistance.innerHTML = "";
dvDistance.innerHTML += "Distance Is: " + distance + "<br />";
dvDistance.innerHTML += "Duration Is: " + duration;
//alert(dvDistance.innerHTML);
} else {
alert("Your Request For Distance Not Available");
}
});
}
function foundLocation(position) {
unit = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
route();
}
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix({
origins: [unit],
destinations: [call],
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC,
avoidHighways: false,
avoidTolls: false
}, function (response, status) {
if (status == google.maps.DistanceMatrixStatus.OK && response.rows[0].elements[0].status != "ZERO_RESULTS") {
var distance = response.rows[0].elements[0].distance.text;
var duration = response.rows[0].elements[0].duration.text;
var dvDistance = document.getElementById("dvDistance");
dvDistance.innerHTML = "";
dvDistance.innerHTML += "Distance Is: " + distance + "<br />";
dvDistance.innerHTML += "Duration Is: " + duration;
//alert(dvDistance.innerHTML);
} else {
alert("Your Request For Distance Not Available");
}
});
}
function foundLocation(position) {
unit = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
route();
}
function noLocation() {
function noLocation() {
}
}
$(document).ready(function () {
directionsService = new google.maps.DirectionsService();
directionsDisplay = new google.maps.DirectionsRenderer({ 'draggable': true });
$(document).ready(function () {
directionsService = new google.maps.DirectionsService();
directionsDisplay = new google.maps.DirectionsRenderer({ 'draggable': true });
navigator.geolocation.getCurrentPosition(foundLocation, noLocation, { timeout: 5000 });
});
</script>
navigator.geolocation.getCurrentPosition(foundLocation, noLocation, { timeout: 5000 });
});
</script>
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
});
}
</script>
<script src="https://sentry.resgrid.net/js-sdk-loader/8a935a7e61f257ce1a3b9131600ecb29.min.js" crossorigin="anonymous"></script>
}
</head>
<body>
Expand Down

0 comments on commit 3a68bce

Please sign in to comment.