-1

My current implementation is, when I open the html via browser it zooms to North America map with 4 markers. On click of the markers, the maps is zoomed to that location with few more markers added. Now I would like to add a back button so when the button is clicked it should take me to the initial maps page with 4 markers. Your help is much appreciated. Thanks, Chitra

Chitra
  • 1
  • 4

1 Answers1

0

The features of Google Maps API that you will need to use are bounds. For a rough understanding, imagine providing a top left corner point and a bottom right corner point and just telling the viewport to zoom and track to fit them in. There is a good answer here: Google Map API v3 — set bounds and center

As for how you implement the actual button to trigger the feature, that is a separate question and there are many potential solutions. Again, it has already been discussed here: Put a button on top of a google map

Community
  • 1
  • 1
Martin Joiner
  • 3,529
  • 2
  • 23
  • 49
  • Thanks @Martin. But I want the existing markers to disappear and the page loaded back to only with 4 markers (home page). – Chitra Oct 24 '16 at 07:32
  • I have made the initial loading of the page as a function. Added a Home button so as and when the button is clicked, it calls the initial loading funcion. This way I got the back button implementation working. – Chitra Oct 24 '16 at 10:00