display google map popup info on changing delivery adress
This commit is contained in:
parent
168b837f21
commit
3a2f9a2fe6
@ -65,55 +65,68 @@ function selectPoint(ref, operator, address)
|
||||
alert(carrier_translation.no_pickup_point_found_try_other_addr);
|
||||
} else {
|
||||
|
||||
res = '<p><b>' + carrier_translation.select_pickup_point1 + '<a href="#" id="openMap" class="click-here" onclick="javascript:makeMap(\'MONR\', \'' + ref + '\', \'' + address + '\');return false;">' + carrier_translation.select_pickup_point2 + '</a></b></p>' +
|
||||
res = '<p><b>' + carrier_translation.select_pickup_point1 + carrier_translation.select_pickup_point2+' :</b></p>' +
|
||||
'<ul class="col-xs-12 col-sm-6">' + res + '</ul>'+
|
||||
'<div id="mapContainer_custom" class="col-xs-12 col-sm-6"><div id="map_canvas_custom"></div></div>';
|
||||
$('#points' + ref + address).show();
|
||||
$('#points' + ref + address).html(res);
|
||||
$('#loaderPoints' + ref + address).remove();
|
||||
if (typeof $(parcelPointId) != "undefined" && typeof $(parcelPointId) != "") {
|
||||
$(parcelPointId).attr("checked", true);
|
||||
$(parcelPointId).attr("checked", "checked");
|
||||
}
|
||||
|
||||
makeMap('MONR', ref, address);
|
||||
|
||||
if (typeof $(parcelPointId) != "undefined" && typeof $(parcelPointId) != "") {
|
||||
$(parcelPointId).attr("checked", "checked");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
var geocoder = new google.maps.Geocoder();
|
||||
var infowindow = new google.maps.InfoWindow();
|
||||
|
||||
infowindow.openCustomMarker = function(map, marker)
|
||||
{
|
||||
if (map !== undefined && marker !== undefined) {
|
||||
infowindow.setContent(marker.get('bulkContent'));
|
||||
infowindow.open(map, marker);
|
||||
}
|
||||
};
|
||||
|
||||
infowindow.openMarkerFromPosition = function(map, markers, position)
|
||||
{
|
||||
infowindow.openCustomMarker(map, markers.find(function(marker) {
|
||||
mpos = marker.getPosition();
|
||||
return (mpos.lat()==position.lat() && mpos.lng()==position.lng());
|
||||
}));
|
||||
};
|
||||
|
||||
var markers = [];
|
||||
|
||||
/**
|
||||
* Constructs Google Map.
|
||||
* Handles map making. If the map has already been opened, show only the <div />. Otherwise
|
||||
* generate the Google Maps.
|
||||
*/
|
||||
function makeMap(ope, carrierdId, address)
|
||||
{
|
||||
// initialize(ope, carrierdId, address);
|
||||
customInitialize(ope, carrierdId, address);
|
||||
}
|
||||
/**
|
||||
* Constructs Google Map.
|
||||
*/
|
||||
|
||||
function customInitialize(ope, carrierdId, addressId)
|
||||
function makeMap(ope, carrierdId, addressId)
|
||||
{
|
||||
$('#counter' + carrierdId + ope).val(0);
|
||||
document.getElementById('mapContainer_custom').style.display = 'inline-block';
|
||||
|
||||
geocoder = new google.maps.Geocoder();
|
||||
var myOptions = {
|
||||
zoom: 11,
|
||||
mapTypeId: google.maps.MapTypeId.ROADMAP
|
||||
};
|
||||
var addressId = addressId;
|
||||
var carrierdId = carrierdId;
|
||||
infowindow = new google.maps.InfoWindow();
|
||||
map = new google.maps.Map(document.getElementById("map_canvas_custom"), myOptions);
|
||||
|
||||
points = $('#parcelPoints' + carrierdId + ope + addressId).val().split('|');
|
||||
infos = $('#parcelInfos' + carrierdId + ope + addressId).val().split('|');
|
||||
parcelNames = $('#parcelNames' + carrierdId + ope + addressId).val().split('|');
|
||||
parcelIds = $('#parcelIds' + carrierdId + ope + addressId).val().split('|');
|
||||
|
||||
for (var i = 0; i < points.length; i++) {
|
||||
(function (i) {
|
||||
var address = points[i];
|
||||
@ -128,69 +141,29 @@ function customInitialize(ope, carrierdId, addressId)
|
||||
})(i);
|
||||
}
|
||||
document.getElementById('mapContainer_custom').style.display = 'inline-block';
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs Google Map.
|
||||
*/
|
||||
/*
|
||||
function initialize(ope, carrierdId, addressId)
|
||||
{
|
||||
$('#counter' + carrierdId + ope).val(0);
|
||||
document.getElementById('mapContainer').style.display = 'block';
|
||||
// set offset on the middle of the page (or top of the page for small screens)
|
||||
var offset = $(window).scrollTop() + ($(window).height() - $('#mapContainer').height())/2;
|
||||
if (offset < $(window).scrollTop()) {
|
||||
offset = $(window).scrollTop();
|
||||
}
|
||||
$('#mapContainer').css('top', offset + 'px');
|
||||
geocoder = new google.maps.Geocoder();
|
||||
var myOptions = {
|
||||
zoom: 11,
|
||||
mapTypeId: google.maps.MapTypeId.ROADMAP
|
||||
};
|
||||
var addressId = addressId;
|
||||
var carrierdId = carrierdId;
|
||||
infowindow = new google.maps.InfoWindow();
|
||||
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
|
||||
points = $('#parcelPoints' + carrierdId + ope + addressId).val().split('|');
|
||||
infos = $('#parcelInfos' + carrierdId + ope + addressId).val().split('|');
|
||||
parcelNames = $('#parcelNames' + carrierdId + ope + addressId).val().split('|');
|
||||
parcelIds = $('#parcelIds' + carrierdId + ope + addressId).val().split('|');
|
||||
for (var i = 0; i < points.length; i++) {
|
||||
(function (i) {
|
||||
var address = points[i];
|
||||
infoParcel[i] = '<b>' + parcelNames[i] + '</b>' + '<br /><a href="#" onclick="javascript: selectPr(\'' + parcelIds[i] + '\', \'' + carrierdId + '\', \'' + addressId + '\'); return false;">' + carrier_translation.select_this_pickup_point + '</a> <br />' + address + '<br />' + infos[i];
|
||||
if (geocoder) {
|
||||
geocoder.geocode({'address': address}, function (results, status) {
|
||||
if (status == google.maps.GeocoderStatus.OK) {
|
||||
makeMarker(i, results[0].geometry.location);
|
||||
}
|
||||
});
|
||||
}
|
||||
})(i);
|
||||
}
|
||||
document.getElementById('mapContainer').style.display = 'block';
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Makes Google Maps markers.
|
||||
*/
|
||||
function makeMarker(s, location)
|
||||
{
|
||||
map.setCenter(location);
|
||||
var marker = new google.maps.Marker({
|
||||
map: map,
|
||||
position: location,
|
||||
title: "" + parcelNames[s]
|
||||
});
|
||||
marker.set("bulkContent", infoParcel[s]);
|
||||
|
||||
google.maps.event.addListener(marker, "click", function () {
|
||||
infowindow.setContent(this.get("bulkContent"));
|
||||
infowindow.open(map, marker);
|
||||
infowindow.openCustomMarker(map, marker);
|
||||
});
|
||||
markers.push(marker);
|
||||
|
||||
map.setCenter(location);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -214,24 +187,50 @@ function hideMap()
|
||||
*/
|
||||
function selectPr(pr, carrierId, addressId)
|
||||
{
|
||||
ope = 'MONR';
|
||||
infowindow.close();
|
||||
|
||||
makeOpeChecked(carrierId, 0, 0, addressId);
|
||||
$.ajax({
|
||||
url: 'index.php?fc=module&module=envoimoinscher&controller=ajax&option=set_point',
|
||||
type: 'POST',
|
||||
data: {'point': pr}
|
||||
});
|
||||
$('#point' + carrierId + pr + addressId).attr('checked', 'checked');
|
||||
$('#point' + carrierId + pr + addressId).attr('checked', true);
|
||||
parcelPointId = '#point' + carrierId + pr + addressId;
|
||||
getCarrierInput($('#point' + carrierId + pr + addressId)).attr('checked', 'checked');
|
||||
getCarrierInput($('#point' + carrierId + pr + addressId)).attr('checked', true);
|
||||
// hideMap();
|
||||
|
||||
parcelPointId = '#point' + carrierId + pr + addressId;
|
||||
$(parcelPointId).attr('checked', 'checked');
|
||||
|
||||
var parcelsId = $('#parcelIds' + carrierId + ope + addressId);
|
||||
var addresses = $('#parcelPoints' + carrierId + ope + addressId);
|
||||
|
||||
|
||||
if (geocoder && parcelsId.length && addresses.length ) {
|
||||
var parcelIds = parcelsId.val().split('|');
|
||||
|
||||
var index = parcelIds.findIndex(function(id) { return id==pr;});
|
||||
if (index>=0) {
|
||||
addresses = addresses.val().split('|');
|
||||
var address = addresses[index];
|
||||
|
||||
geocoder.geocode({'address': address}, function (results, status) {
|
||||
if (status == google.maps.GeocoderStatus.OK) {
|
||||
var pos = results[0].geometry.location;
|
||||
|
||||
map.setCenter(pos);
|
||||
|
||||
infowindow.openMarkerFromPosition(map, markers, pos);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets carrier radio input
|
||||
*/
|
||||
|
||||
function getCarrierInput(ref)
|
||||
{
|
||||
return ref.parent().parent().parent().parent().find('input[name="delivery_option[' + idAddress + ']"]');
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user