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

feat: layer management #3

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ interface Props {
}

const uri =
'https://proximiio-map-mobile.ams3.cdn.digitaloceanspaces.com/1.0.0-b18/index.html';
'https://proximiio-map-mobile.ams3.cdn.digitaloceanspaces.com/1.0.0-b19/index.html';

export interface Feature {
id: string;
Expand Down Expand Up @@ -100,6 +100,11 @@ enum Action {
getSource = 'getSource',
hasSource = 'hasSource',
removeSource = 'removeSource',
addLayer = 'addLayer',
getLayer = 'getLayer',
hasLayer = 'hasLayer',
moveLayer = 'moveLayer',
removeLayer = 'removeLayer',
}

export type PromoteIdSpecification =
Expand Down Expand Up @@ -253,6 +258,35 @@ export class ProximiioMap extends Component<Props> {
return result as boolean;
}

async addLayer(layer: never): Promise<boolean> {
const params = `'${JSON.stringify(layer)}'`;
const result = await this.asyncTask(Action.addLayer, params);
return result as boolean;
}

async getLayer(id: string): Promise<SourceInfo | undefined> {
const result = await this.asyncTask(Action.getLayer, `'${id}'`);
return result as SourceInfo | undefined;
}

async hasLayer(id: string): Promise<boolean> {
const result = await this.asyncTask(Action.hasLayer, `'${id}'`);
return result as boolean;
}

async moveLayer(id: string, beforeId: string): Promise<boolean> {
const result = await this.asyncTask(
Action.moveLayer,
`'${id}', '${beforeId}'`
);
return result as boolean;
}

async removeLayer(id: string): Promise<boolean> {
const result = await this.asyncTask(Action.removeLayer, `'${id}'`);
return result as boolean;
}

setCenter(lat: number, lng: number) {
this.dispatch(`mapController.setCenter(${lat}, ${lng});`);
}
Expand Down
Loading