1

I have a google map and some markers, on clicking the markers I want to open up a street view map, which can be closed and open up again.

I have tried using single global street view instance and using display:none to hide it, problem is, the map won't show render again after it has been hidden.

I also tried initiating new global instance every time, but looks like old instances are not destroyed, and renders new overlays on top of older overlays.

What's the best way to achieve this?

Edit:

Probably a separate question, if above is not easy to achieve, how do I switch existing map to street view mode, given a lat lng? I have been searching on google and couldn't find any apparent result.

James Lin
  • 25,028
  • 36
  • 133
  • 233

1 Answers1

1

OK, I was wrong about "I also tried initiating new global instance every time, but looks like old instances are not destroyed, and renders new overlays on top of older overlays." So it is workable.

And regarding to my question update, I got my answer from the following link:

https://developers.google.com/maps/documentation/javascript/examples/streetview-overlays

Here is the code in case you have similar purpose:

var sv = map.getStreetView();
sv.setPosition(new google.maps.LatLng(lat,lng));                                                                                                   
sv.setVisible(true); 
James Lin
  • 25,028
  • 36
  • 133
  • 233
  • could you take a look at mine https://stackoverflow.com/q/45654166/7039895 I am stuck and I see you figured it out but I do not know how to apply it to my code. – Jermaine Subia Aug 12 '17 at 23:05