question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Map Ready is not firing

See original GitHub issue

Hi, I was trying to use this plugin in my cordova app. map.addEventListener(plugin.google.maps.event.MAP_READY, onMapReady);

MAP_READY is not firing. Do I need to change anything? screen is blank & no error in console.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
tigertooth01commented, Apr 30, 2018

I am also facing the same issue. I will provide as much info as I can, as I also have an NDA with my client… Also here is a link to a sample I created with just the index.html. It also shows same behaviour in iOS 10. Repository

OS: iOS 10 Cordova: 8.0.0

I tried the code block from documentation, and it failed to trigger MAP_READY. No map, just white screen.

But if I send the app to the background, and open it again, MAP_READY is triggered! And map is loaded. But I have added animate function, but that is not triggered now.

But if I repeat the same step again, it shows the map zoomed to a wrong location. If i touch and drag the map, then it suddenly shows the actual location.

0reactions
gfranco69commented, Apr 25, 2021

MAP_READY is not firing. Do I need to do? screen is blank & no error in console. I am using the last version of plugin,

Show me the position 37.4219983,-122.084 and the message alert(‘Before-Map-Ready’) correctly, but no the message alert(‘MAP-READY-OK’); please help me with this.

index.html

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Security-Policy" content="default-src * gap: ws: https://ssl.gstatic.com;style-src * 'unsafe-inline' 'self' data: blob:;script-src * 'unsafe-inline' 'unsafe-eval' data: blob:;img-src * data: 'unsafe-inline' 'self' content:;fmedia-src mediastream;">
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
        <title>Map Test</title>
        <script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
        <script type="text/javascript">
             (function () {
                "use strict";
                document.addEventListener('deviceready', onDeviceReady.bind(this), false);
                function onDeviceReady() {
                 var option = { enableHighAccuracy: true };
                    plugin.google.maps.LocationService.getMyLocation(option, function (location) {
                            var pos = location.latLng;
                            var mapDiv = document.getElementById('map_canvas');
                            var map = plugin.google.maps.Map.getMap(mapDiv, { camera: { latLng: pos,   zoom: 15 } });
                            alert('Before-Map-Ready');
                            map.addEventListener(plugin.google.maps.event.MAP_READY, function () {
                                 alert('MAP-READY-OK');
                            });
                  });
                };
            })();
        </script>
    </head>
    <body>
        <div>
            <div id="deviceready"></div>
            <div style="width:500px;height:500px" id="map_canvas"></div>
        </div>
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="scripts/platformOverrides.js"></script>
     </body>
</html>

Java JDK: installed 1.8.0 Android SDK: installed true Android target: installed android-30,android-29,android-28,android-27,android-26,android-25,android-24,android-23,android-22,android-21,android-20,android-19,android-18,android-17,android-16,android-15,android-14,android-13,android-12,android-11,android-10,android-9,android-8,android-7 Gradle: installed C:\Gradle\gradle-6.6\bin\gradle.BAT

Cordova Packages:

cli: 10.0.0
    common: 4.0.2
    create: 3.0.0
    lib: 10.0.0
        common: 4.0.2
        fetch: 3.0.0
        serve: 4.0.0

Project Installed Platforms:

android: 9.1.0

Project Installed Plugins:

cordova-plugin-camera: 5.0.1
cordova-plugin-googlemaps: 2.7.1
cordova-plugin-whitelist: 1.3.4

config.xml PATH: C:\Hunter\Projects\APPS_ANDROID\BlueHawk1\config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.app.BlueHawk1" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>BlueHawk1</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
	<preference name="GOOGLE_MAPS_ANDROID_API_KEY" value="AIzaSy*******************************" />
</widget>

config.xml PATH: C:\Hunter\Projects\APPS_ANDROID\BlueHawk1\platforms\android\app\src\main\res\xml\config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.app.BlueHawk1" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <feature name="Whitelist">
        <param name="android-package" value="org.apache.cordova.whitelist.WhitelistPlugin" />
        <param name="onload" value="true" />
    </feature>
    <name>BlueHawk1</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <allow-intent href="market:*" />
	<preference name="GOOGLE_MAPS_ANDROID_API_KEY" value="AIzaSy************************************" />
    <preference name="loglevel" value="DEBUG" />
    <feature name="Camera">
        <param name="android-package" value="org.apache.cordova.camera.CameraLauncher" />
    </feature>
    <preference name="xwalkZOrderOnTop" value="true" />
    <preference name="BackgroundColor" value="0" />
    <preference name="android-minSdkVersion" value="19" />
    <feature name="CordovaGoogleMaps">
        <param name="android-package" value="plugin.google.maps.CordovaGoogleMaps" />
        <param name="onload" value="true" />
        <param name="onreset" value="true" />
    </feature>
    <feature name="PluginMap">
        <param name="android-package" value="plugin.google.maps.PluginMap" />
    </feature>
    <feature name="PluginPolyline">
        <param name="android-package" value="plugin.google.maps.PluginPolyline" />
    </feature>
    <feature name="PluginPolygon">
        <param name="android-package" value="plugin.google.maps.PluginPolygon" />
    </feature>
    <feature name="PluginMarker">
        <param name="android-package" value="plugin.google.maps.PluginMarker" />
    </feature>
    <feature name="PluginCircle">
        <param name="android-package" value="plugin.google.maps.PluginCircle" />
    </feature>
    <feature name="PluginTileOverlay">
        <param name="android-package" value="plugin.google.maps.PluginTileOverlay" />
    </feature>
    <feature name="PluginGroundOverlay">
        <param name="android-package" value="plugin.google.maps.PluginGroundOverlay" />
    </feature>
    <feature name="PluginKmlOverlay">
        <param name="android-package" value="plugin.google.maps.PluginKmlOverlay" />
    </feature>
    <feature name="PluginGeocoder">
        <param name="android-package" value="plugin.google.maps.PluginGeocoder" />
    </feature>
    <feature name="PluginLocationService">
        <param name="android-package" value="plugin.google.maps.PluginLocationService" />
    </feature>
    <feature name="PluginEnvironment">
        <param name="android-package" value="plugin.google.maps.PluginEnvironment" />
    </feature>
    <feature name="PluginMarkerCluster">
        <param name="android-package" value="plugin.google.maps.PluginMarkerCluster" />
    </feature>
    <feature name="PluginStreetViewPanorama">
        <param name="android-package" value="plugin.google.maps.PluginStreetViewPanorama" />
    </feature>
</widget>


config.xml PATH: C:\Hunter\Projects\APPS_ANDROID\BlueHawk1\node_modules\cordova-android\bin\templates\project\res\xml\config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
-->
<widget xmlns     = "http://www.w3.org/ns/widgets"
        id        = "io.cordova.helloCordova"
        version   = "2.0.0">
    <name>Hello Cordova</name>

    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>

    <author href="http://cordova.io" email="dev@cordova.apache.org">
        Apache Cordova Team
    </author>

    <!-- <content src="http://mysite.com/myapp.html" /> for external pages -->
    <content src="index.html" />

    <!-- Whitelist docs: https://github.com/apache/cordova-plugin-whitelist -->
    <access origin="*" />
    <!-- Grant certain URLs the ability to launch external applications. This
         behaviour is set to match that of Cordova versions before 3.6.0, and
         should be reviewed before launching an application in production. It
         may be changed in the future. -->
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <allow-intent href="market:*" />

    <preference name="loglevel" value="DEBUG" />
    <!--
      <preference name="splashscreen" value="splash" />
      <preference name="backgroundColor" value="0xFFF" />
      <preference name="loadUrlTimeoutValue" value="20000" />
      <preference name="InAppBrowserStorageEnabled" value="true" />
      <preference name="disallowOverscroll" value="true" />
    -->
	<preference name="GOOGLE_MAPS_ANDROID_API_KEY" value="AIzaSy************************************************" />
</widget>






Read more comments on GitHub >

github_iconTop Results From Across the Web

Leaflet map-event 'load' does not fire - Stack Overflow
I am trying to call a function after a leaflet map has successfully loaded, working with leaflet 1.0.1. Regarding to the docs there...
Read more >
React-Native-Maps: "onmapready" not firing unless I save my ...
The issue is that onMapReady doesn't fire whenever my map is loaded, until I save the actual component, even if there aren't any...
Read more >
Overview | Maps JavaScript API - Google Developers
Get started with the Google Maps JavaScript API. View a simple example, learn the concepts, and create custom maps for your site.
Read more >
MapView | API Reference | ArcGIS Maps SDK for JavaScript ...
A MapView may not be immediately ready for display after it has been constructed. For example, map data may need to be loaded...
Read more >
How to Fix Google Maps Not Working? [2022 Guide] - AirDroid
First, close the Map application in the multi-window section and restart Google Maps. If that doesn't work, try restarting your phone. You can ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found