0
在我的项目中,我整合了谷歌地图。我遇到了一个问题:当我搜索某个特定位置时,标记不会显示在当前位置,而是显示在其他位置。但是,经纬度是正确的,你能帮我理解我失踪的是什么吗?谷歌地图标记没有显示在确切的位置
注意:对于某些位置,标记显示在正确的位置。
HTML代码:
<input ng-model="address" class="form-control" ng-map-autocomplete/>
<ng-map zoom="18" center="{{address}}" style="width:650px; height:450px">
<marker position="{{address}}" title="{{address}}" draggable="true"></marker>
</ng-map>
控制器:
$scope.$watch(function ($scope) { return $scope.chosenPlaceDetails }, function() {
if (angular.isDefined($scope.chosenPlaceDetails)) {
$scope.latitude= $scope.chosenPlaceDetails.geometry.location.lat();
$scope.longitude=$scope.chosenPlaceDetails.geometry.location.lng();
}
});
如何更改控制器中的代码,然后.. –
如果你想还以更新控制器,也许把$ details。$ watch('details',function(newValue,oldValue){ $ scope.latitude = newValue.geometry.location.lat; $ scope.longitude = newValue.geometry .location.lng } }); ' – Roux
Hi Roux在我的控制器中,我给出了这样的初始值:\t $ scope.address =“12180 Park Ave S,Tacoma,WA 98447,USA”; \t $ scope.lat =“47.146427232895235”; \t $ scope.lng =“ - 122.4420750597717”; –