http://iclient.supermap.io/examples/leaflet/editor.html#02_getFeatureByBuffer
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title data-i18n="resources.title_getFeatureByBuffer"></title>
<script type="text/javascript" src="../js/include-web.js"></script>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
<script type="text/javascript">
var host = window.isLocal ? window.server : "http://support.supermap.com.cn:8090";
var map, resultLayer,
baseUrl = host + "/iserver/services/map-world/rest/maps/World",
url = host + "/iserver/services/data-world/rest/data";
map = L.map('map', {
preferCanvas: true,
crs: L.CRS.EPSG4326,
center: {lon: 0, lat: 0},
maxZoom: 18,
zoom: 2
});
L.supermap.tiledMapLayer(baseUrl).addTo(map);
query();
function query() {
var polygon = L.polygon([[-20, 20], [0, 20], [0, 40], [-20, 40], [-20, 20]], {color: 'red'});
polygon.addTo(map);
var bufferParam = new SuperMap.GetFeaturesByBufferParameters({
datasetNames: ["World:Capitals"],
bufferDistance: 10,
geometry: polygon
});
L.supermap
.featureService(url)
.getFeaturesByBuffer(bufferParam, function (serviceResult) {
resultLayer = L.geoJSON(serviceResult.result.features, {
onEachFeature: function (feature, layer) {
if(feature.properties.ID == 175){
layer.bindPopup(resources.text_capital+":" + feature.properties.CAPITAL);
}
}
}).addTo(map);
});
}
</script>
</body>
</html>
用网址的范例和这段代码替换源代码,然后测试一下。这个是查询后得到的点,通过判断条件设置某些可以点击生成弹窗或其他效果。如果是自己添加的点也是一样的。对点的属性做判断,然后符合判断条件的添加不同的事件