Skip to content

Commit

Permalink
Define an interface to add/remove sources and layers to/from map
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedHamouGisaia committed Dec 9, 2024
1 parent a94ad08 commit c74abf6
Show file tree
Hide file tree
Showing 20 changed files with 1,347 additions and 356 deletions.
433 changes: 424 additions & 9 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion projects/arlas-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "arlas-web-components",
"version": "27.0.0-map.alpha.4",
"version": "27.0.0-map.beta.1",
"peerDependencies": {
"@angular/animations": "^15.2.10",
"@angular/cdk": "^15.2.9",
Expand Down

This file was deleted.

This file was deleted.

22 changes: 11 additions & 11 deletions projects/arlas-map/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "arlas-map",
"version": "27.0.0-alpha.8",
"version": "27.0.0-map.beta.1",
"peerDependencies": {
"@angular/animations": "^14.2.12",
"@angular/cdk": "^14.2.7",
"@angular/common": "^14.2.12",
"@angular/core": "^14.2.12",
"@angular/forms": "^14.2.12",
"@angular/material": "^14.2.7",
"@angular/platform-browser": "^14.2.12",
"@angular/platform-browser-dynamic": "^14.2.12",
"@angular/router": "^14.2.12",
"@angular/animations": "^15.2.10",
"@angular/cdk": "^15.2.9",
"@angular/common": "^15.2.10",
"@angular/core": "^15.2.10",
"@angular/forms": "^15.2.10",
"@angular/material": "^15.2.9",
"@angular/platform-browser": "^15.2.10",
"@angular/platform-browser-dynamic": "^15.2.10",
"@angular/router": "^15.2.10",
"@ngx-translate/core": "^14.0.0",
"@ngx-translate/http-loader": "^7.0.0",
"rxjs": "~7.4.0",
Expand All @@ -34,6 +34,6 @@
"@turf/rhumb-destination": "^6.5.0",
"@turf/transform-rotate": "^6.5.0",
"pmtiles": "^2.11.0",
"arlas-web-components": "27.0.0-map.alpha.4"
"arlas-web-components": "27.0.0-map.beta.1"
}
}
17 changes: 17 additions & 0 deletions projects/arlas-map/src/lib/arlas-map.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ export class ArlasMapComponent implements OnInit {



protected ICONS_BASE_PATH = 'assets/icons/';



/** ------------------------------------------------------- VISUAL SEPERATOR - INIT ----------------------------------------- */
Expand Down Expand Up @@ -455,6 +457,18 @@ export class ArlasMapComponent implements OnInit {
}
}

/**
* Adds the custom icons given in the component's input
*/
public addIcons() {
this.icons.forEach(icon => {
const iconName = icon.path.split('.')[0];
const iconPath = this.ICONS_BASE_PATH + icon.path;
const iconErrorMessage = 'The icon "' + this.ICONS_BASE_PATH + icon.path + '" is not found';
this.mapService.addImage(iconName, iconPath, this.map, iconErrorMessage, { 'sdf': icon.recolorable } );
});
}

public declareMap() {
console.log('declaaaring')

Check failure on line 473 in projects/arlas-map/src/lib/arlas-map.component.ts

View workflow job for this annotation

GitHub Actions / Lint, Build, Test & Documentation

Missing semicolon

Check failure on line 473 in projects/arlas-map/src/lib/arlas-map.component.ts

View workflow job for this annotation

GitHub Actions / Lint, Build, Test & Documentation

Missing semicolon
this.initTransformRequest();
Expand Down Expand Up @@ -534,6 +548,7 @@ export class ArlasMapComponent implements OnInit {
console.log('declare');
this.map = this.mapService.createMap(config);
console.log(this.map);

this.map.eventEmitter$.subscribe({
next: (e: MapLayerMouseEvent) => {
if (e.type === 'click') {
Expand Down Expand Up @@ -602,6 +617,8 @@ export class ArlasMapComponent implements OnInit {
// TODO: should change the
this.basemapService.declareProtomapProtocol(this.map);
this.basemapService.addProtomapBasemap(this.map);
this.addIcons();

});

this.map.on('load', () => {
Expand Down
39 changes: 37 additions & 2 deletions projects/arlas-map/src/lib/arlas-map.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { AbstractArlasMapGL, MapConfig } from './map/AbstractArlasMapGL';
import { AbstractDraw } from './draw/AbstractDraw';
import { LngLat } from './map/model/map';
import { FeatureCollection } from '@turf/helpers';
import { VectorStyle } from './map/model/vector-style';

@Injectable({
providedIn: 'root'
Expand Down Expand Up @@ -87,9 +88,43 @@ export abstract class ArlasMapService {
* @param source A Geojson source
* @param data A feature collection object.
*/
public abstract setDataToGeojsonSource(source: any, data: FeatureCollection<GeoJSON.Geometry> );
public abstract setDataToGeojsonSource(source: any, data: FeatureCollection<GeoJSON.Geometry>);


public abstract addImage(name: string, url: string, map: AbstractArlasMapGL, errorMessage: string, opt?: any);

/**
* Checks if the given layer is already added to the map instance
* @param map Map instance
* @param layer layer identifier
*/
public abstract hasLayer(map: AbstractArlasMapGL, layer: any);
/** */
public abstract setSource(sourceId: string, source: any, options: any);
public abstract addLayer(map: AbstractArlasMapGL, layer: any);
public abstract removeLayer(map: AbstractArlasMapGL, layer: any);
public abstract removeSource(map: AbstractArlasMapGL, layer: any);
public abstract createPopup(lng: number, lat: number, message: string);
public abstract addPopup(map: AbstractArlasMapGL, popup: any);
public abstract removePopup(map: AbstractArlasMapGL, popup: any);
public abstract removeLayers(map: AbstractArlasMapGL, layers: any)
public abstract removeLayersFromPattern(map: AbstractArlasMapGL, layersIdPattern: string);
public abstract hasLayersFromPattern(map: AbstractArlasMapGL, layersIdPattern: string);
public abstract setMapCursor(map: AbstractArlasMapGL, cursor: string): void;

public abstract addIconLayer(map: AbstractArlasMapGL, layerId: string, iconName: string,
iconSize: number, data: GeoJSON.Feature<GeoJSON.Geometry> | GeoJSON.FeatureCollection<GeoJSON.Geometry>);
public abstract addRasterLayer(map: AbstractArlasMapGL, layerId: string, url: string, bounds: number[],
maxZoom: number, minZoom: number, tileSize: number, beforeId?: string): void;

public abstract addGeojsonLayer(map: AbstractArlasMapGL, layerId: string, style: VectorStyle,
data: GeoJSON.Feature<GeoJSON.Geometry> | GeoJSON.FeatureCollection<GeoJSON.Geometry>
): void;

public abstract createGeojsonSource(data: GeoJSON.GeoJSON): any;
public abstract createRasterSource(url: string, bounds: number[],
maxZoom: number, minZoom: number, tileSize: number): any;

public abstract onLayerEvent(eventName: any, map: AbstractArlasMapGL, layer: any, fn: () => void);
public abstract onMapEvent(eventName: any, map: AbstractArlasMapGL, fn: (e) => void);

}
Loading

0 comments on commit c74abf6

Please sign in to comment.