StreetView in v3

26 views
Skip to first unread message

Nathan Raley

unread,
Jun 11, 2010, 10:37:37 AM6/11/10
to Google Maps JavaScript API v3
I am trying to add a street view in my program as I am migrating from v2 to v3.

I have the following set up in my initialize function that runs after the page is loaded:

map = new google.maps.Map(document.getElementById("map"),  mapOptions); //{ googleBarOptions : { style : "new"} });
DistanceTextBox = (document.getElementById("distancetext"));
var tempPosition = map.getCenter();
var PanoOpts = { 
     position: tempPosition,
     navigationControl: true,
     addressControl: false,
     zoom: 14
};
myPano = new google.maps.StreetviewPanorama(document.getElementById("pano"), PanoOpts);
map.setStreetView(myPano);

I keep getting an object expected on the line where I create the new StreetviewPanorama.

Any ideas?

Marc Ridey

unread,
Jun 11, 2010, 6:37:12 PM6/11/10
to google-map...@googlegroups.com
I don't see where you are setting the map center. I'm guessing tempPosition is null when it's passed to StreetViewPanorama.
Can you explain what behavior you are trying to achieve.

Thanks

--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Nathan Raley

unread,
Jun 14, 2010, 9:18:50 AM6/14/10
to google-map...@googlegroups.com
I don't set the street view position at creation because I later feed in the center position before displaying the street view.  I show an overlay of the street view like we used to have in version 2 of the api and when the user clicks on an overlay position I set the center.

What I have now is the following in case anyone else has similar problems as to what I was having:

myPano = new google.maps.StreetViewPanorama(document.getElementById("pano"));
map.setStreetView(myPano);

myPano.setVisible(true);
InitMarkersForSV();
OverlayListeners.push(google.maps.event.addListener(map,"click", function (/*overlay,*/point/*,overlaylatlng*/) {
     latlng = point.latLng;
     if(latlng)
          SetPano(latlng);
     else if(overlaylatlng) {
          try {
               SetPano(overlaylatlng);
          }
          catch(error) {
               alert("There doesn't appear to be a Street View for that location!");
          }
     }
     else
          return;
}));

I ended up getting ready of the specific properties returned from the old version of the map click event and have limited myself to just retrieving the point they click on the map.  I am hoping that we eventually have the ability to add a regular street view overlay like we did in version 2 of the api.  I still have yet to figure out how to add the street view overlay like you get when you begin to drag the pegman icon without actually having the pegman icon control on the map and it being dragged.

Thanks,
Nathan
Reply all
Reply to author
Forward
0 new messages