How can I modify the code to prompt the user for their location only when they click on a specific button, and then show all markers on the map? This jsfiddle illustrates the current issues: Google map loads markers from a database, and the user is asked by the browser if they want to share their position. Here are my questions:
- How do I make the browser ask for the user's position only when they click on the "Show my position" button? How can I implement this in the code so that if the button is not clicked, the map shows the other markers instead?
- When the user clicks on "Show my position," how can I adjust the map to fit all markers on the screen and make them visible?
<button>Show my position</button>
<div id="googlemap"></div>
You can view the jsfiddle here.
Note: JSFiddle may not work on Internet Explorer. Thank you for your assistance!