简单的 Leaflet + Mapbox TitleLayer 有问题吗?
Problems with simple Leaflet + Mapbox TitleLayer?
我对 GIS 完全陌生,我想我会从传单开始 quick tutorial。但是,我在使用 Mapbox 添加基础图块层时遇到了问题。到目前为止,这是我的代码:
<!DOCTYPE html>
<html lang='en'>
<head>
<title>Agricultural Trade Patterns</title>
<meta charset='utf-8' />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
</head>
<body>
<div id="map" style="width: 600px; height: 600px"></div>
<script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
<script>
//initialize the map
var map = L.map('map').setView([41.854501, -87.715496],13);
L.titleLayer('https://api.mapbox.com/page.html?access_token=', {
maxZoom:18,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
id: '',
accessToken: ''
}).addTo(map);
map.on('click', onMapClick);
</script>
</body>
我尽量按照教程进行操作,但每次测试时都会收到错误消息:
TypeError: L.titleLayer is not a function
而且我不明白为什么。我是否将错误的参数传递给 tileLayer?我知道我的 URL 模板没有传单教程中的格式,但我在任何地方都找不到那样的 png url?那是问题所在吗?抱歉,如果这是一个简单的问题,我对这些东西完全陌生。
在此先感谢您的帮助!
没有L.TitleLayer
这样的东西。它被称为 L.TileLayer
:
我对 GIS 完全陌生,我想我会从传单开始 quick tutorial。但是,我在使用 Mapbox 添加基础图块层时遇到了问题。到目前为止,这是我的代码:
<!DOCTYPE html>
<html lang='en'>
<head>
<title>Agricultural Trade Patterns</title>
<meta charset='utf-8' />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
</head>
<body>
<div id="map" style="width: 600px; height: 600px"></div>
<script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
<script>
//initialize the map
var map = L.map('map').setView([41.854501, -87.715496],13);
L.titleLayer('https://api.mapbox.com/page.html?access_token=', {
maxZoom:18,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
id: '',
accessToken: ''
}).addTo(map);
map.on('click', onMapClick);
</script>
</body>
我尽量按照教程进行操作,但每次测试时都会收到错误消息:
TypeError: L.titleLayer is not a function
而且我不明白为什么。我是否将错误的参数传递给 tileLayer?我知道我的 URL 模板没有传单教程中的格式,但我在任何地方都找不到那样的 png url?那是问题所在吗?抱歉,如果这是一个简单的问题,我对这些东西完全陌生。
在此先感谢您的帮助!
没有L.TitleLayer
这样的东西。它被称为 L.TileLayer
: