mapsplugin / cordova-plugin-googlemaps

Google Maps plugin for Cordova
Apache License 2.0
1.66k stars 918 forks source link

Uncaught TypeError: Cannot read property 'google' of undefined #1089

Closed jmi23 closed 8 years ago

jmi23 commented 8 years ago

wait for deviceready event, div is set, but no map starts. trying to address with all the

in all the cases the map doesnt start. Using Intel XDK, cordova 5.4.1, crosswalk. What is the correct usage? code as follows:

var mapDiv = document.getElementById("gmap");
    var gomap = window.plugin.google.maps.Map(mapDiv);

or as this, according to your example:

document.addEventListener("deviceready", function() {
      var div = document.getElementById("gmap");

      // Initialize the map view
      map = window.plugin.google.maps.Map.getMap(div);

      // Wait until the map is ready status.
      map.addEventListener(plugin.google.maps.event.MAP_READY, onMapReady);
    }, false);

    function onMapReady() {
        $('body').css('background-color','transparent');
      //var button = document.getElementById("button");
    //  button.addEventListener("click", onBtnClicked, false);
    }
wf9a5m75 commented 8 years ago

Most of this case, there is javascript error in your code, and it fails to load the maps plugin.

jmi23 commented 8 years ago

Sorry, but Intel XDK manages all the plugins, and no one of them have to be loaded with plugin. prefix. I asked you for correct usage. Until this I try to reinstall the plugin, maybe thats why an error occurs. The deviceready system works, because all the other things load and if, say, to code "console.log("ready")" in the deviceready function, it appears in the console.

wf9a5m75 commented 8 years ago

We don't support independent IDEs, and I have never used the Intel XDK. Please ask at the Intel XDK community or stack overflow.

For your information: regarding of @ttarakanoff comments, you need to use remote debugger. https://github.com/mapsplugin/cordova-plugin-googlemaps/issues/714#issuecomment-169866410

jmi23 commented 8 years ago

Thanks, but i already figured it out. Reinstalling of the plugins helped. Maybe, the internet connection was slow, and on downloading from NPM repo something went missing. Now it works, with window.plugin.google.maps.