The tilesloaded event in google.maps.event.addListener is unexpectedly failing to trigger

Today, while testing popover messages on my cordova/ionic app, I compiled the app and noticed that the maps weren't loading. Instead, only my custom "Loading map..." spinning icon kept showing.

Upon investigating further, I found that

var setMap = new google.maps.Map(document.getElementById("mapBody"), mapOptions) ;

was actually loading - as I was able to print setMap to the console.

I have a function that constantly checks for tilesloaded every 500ms in order to stop the spinner and allow the map to load naturally.

However,

google.maps.event.addListenerOnce(setMap,'tilesloaded', function() {..}
never seems to trigger.

This issue started happening simultaneously on iOS and Android without any changes to the mapping code.

code:

  $scope.mapLoader = 0 ;
  $scope.mapTrigger = 0 ;
  function checkLoader() {
    if ($scope.mapLoader == 0) {
      //console.log(setMap) ;
      if (setMap && $scope.mapTrigger == 0) {
        console.log("setMap/mapTrigger") ;
        console.log(setMap) ;
        $scope.mapTrigger = 1 ;
        google.maps.event.addListenerOnce(setMap,'tilesloaded', (function() {
          ////// it never makes it inside here, as the function never fires.
          console.log("tilesloaded done") ;
          $scope.mapLoader = 1 ;
          $scope.$apply() ;
        });
      setTimeout(function() {
        //console.log("Checking Loader") ;
        checkLoader() ;
      },500) ;
    } 
  }

  if ($scope.mapLoader == 0) {
    checkLoader() ;
  } else {
    $scope.mapLoader = 1 ;
  }

Even though set map is loading and it appears that the tilesloaded event is complete (as shown in the console log below), the addListenerOnce function isn't firing. This could explain why the map fails to load and the inner addListenerOnce function never gets triggered. Strangely, there are no errors or indications of issues in the console.

console.log output:

setMap/mapTrigger
https://i.sstatic.net/ABOPk.png

Answer №1

Apparently, by adding a css tag for a popover window and failing to close the element, your application may still function properly but Google Maps will not work as expected.

.platform-ios ion-popover-view.fit {
  padding-top: 10px;
  padding-bottom: 10px;

The correct syntax should be:

.platform-ios ion-popover-view.fit {
  padding-top: 10px;
  padding-bottom: 10px;
}

It seems like I've been gazing at the screen for too long and starting to make those "time to call it a day" mistakes.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Best practices for handling multiple tables in AngularJS HTML

How can I loop through multiple tables in AngularJS? Here is an example of my HTML code: <div ng-repeat="stuff in moreStuff"> <table> <h1>{{stuff.name}}</h1> <tr ng-repeat="car in cars"> <td> ...

What is the best way to utilize this resulting value as an input?

I am trying to generate a random number using math.random and use that value in the following script: let bday = Math.floor( Math.random() * (30 - 1 + 1) + 1 ); await test.page.select('select[name="day_select"]',bday); However, I am ...

Retrieve the ID of the image element using Jquery from a collection of images within a div container

I'm encountering a simple issue that I can't seem to solve. I am working on a basic slider/gallery with the following functionalities: 1) "If button 1 is clicked, image one will appear." 2) "Clicking on button 2 will make IMAGE 1 slide left and I ...

Discovering the quantity of identical elements within a JavaScript array

Looking for some assistance in solving a JavaScript problem as I am relatively new to the language: I have an array and I need help in determining the count of identical values. Below is my array: var arr = ["red", "blue", "green", "red", "red", "gray"] ...

What is the process for creating a button click listener event in Kotlin or JavaScript?

While working in IntelliJ IDEA, I have created a button in my HTML file with an ID. My goal is to change the header tag to say "button clicked" using Kotlin. After searching through kotlinlang.org and other resources, I am struggling to find a simple refe ...

What are some effective methods for locating dual edges within a Half-Edge (DCEL) data structure?

I have implemented a HalfEdge data structure to represent the connectivity between faces in my mesh. While importing an external model, I construct the HalfEdge structure. However, for meshes with numerous triangles, the construction process is time-consu ...

What are the steps to implement a Bottom Navigation bar in iOS and a Top Navigation bar in Android using NativeScript Angular?

For my project, I decided to utilize the tns-template-tab-navigation-ng template. I am currently working on creating a WhatsApp clone, and in iOS, it features a bottom navigation bar while in Android, it has a top navigation bar. I am looking for guidance ...

Leveraging *ngFor to extract HTML content from ion-label

I've encountered an issue while using *ngFor in my HTML like this: <ion-slides #slides [options]="slideOpts"> <ion-slide class="numbers-wrapper" *ngFor="let questionNumber of numbers" (click)="clickQue ...

Creating an AJAX URL in an external JavaScript file within a Django project

How can I verify if a student user's email exists in the database using keyup event in a registration form, and prevent form submission if the email is already registered? Below are the relevant files for achieving this: urls.py urlpatterns = [ ...

execute the NPM script in the current directory

Within my package.json file for a node project, I have the following test script that utilizes the ts-node package: "scripts": { "build": "tsc", "test": "ts-node" } Executing this script from the root ...

After manipulating the array, Vue fails to render the input fields generated by the v-for directive

After setting the value externally, Vue component won't re-render array items. The state changes but v-for element does not reflect these changes. I have a component that displays items from an array. There are buttons to adjust the array length - &a ...

Using D3 to create SVG elements in Next.js, the mouseenter event only triggers once

I'm currently developing a React Component that utilizes D3, however, I am facing an issue where the SVG circles are only triggered once. import React, { useEffect, useRef, useState } from 'react'; import * as d3 from 'd3'; import ...

Display HTML components depending on an object's property using AngularJS

Here is the code I have created to display a simple drop down list: var products = [ { "id": 1, "name": "Product 1", "price": 2200, "category": "c1" }, { "id": 2, "name": "Product 2", "p ...

Tips for incorporating the "define" function into your Mocha testing

Starting my journey with JavaScript testing, I made the decision to use Mocha. The specific modules I am looking to test are AMD/RequireJS. However, it appears that Mocha only works with CommonJS modules. Consequently, when trying to run it, I encounter t ...

Adjust google maps to fill the entire vertical space available

I found this helpful resource for integrating Google Maps into my Ionic app. Everything is working smoothly, but I am trying to make the map fill the remaining height below the header. Currently, I can only set a fixed height in pixels like this: .angula ...

React Intersection Observer not functioning properly

Hey there! I'm trying to create an animation where the title slides down and the left element slides to the right when scrolling, using the intersection observer. Everything seems to be fine in my code, but for some reason it's not working. Any t ...

Where should the JQuery hashchange event be added for optimal placement?

I am currently utilizing the JQuery hashchange event. $(window).on('hashchange', function () { //perform certain actions }); On the initial load, if my URL includes a hash value, I know that it must be triggered by $(window).hashchange(); Is i ...

How to Use Framer Motion in Next.js for window.innerWidth Less Than 768

I am trying to use window.innerWidth to control the timing of an animation (Framer Motion) in my Next.js project, but I keep encountering the error message: ReferenceError: window is not defined Here's a simplified version of my ValuesSection.jsx co ...

Issue with Semantic-UI Special PopUp not displaying on screen

I'm currently working on creating a unique pop-up feature using custom HTML, with the intention of adding content to it later on. My console is displaying the following message: Popup: No visible position could be found for the popup. $(document) ...

Modifying Stroke color in HTML5 Canvas

I am attempting to create a unique visual effect by drawing a circle resembling a clock using canvas 2d context. The idea is to initially draw the circle in black starting at point p1, and then when I complete a full circle tour it should erase as the colo ...