我的宣传单地图上的移动GPS

时间:2017-07-20 11:50:32

标签: gps leaflet

我的传单地图上的GPS信号地图有些问题。我现在有一张没有GPS信号的地图。我尝试从leaflet.com的教程中复制代码行,但它不起作用:(

任何人都可以帮助我吗?



<!DOCTYPE html>
<html>
<head>
	
	<title>Layers Control Tutorial - Leaflet</title>

	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	
	<link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />

    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.1.0/dist/leaflet.css" integrity="sha512-wcw6ts8Anuw10Mzh9Ytw4pylW8+NAD4ch3lqm9lzAsTxg0GFeJgoAtxuCLREZSC5lUXdVyo/7yfsqFjQ4S+aKw==" crossorigin=""/>
    <script src="https://unpkg.com/leaflet@1.1.0/dist/leaflet.js" integrity="sha512-mNqn2Wg7tSToJhvHcqfzLMU6J4mkOImSPTxVZAdo+lcPlk+GhZmYgACEe0x35K7YzW1zJ7XyJV/TT1MrdXvMcA==" crossorigin=""></script>


	<style>
		#map {
			width: 600px;
			height: 400px;
		}
	</style>

	
</head>
<body>

<div id='map'></div>

<script>
	var citie = L.layerGroup();

	L.marker([52.524491, 13.192954]).bindPopup('This is Littleton, CO.').addTo(citie),
	L.marker([52.524273, 13.196197]).bindPopup('This is Denver, CO.').addTo(citie),
	L.marker([52.525986, 13.196685]).bindPopup('This is Aurora, CO.').addTo(citie),
	L.marker([52.529328, 13.195698]).bindPopup('This is Golden, CO.').addTo(citie);
	L.marker([52.527820, 13.195513]).bindPopup('This is Golden, CO.').addTo(citie);
	
	var um = L.layerGroup();
	
	L.marker([52.526729, 13.194802]).bindPopup('This is Golden, CO.').addTo(um);
	
	var mbAttr = 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
			'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
			'Imagery © <a href="http://mapbox.com">Mapbox</a>',
		mbUrl = 'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw';

	var grayscale   = L.tileLayer(mbUrl, {id: 'mapbox.light', attribution: mbAttr}),
		streets  = L.tileLayer(mbUrl, {id: 'mapbox.streets',   attribution: mbAttr});

	var map = L.map('map', {
		center: [52.526273, 13.194531],
		zoom: 10,
		layers: [grayscale, citie]
	});

	var baseLayers = {
		"Grayscale": grayscale,
		"Streets": streets
	};

	var overlays = {
		"Haltestellenaufhebungen": citie,
     	"test": um,
	     
	};


	L.control.layers(baseLayers, overlays).addTo(map);

</script>
</body>
</html>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:0)

GPS信号问题是什么意思?是因为标记不在他们所需要的城市吗? 这个例子https://jsfiddle.net/4mg1v8qh/对你有好处吗?如果是,只需修改标记的位置即可 Doc是here

L.marker([39.613321, -105.016650]).bindPopup('This is Littleton, CO.').addTo(citie),
L.marker([39.739236, -104.990251]).bindPopup('This is Denver, CO.').addTo(citie),
L.marker([39.729431, -104.831919]).bindPopup('This is Aurora, CO.').addTo(citie),

答案 1 :(得分:0)

没有标记是正确的。我现在想要一个移动版的Map。如果你打开地图,GPS位置会显示在我的地图上,你在哪里。我尝试从示例中复制代码行,但它不起作用。

我的地图现在是电脑版