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

Legend.getStyleImage() fails to render "Multi" GeometryTypes #548

Closed
richard-thomas opened this issue Jan 2, 2021 · 0 comments
Closed

Comments

@richard-thomas
Copy link

ol/Layer/Vector features of GeometryType Multi* are not rendered in Legends. However, a simple addition of the 3 missing types in Legend.js seems to solve the problem:

          switch (typeGeom) {
            case ol_geom_Point:
            case 'Point':
            case 'MultiPoint': // ADDED
              vectorContext.drawGeometry(new ol_geom_Point([cx, cy]));
              break;
            case ol_geom_LineString:
            case 'LineString':
            case 'MultiLineString': // ADDED
              ctx.save();
                ctx.rect(legend.get('margin') * ratio, 0, size[0] *  ratio, canvas.height);
                ctx.clip();
                vectorContext.drawGeometry(new ol_geom_LineString([[cx-sx, cy], [cx+sx, cy]]));
              ctx.restore();
              break;
            case ol_geom_Polygon:
            case 'Polygon':
            case 'MultiPolygon': // ADDED
              vectorContext.drawGeometry(new ol_geom_Polygon([[[cx-sx, cy-sy], [cx+sx, cy-sy], [cx+sx, cy+sy], [cx-sx, cy+sy], [cx-sx, cy-sy]]]));
              break;
          }

(Alternatively any "Multi" prefix can be stripped from a GeometryType at an earlier point).

Viglino added a commit that referenced this issue Jan 4, 2021
@Viglino Viglino closed this as completed Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants