javascript - Creating links when switching between custom street view panoramas via <select> -
i have street view-map of campus area. can navigate around areas links created getcustomlinks fine. have been stuck while now: there way change between custom street view panoramas via select component? want able navigate around campus area arrows, able jump panorama in select-component. arrows work perfectly. far have managed change panoramas
my select-box
<select onchange="onchange()" id="hamk_select" width="1000px"> <option value="b_talo_piha">hamk visamäki</option> <option value="kirjasto">kirjasto</option> <option value="c_talo_auditorio">auditorio</option> </select>
onchange()-function
function test(){ d = document.getelementbyid("hamk_select").value; var panooptions = { pano: d, visible: true, panoprovider: getcustompanorama, scrollwheel: true, enableclosebutton: false, centerheading: 270, disabledoubleclickzoom: true, zoomcontrol: true, zoomcontroloptions: { style: google.maps.zoomcontrolstyle.small }, pov: { heading: 130, pitch: 0 }, clicktogo: false, imagedatecontrol: false, pancontrol: false }; panorama = new google.maps.streetviewpanorama(document.getelementbyid('map_canvas'),panooptions);
now stuck creating correct links. in initialization method, similar example @ documentation eventlistener added 'links_changed' event , 'result.location.pano' used create links.
streetviewservice = new google.maps.streetviewservice(); var radius = 50; streetviewservice.getpanoramabylocation(the_entry_location, radius, function(result, status) { if (status == google.maps.streetviewstatus.ok) { google.maps.event.addlistener(panorama, 'links_changed', function() { createcustomlinks(result.location.pano); }); } });
i think should use streetviewservice's getpanoramabyid-method instead of getpanoramabylocation. have tried fails (status = unknown_error, javascript console says: 404 not found in header, isn't working.)
streetviewservice.getpanoramabyid(panorama.getpano(), function(result, status) { if (status == google.maps.streetviewstatus.ok) { createcustomlinks(result.location.pano); } });
calling createcustomlinks(d) doesn't either, var links not defined. ideas how correctly this?
solution ridiculously simple: change pano value , use panorama.setoptions value trigged original "links_changed" event.
function onchange(){ d = document.getelementbyid("hamk_select").value; var panooptions = { pano: d, }; panorama.setoptions(panooptions); }
Comments
Post a Comment