Search code examples
google-maps-api-3google-street-view

Markers not showing in Google Street View until the camera moves


Markers are not displaying in the Google Maps Street View panorama the first time Street View mode is activated, until the camera is moved (change of location or pan around). Even Google's own example exhibits this behaviour in multiple browsers (FF, IE, Chrome) in the latest 3.31 API version and on several PCs and Chome on Android, so it looks like a bug.

Any ideas for a workaround?

Here's how to reproduce the behaviour:

  1. Go to the "Overlays within Street View" example.
  2. Click the "Toggle Street View" button. Toggle to streetview after page first loads
  3. Observe no pins present. no pin present initially
  4. Move the camera slightly and see the coffee cup pin appear. pin appears after first camera pan

This is the code I'm using to switch to Street View:

var panorama = map.getStreetView();
panorama.setPosition(<position>);
panorama.setPov(<pov>);
panorama.setVisible(true);

Some things that do work to show the markers:

  • Using Pegman to switch to to street view
  • Setting POV after a 1 second delay sometimes works

Once markers are displaying in Street View (eg using pegman or a camera move), they will continue to show, even when switching back and forth between map and streetview modes. If the page is refreshed, the no-show behaviour returns.

I've tried on a number of browsers, OSes, and hardware. If you're seeing different results to me, it would help if you could please post a comment on your broswer/OS/cpu?/graphics?.


Solution

  • It turns out this is a bug in Street View, Google is aware of it, and there is a workaround: call setZoom(1) before setVisible(true).