Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.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 Api 3_Angular Google Maps - Fatal编程技术网

Angularjs 使用角度谷歌地图刷新地图和标记

Angularjs 使用角度谷歌地图刷新地图和标记,angularjs,google-maps-api-3,angular-google-maps,Angularjs,Google Maps Api 3,Angular Google Maps,嗨,我正在使用谷歌地图的角度为我的项目。html和js代码如下 html: 我不知道如何用新标记刷新地图,甚至不知道如何触发地图更新。我玩过ui gmap谷歌地图的“控制”和“刷新”参数,但无法让它工作 尝试dorebuildall属性 <ui-gmap-markers models="apartments" coords="'loc'" icon="'assets/images/map_icon_normal.png'" idkey="'_id'"

嗨,我正在使用谷歌地图的角度为我的项目。html和js代码如下

html:


我不知道如何用新标记刷新地图,甚至不知道如何触发地图更新。我玩过ui gmap谷歌地图的“控制”和“刷新”参数,但无法让它工作

尝试
dorebuildall
属性

<ui-gmap-markers 
    models="apartments"
    coords="'loc'"
    icon="'assets/images/map_icon_normal.png'"
    idkey="'_id'"
    fit="'false'"
    click="click"
    dorebuildall="true">
        <ui-gmap-windows></ui-gmap-windows>
</ui-gmap-markers>


更多详细信息请访问:

您需要使用
uiGmapIsReady
——而不是
uiGmapGoogleMapApi
——等待
控件
对象使用其方法进行扩充(例如
刷新

uiGmapIsReady
服务提供了一个承诺,当所有
uiGmapGoogleMap
指令完全初始化时解决问题,而
uiGmapGoogleMapApi
服务只在加载Google Maps JS API时解决问题

有关使用
uiGmapIsReady
的示例,请参阅。当然,别忘了


关于如何更新作用域上的models属性以更新映射,需要充实和清理代码示例以帮助您实现这一点。(例如,
getApartments
更新
$scope.apartments
?或者问这个问题本身就是答案?)看看,这可能会对你有所帮助。

你能为此创建一个plnkr吗?我面临同样的问题,我发现了新的刷新功能,示例:$scope.map.control.refresh({纬度:32.779680,经度:-79.935493});但这对我不起作用,你解决了这个问题吗?
.controller('MapCtrl',
                    function ($scope, $routeParams, Map, uiGmapGoogleMapApi) {
 $scope.apartments = [];
 $scope.customIcon = "../../assets/images/map_icon_normal.png"

$scope.map = {
      center: {
        latitude: $routeParams.lat,
        longitude: $routeParams.lon
      },

      zoom: 5,
      bounds: {},
      events: {
        tilesloaded: function (map) {
          //console.log('tiles loaded');
          $scope.$apply(function () {
            $scope.mapInstance = map;
            //console.log(map.getBounds().getNorthEast());
            $scope.searchbox.options.bounds = new google.maps.LatLngBounds($scope.mapInstance.getBounds().getNorthEast(),
              $scope.mapInstance.getBounds().getSouthWest());

          });
        },
        idle: function(map) {

          $scope.map.refresh = false;

        },
        resize: function(map) {
          console.log('resize');
        },
        dragend: function() {

        }
      },
      markersEvents: {
        click: function(marker, eventName, model, args) {
          console.log('markerEvent click');
          $scope.map.window.model = model;
          $scope.map.window.show = true;
        }
      },

      window :  {
        marker: {},
        show: false,
        closeClick: function() {
          this.show = false;
        },
        options: {} // define when map is ready
      },

      control: {},
      refresh: function () {
        $scope.map.control.refresh();
      }
    }

    uiGmapGoogleMapApi.then(function (map) {

      $scope.getData(20, 0, map);

      map.visualRefresh = true;
      $scope.mapInstance = map;


    })

       $scope.getData = function(limit, offset, map) {
      Map.getApartments($routeParams.lat, $routeParams.lon, limit, offset).success(function (data) {
         ///----- I get undefined error here---
              $scope.map.control.refresh();



      });

    }})
}
<ui-gmap-markers 
    models="apartments"
    coords="'loc'"
    icon="'assets/images/map_icon_normal.png'"
    idkey="'_id'"
    fit="'false'"
    click="click"
    dorebuildall="true">
        <ui-gmap-windows></ui-gmap-windows>
</ui-gmap-markers>