谷歌地图标记在通过变量设置标记和经度时不保持不变

Google Map marker not staying constant when setting marker lattitude and longitude via variables

本文关键字:经度 设置 图标 地图 变量 谷歌      更新时间:2023-09-26

在我的地图中,我试图通过{{lattitude}}和{{经度}}变量设置标记

但是,我看到当我通过此变量设置数据时,标记始终停留在屏幕中间。就像缩放或拖动地图时一样,标记的位置会发生变化,并且不会显示正确的地址。

当我对 lattitude和经度的值进行硬编码时,它显示得很好。

下面是我的代码

<google-map latitude="{{lattitude}}" longitude="{{longtitude}}" min-zoom="9" max-zoom="11" language="en">
    <google-map-marker latitude="{{lattitude}}" longitude="{{longtitude}}" title="Go Giants!" draggable="false" drag-events> </google-map-marker>
</google-map>
<script>
</script>
</template>
<script>
    Polymer({
        is: "map-locations",
        properties: {
            lattitude: String,
            longtitude: String,
            title: String
        }
    });
</script>

有人可以帮我解决这个问题吗

以下是我前段时间做过的例子。

当用户在可拖动地图上移动标记位置时,保存标记位置。

当用户在不可拖动的地图上移动标记位置时,保存标记位置。

draggable_map: function() {
           //How to make google-map to fitToMarkers and AGAIN to be draggable?
           //fitToMarkers is conditional attribute, so just disable it after the resize().
           this.fitToMarkers_init = false;
},

不记得可以解决您问题的属性的确切玩法,但希望这会有所帮助。