Skip to content

Commit

Permalink
interval check
Browse files Browse the repository at this point in the history
  • Loading branch information
dcooley committed Sep 4, 2024
1 parent f5fee5f commit fd73872
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions inst/htmlwidgets/google_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ HTMLWidgets.widget({

if (HTMLWidgets.shinyMode) {



// use setInterval to check if the map can be loaded
// the map is dependant on the Google Maps JS resource
// - usually implemented via callback
var checkExists = setInterval(function () {

if(typeof google !== "undefined" && typeof google.maps !== "undefined" && typeof google.charts !== "undefined" ) {

clearInterval(checkExists);

var map = new google.maps.Map(mapDiv, {
center: {lat: x.lat, lng: x.lng},
zoom: x.zoom,
Expand Down Expand Up @@ -77,18 +79,12 @@ HTMLWidgets.widget({

if(x.split_view !== null) {

//console.log("split view");
//console.log(x.split_view);
//console.log(x.split_view_options);

var panorama = new google.maps.StreetViewPanorama(
document.getElementById(x.split_view), {
position: {lat: x.lat, lng: x.lng},
pov: {
heading: x.split_view_options.heading,
pitch: x.split_view_options.pitch
//heading: 34,
//pitch: 10
}
});

Expand All @@ -101,15 +97,17 @@ HTMLWidgets.widget({
//global map object
window[el.id + 'map'] = map;

if (google !== undefined && google.charts !== undefined ) {
//console.log("exists");
clearInterval(checkExists);

initialise_map(el, x);

} else {
//console.log("does not exist!");
}
initialise_map(el, x);

//if (google !== undefined && google.charts !== undefined ) {
// //console.log("exists");
// clearInterval(checkExists);
//
// initialise_map(el, x);
//} else {
// //console.log("does not exist!");
//}
}
}, 100);

} else {
Expand Down

0 comments on commit fd73872

Please sign in to comment.