對於一個小的學校項目在谷歌地圖座標的列表我需要的東西完全一樣擺弄顯示使用地理定位在HTML5
所以我創建了一個HTML文件的test.html並添加所有小提琴的代碼如下。但是當我在瀏覽器中打開html頁面時,我沒有得到任何輸出。我該如何做這項工作?提前致謝。
<div id="map"></div>
<script>
var map;
var elevator;
var myOptions = {
zoom: 12,
center: new google.maps.LatLng(-33.950198, 151.259302),
mapTypeId: 'terrain'
};
map = new google.maps.Map($('#map')[0], myOptions);
var markers = [];
var beaches = [
['Bondi Beach', -33.890542, 151.274856, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];
var bounds = new google.maps.LatLngBounds();
for (x in beaches) {
var data = beaches[x];
console.log(data)
var lat = beaches[x][1];
var lng = beaches[x][2]
var latLng = new google.maps.LatLng(lat, lng);
var marker = new google.maps.Marker({
map: map,
position: latLng
});
markers.push(marker);
bounds.extend(latLng);
}
map.fitBounds(bounds)
new google.maps.Rectangle({
bounds: bounds,
fillColor: '#000000',
map: map
})
var centerBounds = new google.maps.Marker({
map: map,
position: bounds.getCenter(),
icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=C|FF0000|000000'
});
</script>
在控制檯中拋出什麼錯誤? – charlietfl 2014-10-28 15:43:41
ReferenceError:google沒有定義 – asdfkjasdfjk 2014-10-28 15:47:20
您是否包含庫腳本? ...谷歌地圖一個jQuery – charlietfl 2014-10-28 15:48:42