This commit is contained in:
@@ -540,11 +540,8 @@ export default {
|
||||
//
|
||||
//
|
||||
viewGeoLocation: function(obj) {
|
||||
//TODO: url escape parameters!!
|
||||
//TODO: query by address
|
||||
/*
|
||||
{
|
||||
pointname: m.vm.obj.name,
|
||||
{
|
||||
latitude: m.vm.obj.latitude,
|
||||
longitude: m.vm.obj.longitude,
|
||||
address: m.vm.obj.address || m.vm.obj.postAddress,
|
||||
@@ -570,46 +567,68 @@ export default {
|
||||
|
||||
let mapUrl = window.$gz.store.state.userOptions.mapUrlTemplate;
|
||||
|
||||
//No pre-set?
|
||||
if (!mapUrl || mapUrl == "") {
|
||||
mapUrl =
|
||||
"https://www.google.com/maps/search/?api=1&query={ayaddress}<|>https://www.google.com/maps/search/?api=1&query={aylatitude},{aylongitude}";
|
||||
}
|
||||
|
||||
let geoMapUrl = null;
|
||||
let addressMapUrl = null;
|
||||
|
||||
if (!mapUrl || mapUrl == "") {
|
||||
//no preset map url, default to google, favor geo coordinates
|
||||
if (obj.latitude && obj.longitude) {
|
||||
geoMapUrl =
|
||||
"https://www.google.com/maps/search/?api=1&query={aylatitude},{aylongitude}";
|
||||
} else {
|
||||
//default to address search
|
||||
addressMapUrl =
|
||||
"https://www.google.com/maps/search/?api=1&query={ayaddress}";
|
||||
}
|
||||
} else {
|
||||
//we have a pre-set map url, parse it and split it and extract them
|
||||
//favor first one if multiple supported map types
|
||||
mapUrls = [mapUrl];
|
||||
if (mapUrl.includes("<|>")) {
|
||||
mapUrls = mapUrl.split("<|>");
|
||||
}
|
||||
|
||||
mapUrls.array.forEach(z => {
|
||||
if (!geoMapUrl && z.includes("{aylatitude}")) {
|
||||
geoMapUrl = z;
|
||||
}
|
||||
if (!addressMapUrl && z.includes("{ayaddress}")) {
|
||||
addressMapUrl = z;
|
||||
}
|
||||
});
|
||||
//Parse the map url
|
||||
let mapUrls = [mapUrl];
|
||||
if (mapUrl.includes("<|>")) {
|
||||
mapUrls = mapUrl.split("<|>");
|
||||
}
|
||||
|
||||
mapUrls.forEach(z => {
|
||||
if (!geoMapUrl && z.includes("{aylatitude}")) {
|
||||
geoMapUrl = z;
|
||||
}
|
||||
if (!addressMapUrl && z.includes("{ayaddress}")) {
|
||||
addressMapUrl = z;
|
||||
}
|
||||
});
|
||||
|
||||
//decide which map to use here, favor geocode
|
||||
if (hasGeo && geoMapUrl) {
|
||||
//geo view
|
||||
mapUrl = geoMapUrl;
|
||||
mapUrl = mapUrl.split("{aylatitude}").join(obj.latitude);
|
||||
mapUrl = mapUrl.split("{aylongitude}").join(obj.longitude);
|
||||
if (obj.pointname) {
|
||||
mapUrl = mapUrl.split("{aypointname}").join(obj.pointname);
|
||||
}
|
||||
} else if (hasAddress && addressMapUrl) {
|
||||
mapUrl = addressMapUrl;
|
||||
//compile address fields together
|
||||
//order street to country seems to be standard
|
||||
//note, if google need plus symbol delimiter, if bing, need comma delimiter
|
||||
//but both might accept one big string space delimited and url encoded so test that on all first
|
||||
let delimiter = " ";
|
||||
let q = "";
|
||||
if (obj.address) {
|
||||
q += obj.address + delimiter;
|
||||
}
|
||||
if (obj.city) {
|
||||
q += obj.city + delimiter;
|
||||
}
|
||||
|
||||
if (obj.region) {
|
||||
q += obj.region + delimiter;
|
||||
}
|
||||
|
||||
if (obj.country) {
|
||||
q += obj.country + delimiter;
|
||||
}
|
||||
|
||||
if (obj.postCode) {
|
||||
q += obj.postCode + delimiter;
|
||||
}
|
||||
if (q.length > 1) {
|
||||
q = q.substring(0, q.length - 1);
|
||||
}
|
||||
//url encode the query
|
||||
q = encodeURIComponent(q);
|
||||
mapUrl = mapUrl.split("{ayaddress}").join(q);
|
||||
} else {
|
||||
throw new Error(
|
||||
"View map: error - no matching mapurl / address / geo coordinates set for display, nothing to view"
|
||||
|
||||
@@ -935,7 +935,6 @@ async function clickHandler(menuItem) {
|
||||
break;
|
||||
case "geoview":
|
||||
window.$gz.util.viewGeoLocation({
|
||||
pointname: m.vm.obj.name,
|
||||
latitude: m.vm.obj.latitude,
|
||||
longitude: m.vm.obj.longitude,
|
||||
address: m.vm.obj.address || m.vm.obj.postAddress,
|
||||
|
||||
@@ -177,7 +177,7 @@ export default {
|
||||
{
|
||||
name: "Bing",
|
||||
value:
|
||||
"https://bing.com/maps/default.aspx?where1={ayaddress}<|>https://bing.com/maps/default.aspx?cp={aylatitude}~{aylongitude}&lvl=17&style=r&sp=point.{aylatitude}_{aylongitude}_{aypointname}"
|
||||
"https://bing.com/maps/default.aspx?where1={ayaddress}<|>https://bing.com/maps/default.aspx?cp={aylatitude}~{aylongitude}&lvl=17&style=r&sp=point.{aylatitude}_{aylongitude}"
|
||||
},
|
||||
{
|
||||
name: "Google",
|
||||
|
||||
Reference in New Issue
Block a user