地理位置标题>
html、正文、#map-canvas {
边距:0;
填充:0;
高度:100%;
}
风格>
https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false">>
var 映射;
var 聚;
函数初始化() {
var myLatlng = new google.maps.LatLng(31.1937077, 121.4158436);
var 位置 = [
['测试1,精度:150m', 31.1937077, 121.4158436, 100],
['测试2,精度:150m', 31.2937077, 121.4158436, 100],
['测试3,精度:150m', 31.0937077, 121.2158436, 100],
['测试4,精度:150m', 31.3937077, 120.4158436, 100],
['测试5,精度:150m', 31.1637077, 120.4858436, 100],
['测试6,精度:150m', 31.1037077, 121.5158436, 100]
];
var mapOptions = {
缩放:13,
中心:myLatlng,
地图类型 ID:google.maps.MapTypeId.ROADMAP
};
地图 = new google.maps.Map(document.getElementById('map-canvas'),
地图选项);
// 线条设置
var polyOptions = {
strokeColor: '#00ff00', // 颜色
描边不透明度: 1.0, // 透明度
strokeWeight: 4 // 宽度
}
poly = new google.maps.Polyline(polyOptions);
聚.setMap(地图); // 装载
/* 循环标出所有坐标 */
/*for(var i=0; i
var loc = [];
loc.push(locations[i][1]);
loc.push(locations[i][2]);
var 路径 = poly.getPath(); //获取线条的坐标
path.push(new google.maps.LatLng(loc[0], loc[1])); //为线条添加标记坐标
// 生成标记图标
标记 = new google.maps.Marker({
位置: new google.maps.LatLng(loc[0], loc[1]),
地图:地图
// 图标: "
https://maps.gstatic.com/mapfiles/markers/marker_green.png"
});
}*/
var 标记,i,圆;
var iwarray = [];
var infoWindow;
var latlngbounds = new google.maps.LatLngBounds();
var iconYellow = new google.maps.MarkerImage("
http://maps.google.com/mapfiles/ms/icons/yellow-dot.png");
for (i = 0; i
var loc = [];
loc.push(locations[i][1]);
loc.push(locations[i][2]);
var 路径 = poly.getPath(); //获取线条的坐标
path.push(new google.maps.LatLng(loc[0], loc[1]));
var latlng = new google.maps.LatLng(locations[i][1],locations[i][2]);
latlngbounds.extend(latlng);
if (locations[i][0].indexOf("[已缓存") == 0 || (locations[i][0].indexOf("[Multiple") == 0 &&locations[i][0]. indexOf("[已缓存") >= 0 )) {
标记 = new google.maps.Marker({
position: latlng,
map: map,
icon: iconYellow
});
var iw = '
' + locations[i][0] + '';
} else {
marker = new google.maps.Marker({
position: latlng,
map: map
});
var iw = '
' + locations[i][0] + '';
}
iwarray[i] = iw;
google.maps.event.addListener(marker, 'mouseover', (function(marker,i){
return function(){
infoWindow = new google.maps.InfoWindow({
content: iwarray[i],
maxWidth: 200,
pixelOffset: new google.maps.Size(0, 0)
});
infoWindow.open(map, marker);
}
})(marker,i));
google.maps.event.addListener(marker, 'mouseout', function() {
infoWindow.close();
});
circle = new google.maps.Circle({
map: map,
radius: locations[i][3],
fillColor: '#0000AA',
fillOpacity: 0.01,
strokeWeight: 1,
strokeColor: '#0000CC',
strokeOpacity: 0.8
});
circle.bindTo('center', marker, 'position');
}
map.fitBounds(latlngbounds);
var listener = google.maps.event.addListenerOnce(map, "idle", function()
{
var zoomLevel = parseInt(map.getZoom());
if (zoomLevel > 13)
map.setZoom(13);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
身体>
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn