0
我正在玩Firefox插件無處不在。我正在嘗試在預覽頁面上放置一個自定義Google地圖。該頁面應包含以下內容:將自定義地圖添加到Firefox Ubiquity插件
<html>
<head>
<title>Google Maps Multiple Markers</title>
<script src="https://maps.googleapis.com/maps/api/js?key=MY_KEY" type="text/javascript"></script>
</head>
<body>
<div id="map" style="height: 400px; width: 500px;"></div>
<script type="text/javascript">
var locations = ['Bondi Beach', 'Coogee Beach', 'Cronulla Beach', 'Manly Beach', 'Maroubra Beach'];
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: new google.maps.LatLng(-33.92, 151.25),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var marker, i;
var geocoder = new google.maps.Geocoder();
for (i = 0; i < locations.length; i++) {
console.log("coding " + locations[i]);
geocoder.geocode({'address': locations[i].toLowerCase()}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
</script>
</body>
</html>
但locations
變量應該由輸入設置。這個想法是讓用戶映射多個位置(這個功能曾經存在,我試圖重新制作它)。我試過簡單地設置pblock.innerHTML
,但似乎它得到輸入,沒有出現。我試過逆向工程的默認map
命令的功能,但我不明白它是如何工作的。