Closed grzegorzgolec closed 9 years ago
Could you show me your code? Also is there any error message in xcode error log?
Thats my code
I use init function after device is ready
Map.mapObject = plugin.google.maps.Map.getMap(); Map.mapObject.on(plugin.google.maps.event.MAP_READY, function(){ Map.mapObject.setMyLocationEnabled(true); Map.mapObject.setOptions({ "camera": { "latLng": new plugin.google.maps.LatLng(Map.startLat,Map.startLng), "zoom": 15 } }); });
in different view iam setting the div
Map.mapObject.setDiv(document.getElementById("map_canvas")); Map.mapObject.refreshLayout(); Map.mapObject.setVisible(true);
No errors in xcode.
What ios version do you use? Also what the map plugin version do you use?
iOS 8.1 Map plugin v1.2.4
same error with my cordova project. iOS 7 and iOS 6. Map plugin v1.2.4 cordova ios 3.6.3.
in my case, i resolved it by enabling Google Maps SDK for iOS in Google API Console.
In my case it was always on.
Have you tried to set the mapdiv before setting the options?
I tested with simple code and I probably understand @grzegorzgolec 's report.
$(document).on('deviceready', function() {
var map = plugin.google.maps.Map.getMap();
map.on(plugin.google.maps.event.MAP_READY, function(){
map.setMyLocationEnabled(true);
map.setOptions({ "camera": {
"latLng": new plugin.google.maps.LatLng(35, 137),
"zoom": 15
}
});
});
$("#testBtn").click(function() {
map.setDiv(document.getElementById("map_canvas"));
});
});
In the above code, map.setMyLocationEnabled()
and map.setOptions()
do not work properly.
Because the map is not displayed even at once.
The map plugin passes the statements to Google Maps SDK for iOS (even if you don't display the map), but the map SDK does not work.
In order to solve this, @TheMassassian 's correct way, or execute the statements after the map.setDiv()
$("#testBtn").click(function() {
map.setDiv(document.getElementById("map_canvas"));
map.setMyLocationEnabled(true);
map.setOptions({ "camera": {
"latLng": new plugin.google.maps.LatLng(35, 137),
"zoom": 15
}
});
});
On android works perfectly on iOS not showing. Is this option available on iOS ?