ang-google-services
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "ang-google-services", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Consuming google's APIs services", | ||
@@ -5,0 +5,0 @@ "main": "./src/module.js", |
{ | ||
"name": "ang-google-services", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Consuming google's APIs services", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,5 +6,22 @@ (function($A, $G) { | ||
$A.module('ang-google-services', []) | ||
.factory('$Geocode', ['$q', function($q) { return Geocode($q); }]) | ||
.factory('$Marker', ['$q', function($q) { return Marker($q); }]) | ||
.factory('$Places', ['$q', function($q) { return Places($q); }]); | ||
function Geocode($q) { | ||
var $Self = this, | ||
$GeocodeService = new $G.maps.Geocoder; | ||
return { | ||
getCoords: function() {}, | ||
getNames: function(options) { | ||
return getLocationsName.call($Self, $GeocodeService, options, $q); | ||
} | ||
}; | ||
}; | ||
/** | ||
@@ -79,12 +96,12 @@ * The factory of Marker | ||
if ('placesservice' in $Map) { | ||
} else { | ||
$Map.placesservice = new $G.maps.places.PlacesService($Map); | ||
} | ||
console.log($Map.placesservice); | ||
$Map.placesservice.nearbySearch($Req, function(results, status) { | ||
if (status == 'OK') { | ||
if (status == $G.maps.GeocoderStatus.OK) { | ||
$Deffered.resolve(results); | ||
@@ -94,7 +111,7 @@ } else { | ||
} | ||
}); | ||
return $Deffered.promise; | ||
} | ||
@@ -109,5 +126,5 @@ | ||
function getMarker(options) { | ||
if (!options['map']) return undefined; | ||
return new $G.maps.Marker({ | ||
@@ -118,3 +135,3 @@ map: options['map'], | ||
}); | ||
} | ||
@@ -128,14 +145,14 @@ | ||
function addMarkers(options) { | ||
var $Options = options || {}, | ||
$Markers = options['markers'] || [], | ||
$Map = $Options['map']; | ||
if(!$Map) return 0; | ||
for (var index = 0, length = $Markers.length; index < length; index++) { | ||
var $M = $Markers[index], | ||
$Position = ('geometry' in $M) ? $M['geometry']['location'] : $M['position'] || { lat: null, lng: null}; | ||
$Markers[index].$marker = getMarker({ | ||
@@ -145,6 +162,5 @@ position: $Position, | ||
}); | ||
$Map.panTo($Position); | ||
} | ||
@@ -154,2 +170,25 @@ | ||
/** | ||
* Gets the names of location from coordinates | ||
* | ||
* @param {Object} options | ||
*/ | ||
function getLocationsName($GeocodeService, options, $q) { | ||
var $Deffered = $q.defer(); | ||
$GeocodeService.geocode({'location' : options['coords'] || {lat: null, lng: null } }, function(results, status) { | ||
if (status == $G.maps.GeocoderStatus.OK) { | ||
$Deffered.resolve(results); | ||
} else { | ||
$Deffered.resolve({error: { message: 'Failed to get the result' }}); | ||
} | ||
}); | ||
return $Deffered.promise; | ||
} | ||
}(angular, google)); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1461880
13
208