Get service area GeoJSON from server, show preloader spinner
This commit is contained in:
parent
35436dec09
commit
10c0e406cb
@ -8,148 +8,56 @@
|
|||||||
function loadServiceAreaMap() {
|
function loadServiceAreaMap() {
|
||||||
if (MapControl.supported()) {
|
if (MapControl.supported()) {
|
||||||
if (serviceAreaMap == null) {
|
if (serviceAreaMap == null) {
|
||||||
|
app.preloader.show();
|
||||||
var mapboxel = document.getElementById("mapbox-servicearea");
|
var mapboxel = document.getElementById("mapbox-servicearea");
|
||||||
serviceAreaMap = new MapControl(mapboxel, true);
|
serviceAreaMap = new MapControl(mapboxel, true);
|
||||||
serviceAreaMap.reloadMap();
|
serviceAreaMap.reloadMap();
|
||||||
|
var serviceAreaMapLoaded = false;
|
||||||
|
|
||||||
serviceAreaMap.mapObj.on('load', function () {
|
serviceAreaMap.mapObj.on('load', function () {
|
||||||
|
serviceAreaMapLoaded = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
apirequest(SETTINGS.apis.servicearea, {}, function (resp) {
|
||||||
|
var loadWhenMapReady = function () {
|
||||||
|
if (serviceAreaMapLoaded) {
|
||||||
|
setupServiceAreaMap(resp);
|
||||||
|
} else {
|
||||||
|
setTimeout(function () {
|
||||||
|
loadWhenMapReady();
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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.jumpTo({center: [-112.005, 46.589], zoom: 9});
|
||||||
serviceAreaMap.mapObj.addSource('servicearea', {
|
serviceAreaMap.mapObj.addSource('servicearea', {
|
||||||
'type': 'geojson',
|
'type': 'geojson',
|
||||||
'data': {
|
'data': geojson
|
||||||
"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
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
serviceAreaMap.mapObj.addLayer({
|
serviceAreaMap.mapObj.addLayer({
|
||||||
'id': 'courierservicearea',
|
'id': 'courierservicearea',
|
||||||
@ -171,11 +79,6 @@ function loadServiceAreaMap() {
|
|||||||
},
|
},
|
||||||
'filter': ['==', 'label', 'Notary']
|
'filter': ['==', 'label', 'Notary']
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
showWebGLErrorMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function openServiceAreaExtraChargeInfo() {
|
function openServiceAreaExtraChargeInfo() {
|
||||||
|
@ -42,7 +42,9 @@ var SETTINGS = {
|
|||||||
walletbalance: "http://localhost/helena.express/apis/crypto/walletbalance",
|
walletbalance: "http://localhost/helena.express/apis/crypto/walletbalance",
|
||||||
getutxo: "http://localhost/helena.express/apis/crypto/getutxo",
|
getutxo: "http://localhost/helena.express/apis/crypto/getutxo",
|
||||||
broadcasttransaction: "http://localhost/helena.express/apis/crypto/broadcasttransaction",
|
broadcasttransaction: "http://localhost/helena.express/apis/crypto/broadcasttransaction",
|
||||||
cryptofees: "http://localhost/helena.express/apis/crypto/fees"
|
cryptofees: "http://localhost/helena.express/apis/crypto/fees",
|
||||||
|
// Service area map
|
||||||
|
servicearea: "http://localhost/helena.express/apis/servicearea"
|
||||||
},
|
},
|
||||||
stripe_pubkey: "pk_test_51J6qFXCa1Fboir5UzPO3LCiMsVNiFP2lq4wR0dEcjJJVzAaJ3uRggDekZPB3qeYpMD3ayIYHKyD5sSn0IFLlEXMW001LqrvGSH",
|
stripe_pubkey: "pk_test_51J6qFXCa1Fboir5UzPO3LCiMsVNiFP2lq4wR0dEcjJJVzAaJ3uRggDekZPB3qeYpMD3ayIYHKyD5sSn0IFLlEXMW001LqrvGSH",
|
||||||
branding: {
|
branding: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user