diff --git a/templates/job-order/cmb.form.html.twig b/templates/job-order/cmb.form.html.twig
index 3bbcf718..2c10a73a 100644
--- a/templates/job-order/cmb.form.html.twig
+++ b/templates/job-order/cmb.form.html.twig
@@ -936,9 +936,9 @@ $(function() {
var default_lat = {% trans %}default_lat{% endtrans %};
var default_lng = {% trans %}default_long{% endtrans %};
- var map = mapCreate('m_gmap', default_lat, default_lng, 'road', 13);
+ var osm_map = mapCreate('m_gmap', default_lat, default_lng, 'road', 13);
- var markerLayerGroup = L.layerGroup().addTo(map);
+ var markerLayerGroup = L.layerGroup().addTo(osm_map);
function selectPoint(lat, lng)
{
@@ -950,45 +950,17 @@ $(function() {
// add marker to layer group
markerLayerGroup.addLayer(marker);
- map.setView(new L.LatLng(lat, lng), 13);
+ osm_map.setView(new L.LatLng(lat, lng), 13);
+
+ // set value in hidden input
+ $('#map_lat').val(lat);
+ $('#map_lng').val(lng);
}
- map.on('click', function(e) {
+ osm_map.on('click', function(e) {
selectPoint(e.latlng.lat, e.latlng.lng);
});
- // BEGIN google maps stuff
- /*
- function selectPoint(map, latlng) {
- var lat = latlng.lat();
- var lng = latlng.lng();
-
- // show it in map
- map.removeMarkers();
- map.setCenter(lat, lng);
- map.addMarker({
- lat: lat,
- lng: lng,
- icon: '/assets/images/icon-destination.png'
- });
-
- // set value in hidden input
- $('#map_lat').val(lat);
- $('#map_lng').val(lng);
- }
-
- var map = new GMaps({
- div: '#m_gmap',
- lat: {% trans %}default_lat{% endtrans %},
- lng: {% trans %}default_long{% endtrans %},
- click: function(e) {
- // handle click in map
- selectPoint(map, e.latLng);
- e.stop();
- }
- });
- */
-
var handleAction = function() {
var text = $.trim($('#m_gmap_address').val());
GMaps.geocode({
@@ -996,8 +968,6 @@ $(function() {
callback: function(results, status) {
markerLayerGroup.clearLayers();
if (status == 'OK') {
- // google code
- // selectPoint(map, results[0].geometry.location);
// OSM code
console.log(results);
var lat = results[0].geometry.location.lat();
@@ -1026,9 +996,6 @@ $(function() {
{% if ftags.set_map_coordinate %}
// check if we need to set map
- // google code
- //var latlng = new google.maps.LatLng({{ obj.getCoordinates.getLatitude }}, {{ obj.getCoordinates.getLongitude }});
- //selectPoint(map, latlng);
// OSM code
var lat = {{ obj.getCoordinates.getLatitude }};
var lng = {{ obj.getCoordinates.getLongitude }};
@@ -1045,10 +1012,10 @@ $(function() {
var hub_lat = {{ obj.getCoordinates.getLatitude }};
var hub_lng = {{ obj.getCoordinates.getLongitude }};
- var hmap = mapCreate('hub_map', hub_lat, hub_lng, 'road', 13);
+ var osm_hmap = mapCreate('hub_map', hub_lat, hub_lng, 'road', 13);
- var destLayerGroup = L.layerGroup().addTo(hmap);
- var hubLayerGroup = L.layerGroup().addTo(hmap);
+ var destLayerGroup = L.layerGroup().addTo(osm_hmap);
+ var hubLayerGroup = L.layerGroup().addTo(osm_hmap);
var dest_icon = L.icon({
iconUrl: '/assets/images/icon-destination.png',
@@ -1071,38 +1038,8 @@ $(function() {
hubLayerGroup.addLayer(hub_marker);
{% endfor %}
- // google code
- /*
- var hmap = new GMaps({
- div: '#hub_map',
- lat: {{ obj.getCoordinates.getLatitude }},
- lng: {{ obj.getCoordinates.getLongitude }}
- });
-
- hmap.addMarker({
- lat: {{ obj.getCoordinates.getLatitude }},
- lng: {{ obj.getCoordinates.getLongitude }},
- icon: '/assets/images/icon-destination.png',
- title: "Destination",
- content: "Destination"
- });
-
- {% for hub in hubs %}
- hmap.addMarker({
- lat: {{ hub.hub.getCoordinates.getLatitude }},
- lng: {{ hub.hub.getCoordinates.getLongitude }},
- title: "{{ hub.hub.getName }}",
- content: "{{ hub.hub.getName }}",
- icon: '/assets/images/icon-outlet.png'
- });
- {% endfor %}
- */
-
{% endif %}
-
- // END google maps stuff
-
$("#row-form").submit(function(e) {
if (form_in_process) {
alert("Cannot submit form twice. First submission still in progress.");
diff --git a/templates/job-order/form.html.twig b/templates/job-order/form.html.twig
index b637953c..5bfc8366 100644
--- a/templates/job-order/form.html.twig
+++ b/templates/job-order/form.html.twig
@@ -894,7 +894,6 @@
{% block scripts %}
{{ include('map/' ~ map_js_file) }}
-
@@ -930,9 +929,9 @@ $(function() {
var default_lat = {% trans %}default_lat{% endtrans %};
var default_lng = {% trans %}default_long{% endtrans %};
- var map = mapCreate('m_gmap', default_lat, default_lng, 'road', 13);
+ var osm_map = mapCreate('m_gmap', default_lat, default_lng, 'road', 13);
- var markerLayerGroup = L.layerGroup().addTo(map);
+ var markerLayerGroup = L.layerGroup().addTo(osm_map);
function selectPoint(lat, lng)
{
@@ -944,56 +943,25 @@ $(function() {
// add marker to layer group
markerLayerGroup.addLayer(marker);
- map.setView(new L.LatLng(lat, lng), 13);
+ osm_map.setView(new L.LatLng(lat, lng), 13);
+
+ // set value in hidden input
+ $('#map_lat').val(lat);
+ $('#map_lng').val(lng);
+
}
- map.on('click', function(e) {
+ osm_map.on('click', function(e) {
selectPoint(e.latlng.lat, e.latlng.lng);
});
-
- // BEGIN google maps stuff
- /*
- function selectPoint(map, latlng) {
- var lat = latlng.lat();
- var lng = latlng.lng();
-
- // show it in map
- map.removeMarkers();
- map.setCenter(lat, lng);
- map.addMarker({
- lat: lat,
- lng: lng,
- icon: '/assets/images/icon-destination.png'
- });
-
- // set value in hidden input
- $('#map_lat').val(lat);
- $('#map_lng').val(lng);
- }
-
- var map = new GMaps({
- div: '#m_gmap',
- lat: 14.6091,
- lng: 121.0223,
- click: function(e) {
- // handle click in map
- selectPoint(map, e.latLng);
- e.stop();
- }
- });
- */
-
- var handleAction = function() {
- var text = $.trim($('#m_gmap_address').val());
- GMaps.geocode({
- address: text,
- callback: function(results, status) {
- map.removeMarkers();
+ var handleAction = function() {
+ var text = $.trim($('#m_gmap_address').val());
+ GMaps.geocode({
+ address: text,
+ callback: function(results, status) {
+ markerLayerGroup.clearLayers();
if (status == 'OK') {
- // google code
- // selectPoint(map, results[0].geometry.location);
- // OSM code
console.log(results);
var lat = results[0].geometry.location.lat();
var lng = results[0].geometry.location.lng();
@@ -1021,9 +989,6 @@ $(function() {
{% if ftags.set_map_coordinate %}
// check if we need to set map
- // google code
- //var latlng = new google.maps.LatLng({{ obj.getCoordinates.getLatitude }}, {{ obj.getCoordinates.getLongitude }});
- //selectPoint(map, latlng);
// OSM code
var lat = {{ obj.getCoordinates.getLatitude }};
var lng = {{ obj.getCoordinates.getLongitude }};
@@ -1040,10 +1005,10 @@ $(function() {
var hub_lat = {{ obj.getCoordinates.getLatitude }};
var hub_lng = {{ obj.getCoordinates.getLongitude }};
- var hmap = mapCreate('hub_map', hub_lat, hub_lng, 'road', 13);
+ var osm_hmap = mapCreate('hub_map', hub_lat, hub_lng, 'road', 13);
- var destLayerGroup = L.layerGroup().addTo(hmap);
- var hubLayerGroup = L.layerGroup().addTo(hmap);
+ var destLayerGroup = L.layerGroup().addTo(osm_hmap);
+ var hubLayerGroup = L.layerGroup().addTo(osm_hmap);
var dest_icon = L.icon({
iconUrl: '/assets/images/icon-destination.png',
@@ -1065,39 +1030,8 @@ $(function() {
hubLayerGroup.addLayer(hub_marker);
{% endfor %}
-
- // google code
- /*
- var hmap = new GMaps({
- div: '#hub_map',
- lat: {{ obj.getCoordinates.getLatitude }},
- lng: {{ obj.getCoordinates.getLongitude }}
- });
-
- hmap.addMarker({
- lat: {{ obj.getCoordinates.getLatitude }},
- lng: {{ obj.getCoordinates.getLongitude }},
- icon: '/assets/images/icon-destination.png',
- title: "Destination",
- content: "Destination"
- });
-
- {% for hub in hubs %}
- hmap.addMarker({
- lat: {{ hub.hub.getCoordinates.getLatitude }},
- lng: {{ hub.hub.getCoordinates.getLongitude }},
- title: "{{ hub.hub.getName }}",
- content: "{{ hub.hub.getName }}",
- icon: '/assets/images/icon-outlet.png'
- });
- {% endfor %}
- */
-
{% endif %}
-
- // END google maps stuff
-
$("#row-form").submit(function(e) {
if (form_in_process) {
alert("Cannot submit form twice. First submission still in progress.");