How can I populate all cities' names from a WFS file of a state in a drop down? I am using OpenLayers 6 as mapping Libraries.

Here is my code to add a GeoJSON WFS layer.

//Adding vector source layers
  var vectorSource = new ol.source.Vector({
    format: new ol.format.GeoJSON(),
    url: function (extent) {
      return (
        'http://localhost:8081/geoserver/wfs?service=WFS&' +
        'version=1.0.0&request=GetFeature&typename= election:Rajasthan_constituency_Joined&' +
        'outputFormat=application/json&srsname=EPSG:4326&' +
        'bbox=' +
        extent.join(',') +
    strategy: ol.loadingstrategy.bbox,
  var vector = new ol.layer.Vector({
    source: vectorSource,
    name: 'feature_vector',
    visible: false,
    title: 'vector',
    style: new ol.style.Style({
      stroke: new ol.style.Stroke({
        color: 'rgba(0, 0, 255, 0.4)',
        width: 1.5
  fill:new ol.style.Fill({
     color: 'rgba(0,0,0,0)'
  • 1
    Welcome to Geographic Information Systems! Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works – Ian Turton Jan 4 at 10:32
  • 2
    To display names you will need a style function which sets the name (or whichever property is used for the name) in the text of the label style as which country names openlayers.org/en/latest/examples/vector-layer.html and street names openlayers.org/en/latest/examples/street-labels.html – Mike Jan 4 at 12:03