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

Custom source for ROSM component #289

Closed
itsdapi opened this issue Sep 14, 2024 · 1 comment
Closed

Custom source for ROSM component #289

itsdapi opened this issue Sep 14, 2024 · 1 comment

Comments

@itsdapi
Copy link

itsdapi commented Sep 14, 2024

Vanilla ol has a feature that can load different source of osm map by giving url.

export const geovisBaseLayer = new TileLayer({
  source: new OSM({
    url: `https://tiles1.geovisearth.com/base/v1/vec/{z}/{x}/{y}?format=webp&tmsIds=w&token=${config.mapToken}`,
  }),
});

Here if can provide a props to access the source would be an lazy option not to new a custom layer lol😆

export default class ROSM extends LayerRaster<ROSMProps> {
    source: OSM;

    constructor(props: Readonly<ROSMProps>, context?: React.Context<RContextType>) {
        super(props, context);
        this.source = new OSM();
        this.ol = new LayerTile({source: this.source});
        this.eventSources = [this.ol, this.source];
    }

    protected refresh(prevProps?: ROSMProps): void {
        super.refresh(prevProps);
        this.ol.setProperties({label: 'OpenStreetMap'});
    }
}
@itsdapi
Copy link
Author

itsdapi commented Sep 14, 2024

never mind it was pretty simple

export default function GeoVisBaseLayer() {
  return (
    <RLayerTile url={`https://tiles1.geovisearth.com/base/v1/vec/{z}/{x}/{y}?format=webp&tmsIds=w&token=${config.mapToken}`} />
  );
}

@itsdapi itsdapi closed this as completed Sep 14, 2024
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

1 participant