【问题标题】:How to rewrite ui-gmap-marker to ui-gmap-markers?如何将 ui-gmap-marker 重写为 ui-gmap-markers?
【发布时间】:2016-02-21 12:19:54
【问题描述】:

我是 Angular 和 uiGmapGoogleMapApi 的新手,我正在尝试重写:

<ui-gmap-google-map center="search.map.center" zoom="search.map.zoom" bounds="search.map.bounds" options="{ overviewMapControl: true, streetViewControl: false, mapTypeControl: false }">
    <locations ng-if="! search.isLoading" ng-repeat="player in search.results track by $index">
        <ui-gmap-marker ng-repeat="item in player.l track by $index" ng-if="item.g" idKey="$index" coords="{ latitude: item.g[0], longitude: item.g[1] }" options="{ labelContent: item.n }">
            <ui-gmap-window>
                <div>
                    <a ng-href="{[{ search.getplayerUrl(player) }]}">{[{ player.n }]}</a>
                    <p>{[{ player.s }]}</p>
                </div>
            </ui-gmap-window>
        </ui-gmap-marker>
    </locations>
</ui-gmap-google-map>

到 ui-gmap-markers。 因为 ui-gmap-marker 和 ng-repeat 的性能很差。 我没有从这一点上取得进展。我没有收到任何错误。

<ui-gmap-google-map center="search.map.center" zoom="search.map.zoom" bounds="search.map.bounds" options="{ overviewMapControl: true, streetViewControl: false, mapTypeControl: false }">
    <locations ng-if="! search.isLoading" ng-repeat="player in search.results track by $index">
        <ui-gmap-markers models="player.l" idKey="id" coords="{ latitude: g[0], longitude: g[1] }" options="{ labelContent: n }" />
        <ui-gmap-window>
            <div>
                <a ng-href="{[{ search.getplayerUrl(player) }]}">{[{ player.n }]}</a>
                <p>{[{ player.s }]}</p>
            </div>
        </ui-gmap-window>
    </locations>
</ui-gmap-google-map>

有谁知道我做错了什么?

【问题讨论】:

    标签: angularjs google-maps-markers angular-google-maps


    【解决方案1】:

    coords 属性必须是字符串。

    The document 说:

    坐标:字符串
    模型数组中包含标记的属性名称 坐标。必须引用包含经纬度的对象 属性,或 GeoJSON Point 对象。

    【讨论】:

    • 我认为这不是问题,旧版本可以正常工作,并且他们对坐标有相同的要求。播放器包含类似"l": [ { "df": 40.0, "g": [ 48.1234567, 19.1234567 ], "l": 3 }, { "l": 2 } ], "m": "/....", "n": "Name"
    • markercoords 属性可以是一个对象。但markers' 必须是字符串。仔细阅读两者之间的区别。
    猜你喜欢
    • 2015-05-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-28
    • 1970-01-01
    • 1970-01-01
    • 2015-01-26
    相关资源
    最近更新 更多