<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<title>跨日期线绘制</title>
<link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css"/>
<style>
html, body, #container {
height: 100%;
width: 100%;
}
.amap-icon img {
width: 25px;
height: 34px;
}
</style>
</head>
<body>
<div id="container"></div>
<script type="text/javascript"
src="https://webapi.amap.com/maps?v=1.4.15&key=您申请的key值"></script>
<script type="text/javascript">
// 创建地图实例
var map = new AMap.Map('container', {
zoom: 3,
center: [180, 40],
viewMode: '3D',
});
var arr = []; //经纬度坐标数组
arr.push(new AMap.LngLat(116.39, 39.9, true));
arr.push(new AMap.LngLat(238.25, 37.48, true));
var polyline = new AMap.Polyline({
path: arr,
geodesic: true,
lineJoin: 'round',
showDir: true,
dirColor: 'white',
strokeColor: '#29b6f6',
outlineColor: 'white',
isOutline: true,
strokeWeight: 6.0,
zIndex: 2
});
var marker1 = new AMap.Marker({
position: arr[0],
icon: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
offset: new AMap.Pixel(-13, -30)
});
var marker2 = new AMap.Marker({
position: arr[1],
icon: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-red.png',
offset: new AMap.Pixel(-13, -30)
});
var arr = []; //经纬度坐标数组
arr.push(new AMap.LngLat(116.39, 27.48, true));
arr.push(new AMap.LngLat(238.25, 27.48, true));
arr.push(new AMap.LngLat(228.25, 37.48, true));
arr.push(new AMap.LngLat(126.39, 37.48, true));
var polygon = new AMap.Polygon({
path: arr,
fillColor: '#0277bd',
zIndex: 80,
strokeColor: 'white',
});
var primeMeridianArr = [];
primeMeridianArr.push(new AMap.LngLat(180, 90, true));
primeMeridianArr.push(new AMap.LngLat(180, -90, true));
// 东经 180 度分割线
var primeMeridian = new AMap.Polyline({
path: primeMeridianArr,
geodesic: true,
lineJoin: 'round',
strokeColor: 'red',
strokeWeight: 1.0,
zIndex: 1
});
map.add([primeMeridian, polyline, polygon, marker1, marker2])
</script>
</body>
</html>
订阅评论
0 评论
最旧