<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link href="mapfiles/css/default.css" rel="stylesheet" type="text/css" />
<title>Google Maps JavaScript API v3 Example: Map Simple</title>
<!--script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script-->
<script type="text/javascript" src="mapapi3.8.6.js"></script>
<script type="text/javascript">
function LocalMapType() {}
LocalMapType.prototype.tileSize = new google.maps.Size(256, 256);
LocalMapType.prototype.maxZoom = 5; //地图显示最大级别
LocalMapType.prototype.minZoom = 1; //地图显示最小级别
LocalMapType.prototype.name = "本地数据";
LocalMapType.prototype.alt = "显示本地地图数据";
LocalMapType.prototype.getTile = function(coord, zoom, ownerDocument) {
var img = ownerDocument.createElement("img");
img.style.width = this.tileSize.width + "px";
img.style.height = this.tileSize.height + "px";
//地图存放路径
//谷歌矢量图 maptile/googlemaps/roadmap
//谷歌影像图 maptile/googlemaps/roadmap
//MapABC地图 maptile/mapabc/
var strURL = "C:/GoogleOutLine/maptile/GoogleMap/";
strURL += zoom + "/" + coord.x + "/" + coord.y + ".PNG";
img.src = strURL;
return img;
};
var localMapType = new LocalMapType();
var map;
var GlightPath;
function initialize() {
var myLatlng = new google.maps.LatLng(43.913461,125.3284);
//var myLatlng = new google.maps.LatLng(43.90775,125.32140);
var myOptions = {
center: myLatlng,
zoom: 1,
streetViewControl: false,
mapTypeControlOptions: {
mapTypeIds: [
google.maps.MapTypeId.ROADMAP,
google.maps.MapTypeId.HYBRID,
google.maps.MapTypeId.SATELLITE,
google.maps.MapTypeId.TERRAIN,
'locaMap' ] //定义地图类型
}
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
map.mapTypes.set('locaMap', localMapType); //绑定本地地图类型
map.setMapTypeId('locaMap'); //指定显示本地地图
//画marker
//var markerOptions = new google.maps.MarkerOptions({draggable:true});
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
draggable:true,
title:"北京!"
});
var infowindow = new google.maps.InfoWindow(
{ content:"latlng:" + marker.getPosition().toString(),
size: new google.maps.Size(70,70)
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent("latlng:" + marker.getPosition().toUrlValue(6));
infowindow.open(map,marker);
});
//google.maps.event.addListener(map,'click', function(event) {
// var arr2 = "43.913461|125.3284|43.913477|125.327969|43.912773|125.32801|43.911688|125.326523|43.91063|125.325255|43.910795|125.324973|43.91073|125.324661|43.911656|125.323796|43.912749|125.323656|43.913018|125.323706|43.915401|125.323587|43.919503|125.323561|43.935609|125.324079|43.942849|125.324195|43.94299|125.324135|43.949314|125.307014|43.94002|125.300655|43.940234|125.300374|43.943422|125.300567|43.943474|125.300447|43.943591|125.2927|43.94361|125.287182|43.943568|125.284114";
// DrowRoute(arr2);
//});
}
function Point() {
this.Lng = 0;
this.Lat = 0;
}
function DrowRoute(pointsStr){
var tempPoint= new Array();
tempPoint = pointsStr.split("|");
var GRoutePoints;
GRoutePoints = null;
GRoutePoints = new Array(tempPoint.length/2);
for(var i = 0; i < tempPoint.length; i = i+2) {
GRoutePoints[i/2] = new google.maps.LatLng(tempPoint[i],tempPoint[i+1]);
}
GlightPath = new google.maps.Polyline({
path: GRoutePoints,
strokeColor: "#007FFF",
strokeOpacity: 0.8,
strokeWeight: 4
});
GlightPath.setMap(map);
}
function ClearRoute(){
GlightPath.setMap(null);
GlightPath = null;
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas"></div>
</body>
</html>