Fixed loading of API
parent
10709b1342
commit
3d3838943b
|
@ -26,7 +26,7 @@
|
||||||
<main></main>
|
<main></main>
|
||||||
|
|
||||||
<script async defer
|
<script async defer
|
||||||
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCNFRG3ItKvYNSTCJrDcQCqy0470RdhI6A&callback=init">
|
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAaDEDFAbk7Iefh9y61wuooDH2kWHRT_k8&callback=init">
|
||||||
</script>
|
</script>
|
||||||
<script src="script.js"></script>
|
<script src="script.js"></script>
|
||||||
|
|
||||||
|
|
10
script.js
10
script.js
|
@ -1,12 +1,12 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
/* global navigator googlemaps $ */
|
/* global navigator google */
|
||||||
|
|
||||||
var pano, newLoc;
|
var pano, newLoc;
|
||||||
const main = document.getElementsByTagName('main')[0];
|
const main = document.getElementsByTagName('main')[0];
|
||||||
|
|
||||||
// Create panorama
|
// Create panorama
|
||||||
function init(){
|
function init(){
|
||||||
pano = new googlemaps.StreetViewPanorama(main, {
|
pano = new google.maps.StreetViewPanorama(main, {
|
||||||
panControl: false,
|
panControl: false,
|
||||||
zoomControl: false,
|
zoomControl: false,
|
||||||
addressControl: false,
|
addressControl: false,
|
||||||
|
@ -20,7 +20,7 @@ function init(){
|
||||||
function getStreetViewData(loc,rad,cb) {
|
function getStreetViewData(loc,rad,cb) {
|
||||||
// Ensure that the location hasn't changed (or this is the initial setting)
|
// Ensure that the location hasn't changed (or this is the initial setting)
|
||||||
if ( newLoc == null || loc.tim===newLoc.tim ) {
|
if ( newLoc == null || loc.tim===newLoc.tim ) {
|
||||||
if (!sv) { var sv=new googlemaps.StreetViewService(); }
|
if (!sv) { var sv=new google.maps.StreetViewService(); }
|
||||||
sv.getPanorama({
|
sv.getPanorama({
|
||||||
location: {
|
location: {
|
||||||
lat: loc.lat,
|
lat: loc.lat,
|
||||||
|
@ -29,11 +29,11 @@ function getStreetViewData(loc,rad,cb) {
|
||||||
radius: rad
|
radius: rad
|
||||||
}, function(data,status){ switch (status){
|
}, function(data,status){ switch (status){
|
||||||
// Success
|
// Success
|
||||||
case googlemaps.StreetViewStatus.OK:
|
case google.maps.StreetViewStatus.OK:
|
||||||
cb(data);
|
cb(data);
|
||||||
break;
|
break;
|
||||||
// No results in that radius
|
// No results in that radius
|
||||||
case googlemaps.StreetViewStatus.ZERO_RESULTS:
|
case google.maps.StreetViewStatus.ZERO_RESULTS:
|
||||||
// Try again with a bigger radius
|
// Try again with a bigger radius
|
||||||
getStreetViewData(loc,rad*2,cb);
|
getStreetViewData(loc,rad*2,cb);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue