diff --git a/src/Service/MapTools.php b/src/Service/MapTools.php index 7dd502fb..435a60dd 100644 --- a/src/Service/MapTools.php +++ b/src/Service/MapTools.php @@ -35,7 +35,7 @@ class MapTools foreach ($outlets as $outlet) { $coord = $outlet->getCoordinates(); - $dests[] = $coord->getLatitude() . ',' . $point->getLongitude(); + $dests[] = round($coord->getLatitude(),5) . ',' . round($point->getLongitude(), 5); } $dests_value = implode('|', $dests); @@ -48,6 +48,8 @@ class MapTools 'destinations' => $dests_value, ]; + error_log(print_r($gmaps_params, true)); + // query google maps api $res = $client->request('GET', $maps_url, ['query' => $gmaps_params]); @@ -69,7 +71,7 @@ class MapTools $final_data = []; foreach ($result as $row) { - // error_log($row[0]->getName() . ' - ' . $row['dist']); + error_log($row[0]->getName() . ' - ' . $row['dist']); $outlets[] = $row[0]; $final_data[] = [ 'outlet' => $row[0], @@ -82,7 +84,7 @@ class MapTools // get actual distance details with eta from google maps api $raw_res = $this->mapGetDistances($point, $outlets); $res = json_decode($raw_res, true); - // error_log(print_r($res, true)); + error_log(print_r($res, true)); // check if status is ok if ($res['status'] != 'OK') diff --git a/templates/job-order/form.html.twig b/templates/job-order/form.html.twig index 99377ea4..ba19146c 100644 --- a/templates/job-order/form.html.twig +++ b/templates/job-order/form.html.twig @@ -366,6 +366,7 @@ +
{% endif %} @@ -447,10 +448,32 @@ $(function() { } }); - // check if we need to set map {% if mode == 'update' %} + // check if we need to set map var latlng = new google.maps.LatLng({{ obj.getCoordinates.getLatitude }}, {{ obj.getCoordinates.getLongitude }}); selectPoint(map, latlng); + + // display outlet map + var omap = new GMaps({ + div: '#outlet_map', + lat: {{ obj.getCoordinates.getLatitude }}, + lng: {{ obj.getCoordinates.getLongitude }} + }); + + omap.addMarker({ + lat: {{ obj.getCoordinates.getLatitude }}, + lng: {{ obj.getCoordinates.getLongitude }} + }); + + {% for outlet in outlets %} + omap.addMarker({ + lat: {{ outlet.outlet.getCoordinates.getLatitude }}, + lng: {{ outlet.outlet.getCoordinates.getLongitude }}, + title: "{{ outlet.outlet.getName }}", + content: "{{ outlet.outlet.getName }}" + }); + {% endfor %} + {% endif %}