Add bing maps for the job order maps. #221
This commit is contained in:
parent
6c8ad89d6e
commit
0cffc525c5
1 changed files with 65 additions and 38 deletions
|
|
@ -3,7 +3,13 @@
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
var form_in_process = false;
|
var form_in_process = false;
|
||||||
|
var searchManager;
|
||||||
var pin;
|
var pin;
|
||||||
|
var map = new Microsoft.Maps.Map('#m_gmap', {
|
||||||
|
center: new Microsoft.Maps.Location(14.6091, 121.0223),
|
||||||
|
culture: 'fil-Latn';
|
||||||
|
};
|
||||||
|
Microsoft.Maps.Events.addHandler(map, 'click', selectPoint);
|
||||||
|
|
||||||
function selectPoint(e) {
|
function selectPoint(e) {
|
||||||
if (e.targetType == "map") {
|
if (e.targetType == "map") {
|
||||||
|
|
@ -39,35 +45,42 @@ $(function() {
|
||||||
$('#map_lng').val(lng);
|
$('#map_lng').val(lng);
|
||||||
}
|
}
|
||||||
|
|
||||||
var map = new Microsoft.Maps.Map('#m_gmap', {
|
function geocodeQuery(query) {
|
||||||
center: new Microsoft.Maps.Location(14.6091, 121.0223),
|
var searchRequest = {
|
||||||
}
|
where: query,
|
||||||
Microsoft.Maps.Events.addHandler(map, 'click', selectPoint);
|
callback: function (r) {
|
||||||
|
// clear map
|
||||||
|
map.entities.remove(pin);
|
||||||
{
|
// Add the first result
|
||||||
div: '#m_gmap',
|
if (r && r.results && r.results.length > 0) {
|
||||||
lat: 14.6091,
|
pin = new Microsoft.Maps.Pushpin(r.results[0].location, {
|
||||||
lng: 121.0223,
|
draggable: false,
|
||||||
click: function(e) {
|
icon: '/assets/images/icon-destination.png'
|
||||||
// handle click in map
|
|
||||||
selectPoint(map, e.latLng);
|
|
||||||
e.stop();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
var handleAction = function() {
|
map.entities.push(pin);
|
||||||
var text = $.trim($('#m_gmap_address').val());
|
map.setCenter(location);
|
||||||
GMaps.geocode({
|
|
||||||
address: text,
|
// set value in hidden input
|
||||||
callback: function(results, status) {
|
$('#map_lat').val(locTemp.latitude);
|
||||||
map.removeMarkers();
|
$('#map_lng').val(locTemp.longitude);
|
||||||
if (status == 'OK') {
|
|
||||||
selectPoint(map, results[0].geometry.location);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
region: 'ph'
|
errorCallback: function (e) {
|
||||||
|
alert("No results found");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var handleAction = function() {
|
||||||
|
var text = $.trim($('#m_gmap_address').val());
|
||||||
|
if (!searchManager) {
|
||||||
|
// create an instance of the search manager
|
||||||
|
Microsoft.Maps.loadModule('Microsoft.Maps.Search', function() {
|
||||||
|
searchManager = new Microsoft.Maps.Search.SearchManager(map);
|
||||||
|
geocodeQuery(encodeURIComponent(text));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$('#m_gmap_btn').click(function(e) {
|
$('#m_gmap_btn').click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
@ -84,8 +97,21 @@ $(function() {
|
||||||
|
|
||||||
{% if ftags.set_map_coordinate %}
|
{% if ftags.set_map_coordinate %}
|
||||||
// check if we need to set map
|
// check if we need to set map
|
||||||
var latlng = new google.maps.LatLng({{ obj.getCoordinates.getLatitude }}, {{ obj.getCoordinates.getLongitude }});
|
var location = new Microsoft.Maps.Location({{ obj.getCoordinates.getLatitude }}, {{ obj.getCoordinates.getLongitude }});
|
||||||
selectPoint(map, latlng);
|
|
||||||
|
map.entities.remove(pin);
|
||||||
|
|
||||||
|
pin = new Microsoft.Maps.Pushpin(location, {
|
||||||
|
draggable: false,
|
||||||
|
icon: '/assets/images/icon-destination.png'
|
||||||
|
});
|
||||||
|
|
||||||
|
map.entities.push(pin);
|
||||||
|
map.setCenter(location);
|
||||||
|
|
||||||
|
// set value in hidden input
|
||||||
|
$('#map_lat').val(locTemp.latitude);
|
||||||
|
$('#map_lng').val(locTemp.longitude);
|
||||||
|
|
||||||
// remove placeholder text
|
// remove placeholder text
|
||||||
$("[data-vehicle-field='1']").prop('placeholder', '');
|
$("[data-vehicle-field='1']").prop('placeholder', '');
|
||||||
|
|
@ -93,19 +119,20 @@ $(function() {
|
||||||
|
|
||||||
{% if mode in ['update-processing', 'update-reassign-hub'] %}
|
{% if mode in ['update-processing', 'update-reassign-hub'] %}
|
||||||
// display hub map
|
// display hub map
|
||||||
var hmap = new GMaps({
|
var hmap = new Microsoft.Maps.Map('#hub_map', {
|
||||||
div: '#hub_map',
|
center: new Microsoft.Maps.Location({{ obj.getCoordinates.getLatitude }},
|
||||||
lat: {{ obj.getCoordinates.getLatitude }},
|
{{ obj.getCoordinates.getLongitude }}),
|
||||||
lng: {{ obj.getCoordinates.getLongitude }}
|
culture: 'fil-Latn';
|
||||||
});
|
};
|
||||||
|
|
||||||
hmap.addMarker({
|
var dest = new Microsoft.Maps.Location({{ obj.getCoordinates.getLatitude }},
|
||||||
lat: {{ obj.getCoordinates.getLatitude }},
|
{{ obj.getCoordinates.getLongitude }});
|
||||||
lng: {{ obj.getCoordinates.getLongitude }},
|
hmap.entities.push(new Microsoft.Maps.Pushpin(dest, {
|
||||||
icon: '/assets/images/icon-destination.png',
|
|
||||||
title: "Destination",
|
title: "Destination",
|
||||||
content: "Destination"
|
text: "Destination",
|
||||||
});
|
icon: '/assets/images/icon-destination.png'
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
{% for hub in hubs %}
|
{% for hub in hubs %}
|
||||||
hmap.addMarker({
|
hmap.addMarker({
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue