CSS样式表
html, body, #container {
height: 100%
}
.amap-marker-label {
border: 0;
background-color: #FFF;
}
.info >span{
margin: auto 10px;
}
HTML容器
核心代码
//初始化地图对象,加载地图
var map = new AMap.Map("container", {
center: [121.548181, 29.806906],
zoom: 15,
resizeEnable: true,
});
//数据格式化;
var data = "121.546266,29.80975;121.54543,29.806845;121.548713,29.806752;121.549957,29.809508";
var points = data.split(";");
var path = [];
for (var i = 0; i item =="0").length;//外部;
//console.log('内部数量:'+inRing);
document.getElementById("inRing").innerHTML='内部数量:'+inRing;
//console.log('外部数量:'+outRing);
document.getElementById("outRing").innerHTML='外部数量:'+outRing;
//添加标注;
function addMaker(marker) {
var newMaker = new AMap.Marker({
map: map,
//icon: marker.icon,
//draggable: true,
position: [marker.position[0], marker.position[1]],
offset: new AMap.Pixel(-13, -30)
});
return newMaker;
}
//判断是否在围栏内;
function compute(marker) {
var point = marker.getPosition();
var isPointInRing = AMap.GeometryUtil.isPointInRing(point, path);
// label默认蓝框白底左上角显示,样式className为:amap-marker-label
marker.setLabel({
content: isPointInRing ? '内部' : '外部',
offset: new AMap.Pixel(-5, 35)
});
//返回状态,予以统计;
if (isPointInRing == true) {
return 1;
} else {
return 0;
}
}
lockdatav Done !