¿Podría ayudarme? Tengo 5 huertos que tienen la misma ubicación/coordenadas de GPS y cuando ejecuto mi proyecto, todos aparecen en el mismo lugar. Me gustaría dispersarlos/agruparlos en un círculo o de cualquier manera para que cada ícono espacio entre ellos, estoy usando capas abiertas y también intenté usar ol.source.Cluster pero me da errores, ¿hay una forma más sencilla de lograr esto? Consulte el código a continuación. Gracias
el siguiente código funciona pero los íconos aparecen en un solo lugar
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); };Estilo de icono
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; }Puede usar ol-ext, que es una extensión para openlayers. En ol-ext, cuando se selecciona el clúster, la interacción SelectCluster muestra los datos separados.