高亮显示查询到的点
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="./dist/include-openlayers-local.js"></script>
<script src="./libs/gaode.js"></script>
<script src="./libs/Point.js"></script>
</head>
<body>
<button onclick="queryPoint()">固定点查询</button>
<div id="map_container">
</div>
<script>
var docLayer = new Zondy.Map.Doc('', 'xzd_city', {
ip: 'localhost',
port: 6163
})
var map = new ol.Map({
target: "map_container",
layers: [gaode],
view: new ol.View({
projection: 'EPSG:4326',
center: [114.30, 30.50],
zoom: 4
})
})
map.addLayer(docLayer)
function queryPoint() {
map.on("click", e => {
var position = e.coordinate;
console.log(position)
Point.query({
position,
service: {
name: "xzd_city",
layerId: 2
},
successCallback: onSuccess
})
})
}
var source = new ol.source.Vector({wrapX:false});
var layer = new ol.layer.Vector({
source
})
layer.setStyle(
new ol.style.Style({
image:new ol.style.Circle({
radius:12,
fill:new ol.style.Fill({
color:"#333"
})
})
})
)
map.addLayer(layer)
function onSuccess(res) {
var format = new Zondy.Format.PolygonJSON();
//将MapGIS要素JSON反序列化为ol.Feature类型数组
var features = format.read(res);
console.log(features)
if(features){
source.addFeatures(features)
console.log(source)
}
}
</script>
</body>
</html>