diff --git a/code/map_data_render.js b/code/map_data_render.js index 6f7a4bdc..ed63f1d5 100644 --- a/code/map_data_render.js +++ b/code/map_data_render.js @@ -241,15 +241,32 @@ window.Render.prototype.createPortalEntity = function(ent) { window.portals[ent[0]] = marker; - // re-select the portal, to refresh the sidebar on any changes - if (ent[0] === selectedPortal) { - selectPortal (ent[0]); + // check for URL links to portal, and select it if this is the one + if (urlPortalLL && urlPortalLL[0] == marker.getLatLng().lat && urlPortalLL[1] == marker.getLatLng().lng) { + // URL-passed portal found via pll parameter - set the guid-based parameter + console.log('urlPortalLL '+urlPortalLL[0]+','+urlPortalLL[1]+' matches portal GUID '+ent[0]); + + urlPortal = ent[0]; + urlPortalLL = undefined; // clear the URL parameter so it's not matched again + } + if (urlPortal == ent[0]) { + // URL-passed portal found via guid parameter - set it as the selected portal + console.log('urlPortal GUID '+urlPortal+' found - selecting...'); + selectedPortal = ent[0]; + urlPortal = undefined; // clear the URL parameter so it's not matched again } + // (re-)select the portal, to refresh the sidebar on any changes + if (ent[0] == selectedPortal) { + console.log('portal guid '+ent[0]+' is the selected portal - re-rendering portal details'); + renderPortalDetails (selectedPortal); + } //TODO? postpone adding to the map layer portalsLayers[parseInt(portalLevel)].addLayer(marker); + + }