|
|
|
@ -8,176 +8,79 @@
|
|
|
|
|
function loadServiceAreaMap() {
|
|
|
|
|
if (MapControl.supported()) {
|
|
|
|
|
if (serviceAreaMap == null) {
|
|
|
|
|
app.preloader.show();
|
|
|
|
|
var mapboxel = document.getElementById("mapbox-servicearea");
|
|
|
|
|
serviceAreaMap = new MapControl(mapboxel, true);
|
|
|
|
|
serviceAreaMap.reloadMap();
|
|
|
|
|
var serviceAreaMapLoaded = false;
|
|
|
|
|
|
|
|
|
|
serviceAreaMap.mapObj.on('load', function () {
|
|
|
|
|
serviceAreaMap.mapObj.jumpTo({center: [-112.005, 46.589], zoom: 9});
|
|
|
|
|
serviceAreaMap.mapObj.addSource('servicearea', {
|
|
|
|
|
'type': 'geojson',
|
|
|
|
|
'data': {
|
|
|
|
|
"type": "FeatureCollection",
|
|
|
|
|
"features": [
|
|
|
|
|
{
|
|
|
|
|
"type": "Feature",
|
|
|
|
|
"properties": {
|
|
|
|
|
"label": "Notary"
|
|
|
|
|
},
|
|
|
|
|
"geometry": {
|
|
|
|
|
"type": "Polygon",
|
|
|
|
|
"coordinates": [
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
-111.94158554077148,
|
|
|
|
|
46.75621029973824
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-112.09058761596678,
|
|
|
|
|
46.73880181507399
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-112.11393356323242,
|
|
|
|
|
46.594849313729064
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-112.13109970092773,
|
|
|
|
|
46.53135096527468
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-112.05350875854492,
|
|
|
|
|
46.51410624997797
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-111.92647933959961,
|
|
|
|
|
46.50819926727706
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-111.83721542358398,
|
|
|
|
|
46.537491596723235
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-111.79738998413086,
|
|
|
|
|
46.63800459887636
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-111.86948776245116,
|
|
|
|
|
46.738095947110935
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-111.94158554077148,
|
|
|
|
|
46.75621029973824
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"type": "Feature",
|
|
|
|
|
"properties": {
|
|
|
|
|
"label": "Courier"
|
|
|
|
|
},
|
|
|
|
|
"geometry": {
|
|
|
|
|
"type": "Polygon",
|
|
|
|
|
"coordinates": [
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
-111.40274047851562,
|
|
|
|
|
46.2957133089894
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-111.42059326171874,
|
|
|
|
|
46.49082901981415
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-111.62109375,
|
|
|
|
|
46.64755071082884
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-111.80923461914062,
|
|
|
|
|
46.800999519926314
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-111.92184448242188,
|
|
|
|
|
46.991494313050424
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-111.90261840820312,
|
|
|
|
|
47.09537035351024
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-112.02346801757812,
|
|
|
|
|
47.15236927446393
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-112.24456787109375,
|
|
|
|
|
47.09163058564968
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-112.38704681396484,
|
|
|
|
|
46.93901161506044
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-112.39013671875,
|
|
|
|
|
46.72856582519053
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-112.36953735351562,
|
|
|
|
|
46.53052428878426
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-112.16285705566406,
|
|
|
|
|
46.430285240839964
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-112.02896118164061,
|
|
|
|
|
46.35522171093644
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-111.6815185546875,
|
|
|
|
|
46.31089291474789
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-111.47415161132812,
|
|
|
|
|
46.29761098988109
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
-111.40274047851562,
|
|
|
|
|
46.2957133089894
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
serviceAreaMapLoaded = true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
apirequest(SETTINGS.apis.servicearea, {}, function (resp) {
|
|
|
|
|
var loadWhenMapReady = function () {
|
|
|
|
|
if (serviceAreaMapLoaded) {
|
|
|
|
|
setupServiceAreaMap(resp);
|
|
|
|
|
} else {
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
loadWhenMapReady();
|
|
|
|
|
}, 100);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
serviceAreaMap.mapObj.addLayer({
|
|
|
|
|
'id': 'courierservicearea',
|
|
|
|
|
'type': 'fill',
|
|
|
|
|
'source': 'servicearea',
|
|
|
|
|
'paint': {
|
|
|
|
|
'fill-color': '#005387',
|
|
|
|
|
'fill-opacity': 0.4
|
|
|
|
|
},
|
|
|
|
|
'filter': ['==', 'label', 'Courier']
|
|
|
|
|
});
|
|
|
|
|
serviceAreaMap.mapObj.addLayer({
|
|
|
|
|
'id': 'notaryservicearea',
|
|
|
|
|
'type': 'fill',
|
|
|
|
|
'source': 'servicearea',
|
|
|
|
|
'paint': {
|
|
|
|
|
'fill-color': '#008733',
|
|
|
|
|
'fill-opacity': 0.4
|
|
|
|
|
},
|
|
|
|
|
'filter': ['==', 'label', 'Notary']
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
loadWhenMapReady();
|
|
|
|
|
}, function (xhr) {
|
|
|
|
|
app.preloader.hide();
|
|
|
|
|
try {
|
|
|
|
|
var error = $.parseJSON(xhr.responseText);
|
|
|
|
|
if (error && typeof error.msg != 'undefined') {
|
|
|
|
|
app.dialog.alert(error.msg, "Error");
|
|
|
|
|
sendErrorReport("Service Area", "Couldn't get service area GeoJSON", error.msg);
|
|
|
|
|
} else {
|
|
|
|
|
app.dialog.alert("There's a server or network problem. Check your Internet connection or try again later.", "Error");
|
|
|
|
|
sendErrorReport("Service Area", "Couldn't get service area GeoJSON", "Server/network problem: " + xhr.status + ": " + xhr.statusText);
|
|
|
|
|
}
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
app.dialog.alert("There's a server or network problem. Check your Internet connection or try again later.", "Error");
|
|
|
|
|
sendErrorReport("Service Area", "Couldn't get service area GeoJSON", "Server/network problem: " + xhr.status + ": " + xhr.statusText);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
showWebGLErrorMessage();
|
|
|
|
|
app.preloader.hide();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setupServiceAreaMap(geojson) {
|
|
|
|
|
app.preloader.hide();
|
|
|
|
|
serviceAreaMap.mapObj.jumpTo({center: [-112.005, 46.589], zoom: 9});
|
|
|
|
|
serviceAreaMap.mapObj.addSource('servicearea', {
|
|
|
|
|
'type': 'geojson',
|
|
|
|
|
'data': geojson
|
|
|
|
|
});
|
|
|
|
|
serviceAreaMap.mapObj.addLayer({
|
|
|
|
|
'id': 'courierservicearea',
|
|
|
|
|
'type': 'fill',
|
|
|
|
|
'source': 'servicearea',
|
|
|
|
|
'paint': {
|
|
|
|
|
'fill-color': '#005387',
|
|
|
|
|
'fill-opacity': 0.4
|
|
|
|
|
},
|
|
|
|
|
'filter': ['==', 'label', 'Courier']
|
|
|
|
|
});
|
|
|
|
|
serviceAreaMap.mapObj.addLayer({
|
|
|
|
|
'id': 'notaryservicearea',
|
|
|
|
|
'type': 'fill',
|
|
|
|
|
'source': 'servicearea',
|
|
|
|
|
'paint': {
|
|
|
|
|
'fill-color': '#008733',
|
|
|
|
|
'fill-opacity': 0.4
|
|
|
|
|
},
|
|
|
|
|
'filter': ['==', 'label', 'Notary']
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function openServiceAreaExtraChargeInfo() {
|
|
|
|
|
app.dialog.alert("If you need a notary outside the green zone, the travel fee will be calculated \n\
|
|
|
|
|
using the current IRS mileage rate. If you need courier service outside the blue zone, we can accomodate \n\
|
|
|
|
|