gpt4 book ai didi

javascript - Angular 贴图 : Unable to get gMarker from markersScope

转载 作者:行者123 更新时间:2023-12-02 16:21:06 25 4
gpt4 key购买 nike

尝试添加 infoWindows 时,我收到 Unable to get gMarker frommarkerScope! (在 Angular map 中: https://github.com/angular-ui/angular-google-maps/blob/master/src/coffee/directives/api/models/parent/windows-parent-model.coffee#L146 )。窗口确实会显示,但更新时行为不稳定。

每次用户单击一部电影时,infoWindows 都应使用该电影标记处的该电影的信息进行更新。它有时有效,有时信息窗口消失,有时标记也消失。我得到的唯一错误是上面的错误。

Controller 和 View 代码:

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>

最佳答案

我在指令 coords="'self'"中遇到了类似的问题,但标记设置为坐标:{latitude:xxxx,longitude:xxxxx}

因为您的 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'
}

关于javascript - Angular 贴图 : Unable to get gMarker from markersScope,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28126778/

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