Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

107
Visualizações
WFS point Layer label is not displaying on openlayer 3

I have loaded the WFS point layer data from the geoServer Successfully. And I can plot the point layer also, but the label was not displaying. I added label as text param on Style part and the param looks like this text: '${name}',

Currently my code looks like this:

    var sourceWFS = new ol.source.Vector({
        format: new ol.format.GeoJSON({
            extractGeometryName: true
        }),
        title: geoServerLayerName,
        url: appConfigInfo.wfsurl + '/wfs?service=WFS&version=1.1.0&request=GetFeature&typename=' + geoServerLayerName + '&outputFormat=application/json',
        strategy: ol.loadingstrategy.bbox,
        projection: 'EPSG:4326'
    });
    var vectorLayerWFS = new ol.layer.Vector({
        source: sourceWFS,
        style: new ol.style.Style({
            image: new ol.style.Icon(({
                anchor: [0.5, 1],
                src: IconUrl
            })),
            text: new ol.style.Text({
                text: '${name}',
                font: '12px Calibri,sans-serif',
                fill: new ol.style.Fill({
                    color: '#000'
                }),
                stroke: new ol.style.Stroke({
                    color: '#fff',
                    width: 2
                }),
            })
        })
    });
    vectorLayerWFS.setProperties({
        title: layerName
    });
    mapObj.addLayer(vectorLayerWFS);
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The text must be set in a style function

var style = new ol.style.Style({
        image: new ol.style.Icon(({
            anchor: [0.5, 1],
            src: IconUrl
        })),
        text: new ol.style.Text({
            font: '12px Calibri,sans-serif',
            fill: new ol.style.Fill({
                color: '#000'
            }),
            stroke: new ol.style.Stroke({
                color: '#fff',
                width: 2
            }),
        })
    });
var vectorLayerWFS = new ol.layer.Vector({
    source: sourceWFS,
    style: function(feature) {
        style.getText().setText(feature.get('name'));
        return style;
    }
});
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda