huaxia/htmls/artNetwork/goMap.html

57 lines
2.0 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Cache-Control" content="no-store" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<title>目的地</title>
<script src="https://webapi.amap.com/maps?v=1.4.14&amp;key=4d81136d607c68fb6c906599c0bd1de1&amp;plugin=AMap.Autocomplete,AMap.Geocoder"></script>
<script src="../../js/jquery-1.9.1.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="container" style="width: 600px;height: 600px;"></div>
<script>
function getUrlParamCN(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
var r = decodeURI(window.location.search).substr(1).match(reg); //匹配目标参数
if (r != null) return unescape(r[2]); return null; //返回参数值
}
var lng = getUrlParamCN("lng").split('\'')[1]
var lat = getUrlParamCN("lat").split('\'')[1]
//初始化地图
var map = new AMap.Map('container', {
resizeEnable: true, //是否监控地图容器尺寸变化
zoom: 18, //初始地图级别
center: [lng,lat] //设置地图中心点坐标
});
var marker, lnglat;
lnglat = [lng,lat]
var img = '../../img/public/dwionv.png'
var marker = new AMap.Marker({
position: new AMap.LngLat(lng,lat),
offset: new AMap.Pixel(-20, -40),
icon: img, // 添加 Icon 图标 URL
title: '',
draggable: true //点标记可拖拽
});
map.add(marker);
map.on('click', function(e) {
lnglat = e.lnglat;
marker.setPosition(lnglat);
})
</script>
<div class="Ditumap">
<div style="border:none;" id="BaiduDitu"></div>
<script type="text/javascript">
window.onload = function(){
var w_height = $(window).height()
var w_width = $(window).width()
var html = document.getElementById('container')
html.style.height = w_height+'px'
html.style.width = w_width+'px'
}
</script>
</div>
</body>
</html>