简体   繁体   English

角度贴图:无法从markersScope获取gMarker

[英]Angular maps: Unable to get gMarker from markersScope

I'm getting Unable to get gMarker from markersScope! Unable to get gMarker from markersScope! (in angular maps: https://github.com/angular-ui/angular-google-maps/blob/master/src/coffee/directives/api/models/parent/windows-parent-model.coffee#L146 ) when trying to add infoWindows. (在角度图中: https//github.com/angular-ui/angular-google-maps/blob/master/src/coffee/directives/api/models/parent/windows-parent-model.coffee#L146 )试图添加infoWindows。 The windows do display, but behave erratically when updated. 窗口会显示,但在更新时表现不正常。

Each time the user clicks on a movie the infoWindows should update with information about that movie at that cinema marker. 每次用户点击电影时,infoWindows都应该在该电影标记处更新有关该电影的信息。 It sometimes works, sometimes the infoWindows disappear and sometimes the markers disappear as well. 它有时会起作用,有时infoWindows会消失,有时标记也会消失。 The only error I get is the one above. 我得到的唯一错误是上面的错误。

Controller and view code: 控制器和视图代码:

var createCinemaMarkers = function(cinemas) {
  $scope.cinemaMarkers = [];
  $scope.cinemaWindows = [];
  for (var i = 0; i < cinemas.length; i++) {

    getMoviesForCinema(cinemas[i].venue_id);

    var map_coords = {
      id: cinemas[i].venue_id,
      title: cinemas[i].title,
      options: {
        title: cinemas[i].title,
        random: 'blah blah blah'
      },
      clickable: true,
      latitude: cinemas[i].coords.lat,
      longitude: cinemas[i].coords.lng,
      icon: 'images/cinema_icons/cinema.png'
    }

    if (!cinemas[i].movieTitle) {
      cinemas[i].movieTitle = '';
    }

    var parameters = {
        movieTitle: cinemas[i].movieTitle,
        movieTimes: cinemas[i].movieTimes,
        stuff: 'from props'
    }

    var infoWindow = {
      id: cinemas[i].venue_id,
      coords: {
        latitude: cinemas[i].coords.lat,
        longitude: cinemas[i].coords.lng
      },
      options: {
        title: "I AM TITLE"
      },
      show: true,
      templateUrl: 'views/info-window.html',
      templateParameter: parameters,
      isIconVisibleOnClick: true,
      closeClick: 'none'
    }

  $scope.cinemaWindows.push(infoWindow);      
  $scope.cinemaMarkers.push(map_coords);
  };
};

    <ui-gmap-google-map center="map.center" zoom="map.zoom" events="mapEvents">
    <ui-gmap-markers models="cinemaMarkers" events="events" options="'options'" coords="'self'" icon="'icon'" fit="'true'"  popover-placement="top" popover="On the Top!">
        <ui-gmap-windows models="cinemaWindows" templateUrl="'templateUrl'" templateParameter="'templateParameter'" options="'options'">
        </ui-gmap-windows>
    </ui-gmap-markers>
</ui-gmap-google-map>

I had a similar problem where in the directive coords="'self'" but markers were set to coords: {latitude:xxxx,longitude:xxxxx} 我有一个类似的问题,在指令coords =“'self'”,但标记被设置为坐标:{纬度:xxxx,经度:xxxxx}

Because your ui-gmap-markers is set to coords="'self'" so try remove coords in infoWindow: 因为你的ui-gmap-markers设置为coords =“'self'”所以请尝试删除infoWindow中的coords

var infoWindow = {
      id: cinemas[i].venue_id,
      latitude: cinemas[i].coords.lat,
      longitude: cinemas[i].coords.lng,
      options: {
        title: "I AM TITLE"
      },
      show: true,
      templateUrl: 'views/info-window.html',
      templateParameter: parameters,
      isIconVisibleOnClick: true,
      closeClick: 'none'
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM