Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 角度谷歌地图标记不显示_Angularjs_Google Maps_Angular Google Maps - Fatal编程技术网

Angularjs 角度谷歌地图标记不显示

Angularjs 角度谷歌地图标记不显示,angularjs,google-maps,angular-google-maps,Angularjs,Google Maps,Angular Google Maps,所以我使用的是谷歌地图指令 我无法在地图实例上看到我的标记。我几乎什么都试过了,非常想得到建议。我尝试将$scope.markers移动到$scope.map对象,尝试将其移动到$watch函数中,并将值直接添加到html中,但没有成功。我认为这与我必须添加的$scope.control.refresh()函数有关,以使映射完全加载到选项卡中(我使用的是角度引导选项卡) 谢谢你的帮助 HTML 它不适用于ui gmap标记,但适用于ui gmap标记。我认为这是因为$scope.markers最

所以我使用的是谷歌地图指令 我无法在地图实例上看到我的标记。我几乎什么都试过了,非常想得到建议。我尝试将$scope.markers移动到$scope.map对象,尝试将其移动到$watch函数中,并将值直接添加到html中,但没有成功。我认为这与我必须添加的$scope.control.refresh()函数有关,以使映射完全加载到选项卡中(我使用的是角度引导选项卡)

谢谢你的帮助

HTML


它不适用于ui gmap标记,但适用于ui gmap标记。我认为这是因为$scope.markers最初没有定义


.google地图容器{
宽度:500px;
高度:500px;
}
(功能(){
"严格使用",;
var locationCtrl=函数($scope,uiGmapIsReady,$timeout){
$scope.markers=[];
$scope.map={
中心:{纬度:36.132411,经度:-80.290481},
缩放:15
};
$scope.control={};
$scope.$watch($scope.active,function(){
$timeout(函数(){
uiGmapIsReady.promise().then(函数(){
$scope.markers.push({
idKey:1,
协调:{
纬度:36.132411,
经度:-80.290481
},
});
});
}, 0);
});
};
角度.module('boltlandApp',['uiGmapgoogle-maps']))
角度。模块('boltlandApp')。控制器('LocationCtrl',LocationCtrl);
})();

受够了角度谷歌地图,所以我切换到ngMaps(github中的angularjs谷歌地图)

HTML

添加您的HTML:

<ui-gmap-markers models="markers" coords="'coords'" idKey="'idKey'">
          </ui-gmap-markers>

我今天遇到了这个问题,需要解决的只是确保包含
idKey

只需要两个属性“idKey”和“coords”,并且必须在标记中设置这两个属性

<ui-gmap-marker coords="marker.coords" idkey="marker.id">
                                                </ui-gmap-marker>

请检查每个单词的拼写。。。 此外,如果标记是通过一些纯js(来自事件处理程序或类似的东西)添加的,则需要对范围进行消化

顺便说一下,你可以重复标记

<ui-gmap-marker ng-repeat="m in map.markers" coords="m.coords" idkey="m.id" options="m.options" events="m.events">
                                                </ui-gmap-marker>

(function() {
  'use strict';

  var locationCtrl = function($scope, $timeout) {

    $scope.active = $scope.$parent.active;
    $scope.$watch($scope.active, function() {
      if($scope.active().title === "Location") {
      $scope.locationActive = true;
      } else {
        $scope.locationActive = false;
      }
      $timeout(function() {
      }, 0);
    });
  };
  angular.module('boltlandApp').controller('LocationCtrl', locationCtrl);
})();
<ui-gmap-markers models="markers" coords="'coords'" idKey="'idKey'">
          </ui-gmap-markers>
uiGmapIsReady.promise().then(function () {
         $scope.markers.push({
            idKey: 1,
              coords: {
                latitude: 36.132411,
                longitude: -80.290481
        },        
});
<ui-gmap-marker coords="marker.coords" idkey="marker.id">
                                                </ui-gmap-marker>
<ui-gmap-marker ng-repeat="m in map.markers" coords="m.coords" idkey="m.id" options="m.options" events="m.events">
                                                </ui-gmap-marker>