繁体   English   中英

通过变量设置标记纬度和经度时,Google Map标记不会保持恒定

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

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

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

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

下面是我的代码

<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;
},

记不清可以解决问题的属性的确切作用,但希望对您有所帮助。

暂无
暂无

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

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