method to attempt to find a portal lat/lng from guid, even if the portal data isn't available (we can also search through links and fields) - minimal testing
added note concerning unfinished/temporary nature of the portal details API
This commit is contained in:
parent
4dc7868a58
commit
3bfd83a0c2
@ -39,3 +39,43 @@ window.getPortalFields = function(guid) {
|
|||||||
|
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// find the lat/lon for a portal, using any and all available data
|
||||||
|
// (we have the list of portals, the cached portal details, plus links and fields as sources of portal locations)
|
||||||
|
window.findPortalLatLng = function(guid) {
|
||||||
|
if (window.portals[guid]) {
|
||||||
|
return window.portals[guid].getLatLng();
|
||||||
|
}
|
||||||
|
|
||||||
|
// not found in portals - try the cached (and possibly stale) details - good enough for location
|
||||||
|
var details = portalDetail.get(guid);
|
||||||
|
if (details) {
|
||||||
|
return L.latLng (details.locationE6.latE6/1E6, details.locationE6.lngE6/1E6);
|
||||||
|
}
|
||||||
|
|
||||||
|
// now try searching through fields
|
||||||
|
for (var fguid in window.fields) {
|
||||||
|
var f = window.fields[fguid].options.data;
|
||||||
|
|
||||||
|
for (var i in f.points) {
|
||||||
|
if (f.points[i].guid == guid) {
|
||||||
|
return L.latLng (f.points[i].latE6/1E6, f.points[i].lngE6/1E6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// and finally search through links
|
||||||
|
for (var lguid in window.links) {
|
||||||
|
var l = window.links[lguid].options.data;
|
||||||
|
if (l.oGuid == guid) {
|
||||||
|
return L.latLng (l.oLatE6/1E6, l.oLngE6/1E6);
|
||||||
|
}
|
||||||
|
if (l.dGuid == guid) {
|
||||||
|
return L.latLng (l.dLatE6/1E6, l.dLngE6/1E6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no luck finding portal lat/lng
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
/// PORTAL DETAIL //////////////////////////////////////
|
/// PORTAL DETAIL //////////////////////////////////////
|
||||||
// code to retrieve the new potal detail data from the servers
|
// code to retrieve the new potal detail data from the servers
|
||||||
|
|
||||||
|
// NOTE: the API for portal detailed information is NOT FINAL
|
||||||
|
// this is a temporary measure to get things working again after a major change to the intel map
|
||||||
|
// API. expect things to change here
|
||||||
|
|
||||||
|
|
||||||
// anonymous function wrapper for the code - any variables/functions not placed into 'window' will be private
|
// anonymous function wrapper for the code - any variables/functions not placed into 'window' will be private
|
||||||
(function(){
|
(function(){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user