如何以角度在页面上创建多个传单地图

问题描述

我制作了下面给出的传单公开街道地图。

.component.ts

targetSdkVersion 29

我已将地图放置在 html 页面中,如下所示

.component.html

 map = L.map('map').setView([12.876,80.599],12);  

    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{
      attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
    }).addTo(map);

并提到css中的高度

.component.css

<div class ="row">
<div class="col-xs-12 col-sm-8 col-lg-7">
    <div id="map"></div>
  </div>
</div>

现在我想在页面中创建两个地图,我尝试过但无法创建地图,因为我使用了名称地图的id。

那么如何将 id 值(映射)更改为类,而不是我将使用该类在 页

解决方法

我可能会使用相同的 L.map 实例,并对其进行必要的更改。 另一种方法是创建另一个具有不同 ID 的 DOM,并使用 [hide] 来显示第一张或第二张地图。