This commit is contained in:
@@ -540,11 +540,8 @@ export default {
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
viewGeoLocation: function(obj) {
|
viewGeoLocation: function(obj) {
|
||||||
//TODO: url escape parameters!!
|
|
||||||
//TODO: query by address
|
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
pointname: m.vm.obj.name,
|
|
||||||
latitude: m.vm.obj.latitude,
|
latitude: m.vm.obj.latitude,
|
||||||
longitude: m.vm.obj.longitude,
|
longitude: m.vm.obj.longitude,
|
||||||
address: m.vm.obj.address || m.vm.obj.postAddress,
|
address: m.vm.obj.address || m.vm.obj.postAddress,
|
||||||
@@ -570,46 +567,68 @@ export default {
|
|||||||
|
|
||||||
let mapUrl = window.$gz.store.state.userOptions.mapUrlTemplate;
|
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 geoMapUrl = null;
|
||||||
let addressMapUrl = null;
|
let addressMapUrl = null;
|
||||||
|
|
||||||
if (!mapUrl || mapUrl == "") {
|
//Parse the map url
|
||||||
//no preset map url, default to google, favor geo coordinates
|
let mapUrls = [mapUrl];
|
||||||
if (obj.latitude && obj.longitude) {
|
if (mapUrl.includes("<|>")) {
|
||||||
geoMapUrl =
|
mapUrls = mapUrl.split("<|>");
|
||||||
"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;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
//decide which map to use here, favor geocode
|
||||||
if (hasGeo && geoMapUrl) {
|
if (hasGeo && geoMapUrl) {
|
||||||
//geo view
|
//geo view
|
||||||
|
mapUrl = geoMapUrl;
|
||||||
mapUrl = mapUrl.split("{aylatitude}").join(obj.latitude);
|
mapUrl = mapUrl.split("{aylatitude}").join(obj.latitude);
|
||||||
mapUrl = mapUrl.split("{aylongitude}").join(obj.longitude);
|
mapUrl = mapUrl.split("{aylongitude}").join(obj.longitude);
|
||||||
if (obj.pointname) {
|
|
||||||
mapUrl = mapUrl.split("{aypointname}").join(obj.pointname);
|
|
||||||
}
|
|
||||||
} else if (hasAddress && addressMapUrl) {
|
} 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 {
|
} else {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"View map: error - no matching mapurl / address / geo coordinates set for display, nothing to view"
|
"View map: error - no matching mapurl / address / geo coordinates set for display, nothing to view"
|
||||||
|
|||||||
@@ -935,7 +935,6 @@ async function clickHandler(menuItem) {
|
|||||||
break;
|
break;
|
||||||
case "geoview":
|
case "geoview":
|
||||||
window.$gz.util.viewGeoLocation({
|
window.$gz.util.viewGeoLocation({
|
||||||
pointname: m.vm.obj.name,
|
|
||||||
latitude: m.vm.obj.latitude,
|
latitude: m.vm.obj.latitude,
|
||||||
longitude: m.vm.obj.longitude,
|
longitude: m.vm.obj.longitude,
|
||||||
address: m.vm.obj.address || m.vm.obj.postAddress,
|
address: m.vm.obj.address || m.vm.obj.postAddress,
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ export default {
|
|||||||
{
|
{
|
||||||
name: "Bing",
|
name: "Bing",
|
||||||
value:
|
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",
|
name: "Google",
|
||||||
|
|||||||
Reference in New Issue
Block a user