javascript - 如何在 vue.js 项目中的谷歌地图上添加多个圆圈
问题描述
这是我加载谷歌地图的代码
<gmap-map
:center="center"
:zoom="8"
style="width:100%; height: 400px;"
>
<gmap-marker
:key="index"
v-for="(m, index) in myLatLng"
:position="m.position"
:icon="require('./../../../../assets/tower.png')"
></gmap-marker>
<gmap-circle
:key="index"
v-for="(pin, index) in myLatLng"
:center="myLatLng.position"
:radius="3000"
:visible="true"
:options="{fillOpacity:0.5,strokeWeight: 0.5
}"
>
</gmap-circle>
</gmap-map>
这是一个“myLatLng”对象,
myLatLng: [
{position: { lat:6.0535185, lng:80.2209773 }},
{position: { lat:6.2036027, lng:80.4764655 }},
{position: { lat:6.296856600000001, lng:81.2357613}},
]
但我运行项目这些圆圈在地图上不可见。我想显示三个圆圈,使用“myLating”位置作为圆圈的中心点。我如何解决这个问题?
解决方案
也许你需要改变这个:
<gmap-circle
:key="index"
v-for="(pin, index) in myLatLng"
:center="myLatLng.position"
:radius="3000"
:visible="true"
:options="{fillOpacity:0.5,strokeWeight: 0.5">
</gmap-circle>
对此:
<gmap-circle
v-for="(pin, index) in myLatLng"
:key="index+'circle'"
:center="pin.position"
:radius="3000"
:visible="true"
:options="{fillOpacity:0.5,strokeWeight: 0.5}">
</gmap-circle>
问题是:center="myLatLng.position"
推荐阅读
- typescript - 如何使用泛型按名称获取属性的类型
- react-native - Expo:仅在控制台中禁用黄色警告
- java - STOMP 在后端 Java Springboot 上接收空值
- java - 您可以使用增强的 for 每个循环将元素添加到数组中吗?
- html - 角度绑定到选择标签表 - 如何获取值?
- reactjs - 在 React 中从另一个文件导入 html 作为 jsx
- java - Java 异常:java.version 字符串的长度低于 2:10
- c# - 将 PropertyGroup 添加到 csProj C#
- javascript - 如何从文档和窗口中删除 JavaScript 触摸事件处理程序?
- python - 如何实时获取 QLineEdit 文本光标位置