Skip to content

Commit

Permalink
Merge pull request #371 from Shared-Reality-Lab/map-bug-fix
Browse files Browse the repository at this point in the history
fix: map query string bug
  • Loading branch information
jaydeepsingh25 committed Jan 31, 2024
2 parents b04a22b + c73415b commit 438d235
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/maps/maps-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ function sendMapRequest(port: browser.Runtime.Port, map: HTMLIFrameElement, toRe
let src = map.getAttribute("src");
let q, lat, lon, zoom;
let maptype = "roadmap";
if (src?.includes("&q=")) { // assume src is not null and then look for a query string
let i1 = src.indexOf("&q=") + 3;
console.log(src);
if (src?.includes("&q=") || src?.includes("?q=")) { // assume src is not null and then look for a query string
let i1 = (src?.includes("&q=")) ? (src.indexOf("&q=") + 3) : (src.indexOf("?q=") + 3);
let i2 = src.indexOf("&", i1) == -1 ? src.length : src.indexOf("&", i1); // query either goes to the end or there is another header
q = src.substring(i1, i2);
console.log(q);
}
if (src?.includes("&center=")) { // try to find center of map
let i1 = src.indexOf("&center=") + 8;
Expand Down

0 comments on commit 438d235

Please sign in to comment.