Search code examples
geometryopenlayerspointgeoserver

make circles(buffers?) on openlayers


I am sorry for the awkward grammar because I am not good at English.

I want to make circles at each point(load from url) I used ol.source.imageWMS, but i don't know how to get each point's latitude, longitude.

this is my code:

Source_PtSearch = new ol.source.ImageWMS({
    url : 'http://localhost:9090/geoserver/HB/wms',
    params : {'LAYERS' : 'HB:HB_ASF_TEST2'},
    serverType : 'geoserver',
    crossOrigin : 'anonymous',
    projection : 'EPSG:4326'
});

how can i get each point's latitude, longitude?


Solution

  • First make a GetFeatureInfo request to your Geoserver to retrieve all features from a WMS layer. Then have a look at WMS GetFeatureInfo Example to see how to parse the response to get all Features, in resume it's:

    var allFeatures = new WMSGetFeatureInfo().readFeatures(response);
    

    Then you can iterate over all features and get the coordinates by:

    feature.getGeometry().getCoordinates()