5

google maps geocoding api ile ilgili bazı sorunlarım var. Ben Açısal Google Maps kullanarak ve geri arama işlevine sahip bir adres coğrafi kod çalışıyorumAçısal Google geocoding geri arama haritaları

:

.controller('myCtrl', ['$scope', '$rootScope', 'uiGmapGoogleMapApi', function ($scope, $rootScope, uiGmapGoogleMapApi) { 

    // To be set by previous step 
    $rootScope.chosenTown = "Roma" 

    // geocode the given address 
    var geocodeAddress = function(address, callback) { 
     var geocoder = new google.maps.Geocoder(); 
     geocoder.geocode({ 'address': address}, function(results, status) { 
      if (status == google.maps.GeocoderStatus.OK) { 
       callback(results[0].geometry.location); 
      } else { 
       console.log("Geocode was not successful for the following reason: " + status); 
      } 
     }); 
    }; 

    // google maps is ready 
    uiGmapGoogleMapApi.then(function(maps) { 
     // geocode chosen town 
     geocodeAddress($rootScope.chosenTown, function(latLng){ 
      console.log("1 " + latLng.lat()) 
      console.log("2 " + latLng.lng()) 
      $scope.map = { center: { latitude: latLng.lat(), longitude: latLng.lng() }, zoom: 12, bounds: {}}; 
     }); 

    }); 
}]) 

Ve html kodu: harita gösterilmez

<div class="col-lg-5 finalStepMap"> 
     <ui-gmap-google-map center='map.center' zoom='map.zoom' draggable="true" options="options" bounds="map.bounds"> 
      <ui-gmap-markers models="markers" coords="'self'" options="'options'"></ui-gmap-markers> 
     </ui-gmap-google-map> 
</div> 

.

Ancak, Ararsam:

$scope.map = { center: { latitude: 10, longitude: 40}, zoom: 12, bounds: {}}; 
     }); 

geri arama işlevi dışında sabit enlem ve LNG ile, her şey gayet iyi çalışıyor.

Herhangi bir ipucu? Değerli yardım :) için

Teşekkür

cevap

3

daha googling sonra, nihayet cevabını buldu!

Sen kullanmak zorunda:

$scope.$apply(function() { 
    $scope.map = ... 
}); 
İlgili konular