更改LeafJet tile图层位置

问题描述 投票:0回答:1

我在我的应用程序中使用WebView来显示LeafJet地图。

在HTML文件中,我具有以下信用和链接:

L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
                maxZoom: 18,
                attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
                '<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
                'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
                id: 'mapbox.streets'
                }).addTo(mymap);

看起来像这样:

enter image description here

例如,是否可以将tileLayer放置在左上角而不是右下角?

谢谢

html leaflet
1个回答
0
投票

当然,您可以控制地图上的所有内容;)

let map = L.map('map', {
  attributionControl: false
}).setView([51.505, -0.09], 13);

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


L.control.attribution({
  position: 'topright'
}).addTo(map);
body {
  height: 100%;
  margin: 0;
}

#map {
  width: 100%;
  height: 100%;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.5.1/leaflet.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.5.1/leaflet.css">

<div id="map"></div>
© www.soinside.com 2019 - 2024. All rights reserved.