I was so excited that I moved over my website planningalerts.org.au to
use the v3 streetview the same day I found it was available. See here
for an example: http://www.planningalerts.org.au/applications/6549
The page basically shows the user the location of a planning
application for a water tank that is has been put into the local
council.
The addition of support for markers was great too. Thanks!
I do have one thing that I tried to do but for the life of me couldn't
figure out how to do. I want to orient the view automatically to point
towards the marker which is the actual location I'm interested in.
With the v2 API I did this by using this example:
http://gmaps-samples.googlecode.com/svn/trunk/streetview/angletowardsbuilding.html
So, what I tried is requesting a panorama from the location I'm
interested in (the same as the marker location). It then gives me
something close which hopefully will have the marker viewable in it.
But once that panorama is loaded if I query it's location it's not the
actual location of the panorama, just the location I requested
initially.
So, is there a way to do what the example
http://gmaps-samples.googlecode.com/svn/trunk/streetview/angletowardsbuilding.html
does with API v3?
<html>
<head>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script>
function initialize() {
var opts = {
center: new google.maps.LatLng(48.8589, 2.2958),
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControl: true
};
var map = new google.maps.Map(document.getElementById('map'), opts);
var panorama = new
google.maps.StreetViewPanorama(document.getElementById('streetview'));
map.setStreetView(panorama);
var marker = new google.maps.Marker({
position: opts.center,
draggable: true
});
marker.setMap(map);
function refreshPanoPov() {
var markerPos = marker.getPosition();
var panoPos = panorama.getPosition();
if (markerPos && panoPos) {
var markerPosLat = markerPos.lat() / 180 * Math.PI;
var markerPosLng = markerPos.lng() / 180 * Math.PI;
var panoPosLat = panoPos.lat() / 180 * Math.PI;
var panoPosLng = panoPos.lng() / 180 * Math.PI;
var y = Math.sin(markerPosLng - panoPosLng) *
Math.cos(markerPosLat);
var x = Math.cos(panoPosLat)*Math.sin(markerPosLat) -
Math.sin(panoPosLat)*Math.cos(markerPosLat)*Math.cos(markerPosLng -
panoPosLng);
var brng = Math.atan2(y, x) / Math.PI * 180;
var pov = panorama.getPov();
pov.heading = brng;
panorama.setPov(pov);
}
}
google.maps.event.addListener(marker, 'position_changed',
refreshPanoPov);
google.maps.event.addListener(panorama, 'position_changed',
refreshPanoPov);
}
</script>
</head>
<body style="margin:0; padding:0" onload="initialize()">
<div id="map" style="width: 400px; height: 400px;"></div>
<div id="streetview" style="position:absolute; left:410px; top:
0px; width: 400px; height: 400px;"></div>
</body>
</html>
--
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.
--
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.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.