0
目前我必須按下地圖右上角的地圖來顯示我的當前位置(它是圖片中的小人物),有沒有辦法在地圖加載時自動顯示您的位置?我附上了代碼以及一張照片來解釋。謝謝,我由於缺乏知識而提前道歉。 我希望Mapquest OSM地理位置自動顯示您的當前位置,但它不是?
<html>
<head>
<script src="http://open.mapquestapi.com/sdk/js/v7.0.s/mqa.toolkit.js?key=Kmjtd%7Cluua2qu7n9%2C7a%3Do5-lzbgq"></script>
<script type="text/javascript">
/*An example of using the MQA.EventUtil to hook into the window load event and execute defined function
passed in as the last parameter. You could alternatively create a plain function here and have it
executed whenever you like (e.g. <body onload="yourfunction">).*/
MQA.EventUtil.observe(window, 'load', function() {
/*Create an object for options*/
var options={
elt:document.getElementById('map'), /*ID of element on the page where you want the map added*/
zoom:13, /*initial zoom level of map*/
latLng:{lat:40.735383, lng:-73.984655}, /*center of map in latitude/longitude*/
mtype:'osm' /*map type (osm)*/
};
/*Construct an instance of MQA.TileMap with the options object*/
window.map = new MQA.TileMap(options);
MQA.withModule('geolocationcontrol', function() {
map.addControl(
new MQA.GeolocationControl()
);
});
});
</script>
</head>
<body>
<div id='map' style='width:750px; height:280px;'></div>
</body>
</html>
是否有任何形式的共性,它* *是否居中? –
@andrewBarber它圍繞geolocater提供的位置。如果這是有道理的,如果不是,你的意思是什麼? – user2083920
那麼你現在的代碼有什麼問題? – MaM