Skip to content

I get the error, Can't find variable: google when page auto-reloads after making a save #22

@dhruveonmars

Description

@dhruveonmars

I get the error, Can't find variable: google in my browser console when the page auto-reloads after making a save, however when I reload the page in the browser manually, it usually loads fine, but not always.

Could this mean that it's trying to run the script before it's loaded the js?

This is my code;

@ViewChild('gmap') gmapElement: any;
map: google.maps.Map;

and then inside ngOnInit() {, I assign the lat/long to a variable, the styles, the marker image, and then the following:

var mapProp = new google.maps.Map(this.gmapElement.nativeElement, {
      zoom: 15,
      center: myPosition,
      disableDefaultUI: true,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      styles: myMapStyles
    });

    var marker = new google.maps.Marker({
      position: myPosition,
      map: mapProp,
      icon: mapMarkerImage,
      title: 'Temporary Title'
    });

    var contentString = '<h3 class="sectiontitle fc-darkshade">Temporary popup title</h3>'+
      '<div class="fc-darkshade">'+
      '<p>Some details here or address?</p>'+
      '</div>';

    var infowindow = new google.maps.InfoWindow({
      content: contentString
    });

    marker.addListener('click', function() {
      infowindow.open(mapProp, marker);
    });

Any help is appreciated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions