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

67
Visualizações
Cluster/Scatter locations with same GPS Location ol.layers

Could you please assist,i have 5 orchards that all have the same GPS location/coordinates and when i run my project they all appear at the same place,i would like to scatter/cluster them in a circle or however so that each icons have space between them,i am using open layers and also tried using ol.source.Cluster but is giving me errors,is there a simpler way to achieve this?please see code below.Thanks

below code working but icons appearing in one place

  function getOrchardLocations(locationId) {
        if (orchards != null)
            map.removeLayer(orchards);

        orchards = new ol.layer.Vector({
            source: new ol.source.Vector({
                url: rootName+'/Home/Locations/GetOrchardLocations/' + locationId,
                format: new ol.format.GeoJSON()
            }),
            style: function (feature) { return iconStyleFunc(feature); }
        });
       // console.log(feature);
        map.addLayer(orchards);
        ZoomPucOrchards(pucid);
    };

Icon Style

    function iconStyleFunc(feature) {

        var zIndex = 1;

        var iconName = feature.get("IconPath") || "blue.png";

        iconStyle = [new ol.style.Style({
            image: new ol.style.Icon(({
                anchor: [0.5, 36],
                anchorXUnits: "fraction",
                anchorYUnits: "pixels",
                opacity: 1,
                src: "/img/icons/" + iconName,
                zIndex: zIndex
            })),
            text: new ol.style.Text({
                text: getText(feature),
                font: '14px "Helvetica Neue",Helvetica,Arial,sans-serif',
                placement: 'point',
                fill: new ol.style.Fill({ color: '#fff' }),
                stroke: new ol.style.Stroke({ color: '#000', width: 1 }),
            }),
            zIndex: zIndex
        })];
        return iconStyle;
    }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use ol-ext which is extension for openlayers. In ol-ext, when cluster is selected, SelectCluster interaction shows the data as seperated.

ol-ext

Example code

Example website

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