【问题标题】:how to pass multiple location in leaflet map如何在传单地图中传递多个位置
【发布时间】:2020-05-21 18:17:46
【问题描述】:

我需要使用 vuejs 在传单地图中显示多个标记。而且我还需要更改标记图像,我在下面只为单个制造商提供了代码。

          mounted () {
            //    L.Icon.Default.imagePath = 'assets/vendor/leaflet' TODO: make it work with webpack
            Leaflet.Icon.Default.imagePath = 'https://unpkg.com/leaflet@1.0.3/dist/images'

            let map = Leaflet.map(this.$refs['mapElement']).setView([51.505, -0.09], 13)

            Leaflet.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png', {
              attribution: '&copy; <a href="https://osm.org/copyright">OpenStreetMap</a> contributors',
            }).addTo(map)

            Leaflet.marker([51.5, -0.09]).addTo(map)

              .openPopup()
          },

下面是我的api输出数据

   [[51.4, -0.03],[53.5, -0.39],[52.5, -0.39]]

【问题讨论】:

    标签: javascript google-maps dictionary vue.js leaflet


    【解决方案1】:

    我相信您可以将解决方案 here 与您的 API 输出一起使用。

    var res =  [[51.4, -0.03],[53.5, -0.39],[52.5, -0.39]];
    
    for (var i = 0; i < res.length; i++) {
                marker = new L.marker(res[i])
                    .addTo(map);
            }
    

    希望能回答你的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-08
      • 1970-01-01
      相关资源
      最近更新 更多