ng-cordova
Version:
[ngCordova](http://ngcordova.com/) ==========
54 lines (45 loc) • 1.39 kB
JavaScript
// install :
// link :
// Google Maps needs ALOT of work!
// Not for production use
angular.module('ngCordova.plugins.googleMap', [])
.factory('$cordovaGoogleMap', ['$q', '$window', function ($q, $window) {
var map = null;
return {
getMap: function (options) {
var q = $q.defer();
if (!$window.plugin.google.maps) {
q.reject(null);
} else {
var div = document.getElementById('map_canvas');
map = $window.plugin.google.maps.Map.getMap(options);
map.setDiv(div);
q.resolve(map);
}
return q.promise;
},
isMapLoaded: function () { // check if an instance of the map exists
return !!map;
},
addMarker: function (markerOptions) { // add a marker to the map with given markerOptions
var q = $q.defer();
map.addMarker(markerOptions, function (marker) {
q.resolve(marker);
});
return q.promise;
},
getMapTypeIds: function () {
return $window.plugin.google.maps.mapTypeId;
},
setVisible: function (isVisible) {
var q = $q.defer();
map.setVisible(isVisible);
return q.promise;
},
// I don't know how to deallocate te map and the google map plugin.
cleanup: function () {
map = null;
// delete map;
}
};
}]);