Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle maps - map doesn't reload when user shares location
    text
    copied!<p>I have a google map that displays correctly on the initial page load, and shows the correct place markers (which are retrieved from a custom web service). However I'm prompting the user to share their location, and when they do this the map disappears. I'm prompting the user to share their location by using:</p> <pre><code> if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(setPosition, error); } ... </code></pre> <p>This works fine, and in the 'success' function that gets called (setPosition), I use the following to refresh the map:</p> <pre><code>//load map object and show map this.map = new google.maps.Map( document.getElementById(this.mapElementId), { zoom: this.currentZoom, center: this.startPos, mapTypeId: google.maps.MapTypeId.ROADMAP } ); </code></pre> <p>'this.map' is successfully populated with a google map object. The 'document.getElementById(this.mapElementId)' works fine and finds the <code>&lt;div&gt;</code> that I want the map to appear in, and the 'currentZoom' and the co-ordinates for 'startPos' are being correctly obtained. </p> <p>This was all working fine previously when the map was part of an <code>&lt;iframe&gt;</code> - I've now moved the code inline into the page that previously contained the <code>&lt;iframe&gt;</code> (it doesn't look like a cross-domain issue, as I've verified this)</p> <p><strong>UPDATE</strong></p> <p>(Actually, please ignore my previous update - the markup I'm getting differs depending whether or not I'm debugging. Here is the markup from the working and broken versions when I allow sharing of my location, without having the Firebug debugger running. The blue line in the 'working' version shown highlights the div that contains the Google map.):</p> <p>WORKING:</p> <p><img src="https://i.stack.imgur.com/2uTST.png" alt="enter image description here"> BROKEN:</p> <p><img src="https://i.stack.imgur.com/AfCSO.png" alt="enter image description here"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload