Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * buscaLatLongEndereco
- *
- * busca a latitude e longitude dado um endereço
- *
- * @access public
- * @author Lucas Renato
- * @since 11/2015
- * @param Object
- * @return void
- *
- */
- this.buscaLatLongEndereco = function(Pdv){
- var q = $q.defer();
- // seta a string de endereço
- var endereco = Pdv.logradouro + ' ' + Pdv.endereco + ', ' + Pdv.numero
- + ', ' + Pdv.bairro + ' - ' + Pdv.cidade + ' - ' + Pdv.estado;
- // cria um novo geocoder
- var geocoder = new google.maps.Geocoder();
- // seta LatLong
- var LatLong = [];
- // chama a função geocoder passando endereço
- geocoder.geocode( { 'address': endereco}, function(results, status) {
- // verifica se conseguiu buscar o endereço
- if (status == google.maps.GeocoderStatus.OK) {
- // seta latitude e longitude
- LatLong[0] = results[0].geometry.location.lat();
- LatLong[1] = results[0].geometry.location.lng();
- // seta promessa como sucesso
- q.resolve(LatLong);
- } else {
- // seta promessa como falha
- q.reject();
- }
- });
- //retorna a promessa
- return q.promise;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement