gpt4 book ai didi

javascript - 谷歌地图显示未捕获错误 : 10 $digest() iterations reached. 中止!; Angular 应用

转载 作者:行者123 更新时间:2023-11-30 17:19:59 24 4
gpt4 key购买 nike

我正在尝试使用我的 Angular 应用程序创建 map 以在 map 上显示坐标。这些坐标是从我的api中获取的,并显示在详细页面上。但是 HTML 代码给我错误:

Uncaught Error: 10 $digest() iterations reached. Aborting!

HTML:

<input  value="{{place.place.name}}">


<label>zoom</label>
<input type="number" ng-model="zoom"/>

<div id="map_canvas">
<google-map center="{latitude: place.place.lat,longitude: place.place.lng}" zoom="zoom" draggable="true" options="options">
<marker coords="{latitude: place.place.lat,longitude: place.place.lng}"></marker>
</google-map>

</div>

所有这些代码都显示了上述错误。我怎样才能解决这个问题?下面是我的javascript,总的来说我有一个地方列表,然后用户点击这个地方和这个地方的详细信息。该页面还允许用户向页面添加类别。所以这是链接到该 map 所在页面的整个 Controller 。:

 $http.get('http://94.125.132.253:8000/getuncategorisedplaces').success(function (data, status, headers) {

$scope.places = data;
console.log(data);
$scope.message = 'Uncategorised places';
})
$scope.id = $routeParams.id;
$scope.showplace = function(id) {
$http({method: 'GET', url: 'http://94.125.132.253:8000/getitemdata?ID=' + $scope.id}).
success(function(data, status, headers, config) {
$scope.place = data; //set view model
console.log(data);

console.log(id);

$scope.view = 'templates/detail.html';

})
.error(function(data, status, headers, config) {
$scope.place = data || "Request failed";
$scope.status = status;
$scope.view = 'templates/detail.html';
});
}
$scope.showplace();


$scope.map = function(){

$scope.zoom = 13;


}
$scope.map();
$scope.meta = function () {
$http.get('http://94.125.132.253:8000/getmetas').success(function (data, status, headers) {

$scope.metas = data;
console.log($scope.category);
console.log(data);
$scope.message = 'List of Uncategorised places';


})
}
$scope.meta();
$scope.meta1 = function (data, status, headers) {
var formdata = {
'cat': $scope.cat,
}
var inserturl = 'http://94.125.132.253:8000/getcategories?meta=' + formdata.cat;
return $http.get(inserturl).success(function (data, status, headers) {

$scope.categories = data;
console.log(formdata.cat);
console.log(data);

});
};


$scope.$watch('cat', function (newvalue) {
$scope.meta1();
});
$scope.meta2 = function (data, status, headers) {
var formdata = {
'category': $scope.category,
}
var inserturl = 'http://94.125.132.253:8000/getsubcategories?category=' + formdata.category;
return $http.get(inserturl).success(function (data, status, headers) {

$scope.subcategories = data;
console.log(formdata.sub);
console.log(data);

});
};

$scope.$watch('category', function (newvalue2) {
$scope.meta2();
});

最佳答案

我认为您对使用 angularjs 的 Google map 感兴趣。

我建议另一种选择,ng-map,就像我在这里建议的那样 Google maps for AngularJS

有了ngMap,我可以轻松满足您的需求,您不必了解指令选项和指令。

<script>
var MyCtrl = function($scope) {
$scope.updateCenter = function(lat,lng) {
$scope.map.setCenter(new google.maps.LatLng(lat, lng));
}
}
</script>

<body ng-controller="MyCtrl">
<map center="[40.74, -74.18]"></map>
<button ng-click="updateCenter(41.74, -75.18)">Update Center</button>
</body>

示例 here !

关于javascript - 谷歌地图显示未捕获错误 : 10 $digest() iterations reached. 中止!; Angular 应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25310092/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com