javascript - Google maps api v2 on Cordova: not sentitive to events? -


in cordova, open map shows markers when initialized. in code, create map , wait event map_ready add markers. way ?

    var map; document.addeventlistener("deviceready", function() {   var button = document.getelementbyid("button");   button.addeventlistener("click", onbtnclicked, false);    var div = document.getelementbyid("map_canvas");   map = plugin.google.maps.map.getmap(div); }, false);  map.addeventlistener(plugin.google.maps.event.map_ready, function(map) {     map.getmylocation(function(location) {         var msg = ["current location:\n",             "latitude:" + location.latlng.lat,             "longitude:" + location.latlng.lng].join("\n");          map.addmarker({             'position': location.latlng,             'title': msg             }, function(marker) {                 marker.showinfowindow();         });     }); }); 

with code, marker not added. works if use button code:

    map.getmylocation(function(location) {         var msg = ["current location:\n",             "latitude:" + location.latlng.lat,             "longitude:" + location.latlng.lng].join("\n");          map.addmarker({             'position': location.latlng,             'title': msg             }, function(marker) {                 marker.showinfowindow();         }); 

thanks help!


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -