如何将ESRI街道地图(https://leaflet-extras.github.io/leaflet-providers/preview/#filter=Esri.WorldStreetMap)整合到我的传单javascript中。以下是我所做的,但地图没有加载。
<script src="https://unpkg.com/esri-leaflet@2.0.6"></script>
<script> var map = L.map('map1').setView([48.135, 11.582], 3);
L.esri.basemapLayer('Streets').addTo(map);
L.tileLayer('http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map /MapServer/tile/{z}/{y}/{x}', {
attribution: 'Tiles © Esri — Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012'}).addTO(map);
答案 0 :(得分:3)
你正在混合两种完全不同的加载相同平铺地图服务的技术。
当您使用esri leaflet插件时,您只需按名称提及Esri底图。当用户自动平移和缩放时,Leaflet的归属控制将自动填充,并识别区域内的数据提供者。
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.2/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.0.2"></script>
<script src="https://unpkg.com/esri-leaflet@2.0.6"></script>
<script>
var map = L.map("map").setView([37.75, -122.23], 10);
L.esri.basemapLayer('Streets').addTo(map);
</script>
第二种技术是使用Leaflet自己的TileLayer类来加载Esri底图。你自己尝试了一个拼写错误,但它肯定有效地手动引用服务URL并跳过使用插件。
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.2/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.0.2"></script>
<script>
var map = L.map("map").setView([37.75, -122.23], 10);
var serviceUrl = 'http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}';
var credits = 'Tiles © Esri — Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012 etc. etc. etc.';
// not addTO(map)
L.tileLayer(serviceUrl, { attribution: credits }).addTo(map);
</script>
无论您采用哪种方法,Esri在Leaflet应用程序中显示ArcGIS Online服务时都会two requirements
- 您需要一个(免费)ArcGIS Online帐户。
- 您必须显示“由Esri提供支持”和识别所有数据提供商。
醇>