javascript - 如何在传单和vue中绘制箭头
问题描述
我正在制作一个使用 vue-2-leaflet 的应用程序,我需要生成指向其他标记的箭头。现在,我只需要能够在地图上画一个箭头。我稍后可以指点箭头。任何帮助,将不胜感激。
这是我现在的代码
<template>
<div class="containerTest">
<p
:key="index"
v-for="(brew, index) in markers"
:lat-lng="latLng(brew.latitude, brew.longitude)"
>{{brew.latitude}}</p>
<div style="height: 80vh">
<LMap :zoom="zoom" :center="center">
<LTileLayer :url="url"></LTileLayer>
<l-marker
:key="index"
v-for="(brew, index) in markers"
:lat-lng="latLng(brew.latitude, brew.longitude)"
></l-marker>
</LMap>
</div>
</div>
</template>
<script>
import { LMap, LTileLayer, LMarker } from "vue2-leaflet";
export default {
name: "Map",
components: {
LMap,
LTileLayer,
LMarker
},
data() {
return {
markers: [],
url: "https://api.maptiler.com/maps/streets/{z}/{x}/{y}.png?key=CFmlXsYmVozAdWKEtdT5",
zoom: 6,
center: [46.5322, 2.9482],
bounds: null
};
},
mounted: function () {
//get the brewery data
fetch('https://api.openbrewerydb.org/breweries?by_city=san_diego').then((response) => {
return response.json();
}).then(json=>{
this.markers = json.filter(r => r.latitude != null)
console.log(this.markers.filter(r => r.latitude != null))
})
},
methods: {
latLng: function(lat, lng) {
return L.latLng(lat,lng);
},
}
};
</script>
解决方案
推荐阅读
- c++ - Omnet++ 需要有关延迟的统计信息
- asp.net-core - 在 ASP.NET Core 中设置 CORS 以允许没有身份验证的通配符来源和具有身份验证的白名单域
- javascript - 使用 JavaScript(Oracle APEX 交互式网格)从页面项中设置列值
- python - 在 Windows 上使用 Python/Django 运行服务器时,是否可以使用自定义测试 url 进行测试?
- chainlink - 如何合并两个api以进行chainlink适配器调用
- javascript - 为所有文档自动加载和启动 Office-js 加载项的运行时
- spell-checking - 页面上的多语言拼写检查
- c# - 我应该在调用异步方法的方法中返回 ValueTask 还是 Task
- jquery - 使用 jQuery 弹跳球/颜色变化动画
- flutter - Flutter:当变量更改而不在每个页面上调用它时,如何使其在整个应用程序中显示“请验证”页面?