高亮显示查询到的点

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <title>Document</title>
    7. <script src="./dist/include-openlayers-local.js"></script>
    8. <script src="./libs/gaode.js"></script>
    9. <script src="./libs/Point.js"></script>
    10. </head>
    11. <body>
    12. <button onclick="queryPoint()">固定点查询</button>
    13. <div id="map_container">
    14. </div>
    15. <script>
    16. var docLayer = new Zondy.Map.Doc('', 'xzd_city', {
    17. ip: 'localhost',
    18. port: 6163
    19. })
    20. var map = new ol.Map({
    21. target: "map_container",
    22. layers: [gaode],
    23. view: new ol.View({
    24. projection: 'EPSG:4326',
    25. center: [114.30, 30.50],
    26. zoom: 4
    27. })
    28. })
    29. map.addLayer(docLayer)
    30. function queryPoint() {
    31. map.on("click", e => {
    32. var position = e.coordinate;
    33. console.log(position)
    34. Point.query({
    35. position,
    36. service: {
    37. name: "xzd_city",
    38. layerId: 2
    39. },
    40. successCallback: onSuccess
    41. })
    42. })
    43. }
    44. var source = new ol.source.Vector({wrapX:false});
    45. var layer = new ol.layer.Vector({
    46. source
    47. })
    48. layer.setStyle(
    49. new ol.style.Style({
    50. image:new ol.style.Circle({
    51. radius:12,
    52. fill:new ol.style.Fill({
    53. color:"#333"
    54. })
    55. })
    56. })
    57. )
    58. map.addLayer(layer)
    59. function onSuccess(res) {
    60. var format = new Zondy.Format.PolygonJSON();
    61. //将MapGIS要素JSON反序列化为ol.Feature类型数组
    62. var features = format.read(res);
    63. console.log(features)
    64. if(features){
    65. source.addFeatures(features)
    66. console.log(source)
    67. }
    68. }
    69. </script>
    70. </body>
    71. </html>