<html>
<head>
<script src="${}/jquery/jquery-2.1.1.min.js" type="text/javascript"></script>
<script src="${}/layer-v2.3/layer/layer.js" type="text/javascript" ></script>
<script src="${}/map/mapfiles/map.js" type="text/javascript" ></script>
<script type="text/javascript">
$(document).ready(function(){
createMap("map_canvas",36.26613281490336,120.26979816083906);
google.maps.event.addListener(map, 'click', function(event) {
placeMarker(event.latLng);
});
});
//获取点坐标
var markersArray = [];
var strLocation;
function placeMarker(location) {
if (markersArray) {
for (i in markersArray) {
markersArray[i].setMap(null);
}
markersArray.length = 0;
}
marker = new google.maps.Marker({
position: location,
map: map
});
markersArray.push(marker);
strLocation = location.lat().toString() + "," + location.lng().toString();
console.log(strLocation);
}
</script>
</head>
<body>
<div id="map_canvas" style="width: 1150px; height: 600px; margin: 0; padding: 0; position: absolute;"></div>
</body>
</html>
map.js 插件
function createMap(mapId,lat,lng){
var myLatlng = new google.maps.LatLng(lat,lng);
var myOptions = {
center : myLatlng,
zoom : 15,
streetViewControl : false,
mapTypeControlOptions : {
mapTypeIds : ['locaMap'] //定义地图类型
}
};
map = new google.maps.Map(document.getElementById(mapId), myOptions);
var localMapType = new google.maps.ImageMapType({
getTileUrl : function(coord, zoom) {
var url = "/gtg/static/map/tiles/" + zoom + "/" + coord.x + "/" + coord.y + ".png"
return url;
},
tileSize : new google.maps.Size(256, 256),
maxZoom : 17,
minZoom : 14,
name : '青岛高新区'
});
map.mapTypes.set('locaMap', localMapType); //绑定本地地图类型
map.setMapTypeId('locaMap'); //指定显示本地地图
}
window.google = window.google || {};
google.maps = google.maps || {};
(function() {
function getScript(src) {
document.write('<' + 'script src="' + src + '"' +
' type="text/javascript"><' + '/script>');
}
var modules = google.maps.modules = {};
google.maps.__gjsload__ = function(name, text) {
modules[name] = text;
};
google.maps.Load = function(apiLoad) {
delete google.maps.Load;
apiLoad([0.009999999776482582,[[["http://mt0.google.cn/vt?lyrs=m@160000000\u0026hl=zh-CN\u0026gl=CN\u0026","http://mt1.google.cn/vt?lyrs=m@160000000\u0026hl=zh-CN\u0026gl=CN\u0026"],null,null,null,null,"m@255000000",["https://mts0.google.com/vt?lyrs=m@255000000\u0026src=api\u0026hl=zh-CN\u0026gl=CN\u0026","https://mts1.google.com/vt?lyrs=m@255000000\u0026src=api\u0026hl=zh-CN\u0026gl=CN\u0026"]],[["http://mt0.google.cn/vt?lyrs=s@145\u0026hl=zh-CN\u0026gl=CN\u0026","http://mt1.google.cn/vt?lyrs=s@145\u0026hl=zh-CN\u0026gl=CN\u0026"],null,null,null,1,"145",["https://khms0.google.com/kh?v=145\u0026hl=zh-CN\u0026gl=CN\u0026","https://khms1.google.com/kh?v=145\u0026hl=zh-CN\u0026gl=CN\u0026"]],[["http://mt0.google.cn/vt?imgtp=png32\u0026lyrs=h@160000000\u0026hl=zh-CN\u0026gl=CN\u0026","http://mt1.google.cn/vt?imgtp=png32\u0026lyrs=h@160000000\u0026hl=zh-CN\u0026gl=CN\u0026"],null,null,null,null,"h@255000000",["https://mts0.google.com/vt?lyrs=h@255000000\u0026src=api\u0026hl=zh-CN\u0026gl=CN\u0026","https://mts1.google.com/vt?lyrs=h@255000000\u0026src=api\u0026hl=zh-CN\u0026gl=CN\u0026"]],[["http://mt0.google.cn/vt?lyrs=t@127,r@160000000\u0026hl=zh-CN\u0026gl=CN\u0026","http://mt1.google.cn/vt?lyrs=t@127,r@160000000\u0026hl=zh-CN\u0026gl=CN\u0026"],null,null,null,null,"t@132,r@255000000",["https://mts0.google.com/vt?lyrs=t@132,r@255000000\u0026src=api\u0026hl=zh-CN\u0026gl=CN\u0026","https://mts1.google.com/vt?lyrs=t@132,r@255000000\u0026src=api\u0026hl=zh-CN\u0026gl=CN\u0026"]],null,null,[["http://cbk0.googleapis.com/cbk?","http://cbk1.googleapis.com/cbk?"]],[["http://khm0.googleapis.com/kh?v=84\u0026hl=zh-CN\u0026gl=CN\u0026","http://khm1.googleapis.com/kh?v=84\u0026hl=zh-CN\u0026gl=CN\u0026"],null,null,null,null,"84",["https://khms0.google.com/kh?v=84\u0026hl=zh-CN\u0026gl=CN\u0026","https://khms1.google.com/kh?v=84\u0026hl=zh-CN\u0026gl=CN\u0026"]],[["http://mt0.googleapis.com/mapslt?hl=zh-CN\u0026gl=CN\u0026","http://mt1.googleapis.com/mapslt?hl=zh-CN\u0026gl=CN\u0026"]],[["http://mt0.googleapis.com/mapslt/ft?hl=zh-CN\u0026gl=CN\u0026","http://mt1.googleapis.com/mapslt/ft?hl=zh-CN\u0026gl=CN\u0026"]],[["http://mt0.googleapis.com/vt?hl=zh-CN\u0026gl=CN\u0026","http://mt1.googleapis.com/vt?hl=zh-CN\u0026gl=CN\u0026"]],[["http://mt0.googleapis.com/mapslt/loom?hl=zh-CN\u0026gl=CN\u0026","http://mt1.googleapis.com/mapslt/loom?hl=zh-CN\u0026gl=CN\u0026"]],[["https://mts0.googleapis.com/mapslt?hl=zh-CN\u0026gl=CN\u0026","https://mts1.googleapis.com/mapslt?hl=zh-CN\u0026gl=CN\u0026"]],[["https://mts0.googleapis.com/mapslt/ft?hl=zh-CN\u0026gl=CN\u0026","https://mts1.googleapis.com/mapslt/ft?hl=zh-CN\u0026gl=CN\u0026"]],[["https://mts0.googleapis.com/mapslt/loom?hl=zh-CN\u0026gl=CN\u0026","https://mts1.googleapis.com/mapslt/loom?hl=zh-CN\u0026gl=CN\u0026"]]],["zh-CN","CN",null,0,null,null,"/gtg/static/map/mapfiles/","http://csi.gstatic.com","https://maps.googleapis.com","http://maps.googleapis.com"],["/gtg/static/map/mapfiles/api-3/16/2","3.16.2"],[202450162],1,null,null,null,null,0,"",null,null,0,"http://khm.googleapis.com/mz?v=145\u0026",null,"https://earthbuilder.googleapis.com","https://earthbuilder.googleapis.com",null,"/gtg/static/map/mapfiles",[["http://mt0.googleapis.com/vt","http://mt1.googleapis.com/vt"],["https://mts0.googleapis.com/vt","https://mts1.googleapis.com/vt"],[null,[[0,"m",255000000]],[null,"zh-CN","CN",null,18,null,null,null,null,null,null,[[47],[37,[["smartmaps"]]]]],0],[null,[[0,"m",255000000]],[null,"zh-CN","CN",null,18,null,null,null,null,null,null,[[47],[37,[["smartmaps"]]]]],3],[null,[[0,"m",255000000]],[null,"zh-CN","CN",null,18,null,null,null,null,null,null,[[50],[37,[["smartmaps"]]]]],0],[null,[[0,"m",255000000]],[null,"zh-CN","CN",null,18,null,null,null,null,null,null,[[50],[37,[["smartmaps"]]]]],3],[null,[[4,"t",132],[0,"r",132000000]],[null,"zh-CN","CN",null,18,null,null,null,null,null,null,[[5],[37,[["smartmaps"]]]]],0],[null,[[4,"t",132],[0,"r",132000000]],[null,"zh-CN","CN",null,18,null,null,null,null,null,null,[[5],[37,[["smartmaps"]]]]],3],[null,null,[null,"zh-CN","CN",null,18],0],[null,null,[null,"zh-CN","CN",null,18],3],[null,null,[null,"zh-CN","CN",null,18],6],[null,null,[null,"zh-CN","CN",null,18],0],["https://mts0.google.com/vt","https://mts1.google.com/vt"],"/maps/vt"],2,500], loadScriptTime);
};
var loadScriptTime = (new Date).getTime();
getScript("/gtg/static/map/mapfiles/api-3/16/2/main.js");
})();