Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue while rendering map style photo in angular. #1117

Open
tberbalaje opened this issue Dec 26, 2024 · 3 comments
Open

Issue while rendering map style photo in angular. #1117

tberbalaje opened this issue Dec 26, 2024 · 3 comments

Comments

@tberbalaje
Copy link

tberbalaje commented Dec 26, 2024

Circular image rendering using Photo from 'ol-ext/style/Photo' is not working. Even if 4 images are loaded only the last image displayed in all 4 image holders. Below attached code, new Icon works fine but not new Photo

JS reference: https://viglino.github.io/ol-ext/examples/style/map.style.photo.html

new Photo
image

new Icon
image

`addCircularImages() {
const map: OlMap = this.mapService.getMap(this.mapidService);

const vectorSource = new VectorSource({
  url: 'assets/paris-1900.geojson',
  format: new GeoJSON(),
});

const clusterLayer = new VectorLayer({
  source: new ClusterSource({
    source: vectorSource,
  }),
  style: (feature) => {
    const size = feature.get('features').length;
    const img = feature.get('features')[0].get('img');
    return new Style({
      image: new Photo({
        src: img,
        radius: 25,
        crop: true,
        kind: size > 1 ? 'folio' : 'circle',
        shadow: 0,
        crossOrigin: 'anonymous',
        declutterMode: 'none',
        onload: () => {
          return true;
        },
        displacement: [0, 0],
        stroke: new Stroke({
          width: 5,
          color: '#fff',
        }),
      }),
      // image: new Icon({
      //   src: feature.get('features')[0].get('img'),
      //   height: 50,
      //   width: 50,
      // }),
      text: new Text({
        text: size > 1 ? size.toString() : '',
        font: 'bold 12px sans-serif',
        fill: new Fill({ color: '#fff' }),
      }),
    });
  },
});
map.addLayer(clusterLayer);

}`

@Viglino
Copy link
Owner

Viglino commented Dec 30, 2024

I you are using ol > 10.13.1 there is a breaking change on symbol cache.
This commit should fix it: 6ea333d
But nor yet deployed on npm.
Can you try to replace the style/photo.js file in the ol-ext directory to test it?

@tberbalaje
Copy link
Author

@Viglino this worked, but renderOptions_ is private in ol/style/RegularShape.js

@Viglino
Copy link
Owner

Viglino commented Jan 6, 2025

@Viglino this worked, but renderOptions_ is private in ol/style/RegularShape.js

That's still a hack for 10.13.1 I'll manage to overwrite the createRenderOptions method in the next version...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants