mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
refactoring map service: Using leaflet's LatLngLiteral interface
This commit is contained in:
parent
57cf18ec07
commit
346590f651
@ -15,7 +15,6 @@ import {
|
||||
Control,
|
||||
divIcon,
|
||||
icon,
|
||||
LatLng,
|
||||
latLng,
|
||||
latLngBounds,
|
||||
layerGroup,
|
||||
@ -392,11 +391,11 @@ export class GalleryMapLightboxComponent implements OnChanges {
|
||||
}
|
||||
if (parsedGPX.path.length !== 0) {
|
||||
// render the beginning of the path with a marker
|
||||
this.mapLayersControlOption.overlays.Paths.addLayer(marker(parsedGPX.path[0] as LatLng));
|
||||
this.mapLayersControlOption.overlays.Paths.addLayer(polyline(parsedGPX.path as LatLng[]));
|
||||
this.mapLayersControlOption.overlays.Paths.addLayer(marker(parsedGPX.path[0]));
|
||||
this.mapLayersControlOption.overlays.Paths.addLayer(polyline(parsedGPX.path));
|
||||
}
|
||||
parsedGPX.markers.forEach(mc => {
|
||||
this.mapLayersControlOption.overlays.Paths.addLayer(marker(mc as LatLng));
|
||||
this.mapLayersControlOption.overlays.Paths.addLayer(marker(mc));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import {FileDTO} from '../../../../../common/entities/FileDTO';
|
||||
import {Utils} from '../../../../../common/Utils';
|
||||
import {Config} from '../../../../../common/config/public/Config';
|
||||
import {MapLayers, MapProviders} from '../../../../../common/config/public/ClientConfig';
|
||||
import {LatLngLiteral} from 'leaflet';
|
||||
|
||||
|
||||
@Injectable()
|
||||
@ -70,12 +71,12 @@ export class MapService {
|
||||
}
|
||||
|
||||
|
||||
public async getMapCoordinates(file: FileDTO): Promise<{ path: MapCoordinates[], markers: MapCoordinates[] }> {
|
||||
public async getMapCoordinates(file: FileDTO): Promise<{ path: LatLngLiteral[], markers: LatLngLiteral[] }> {
|
||||
const filePath = Utils.concatUrls(file.directory.path, file.directory.name, file.name);
|
||||
const gpx = await this.networkService.getXML('/gallery/content/' + filePath);
|
||||
const getCoordinates = (tagName: string): MapCoordinates[] => {
|
||||
const getCoordinates = (tagName: string): LatLngLiteral[] => {
|
||||
const elements = gpx.getElementsByTagName(tagName);
|
||||
const ret: MapCoordinates[] = [];
|
||||
const ret: LatLngLiteral[] = [];
|
||||
// tslint:disable-next-line:prefer-for-of
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
ret.push({
|
||||
@ -92,9 +93,3 @@ export class MapService {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export interface MapCoordinates {
|
||||
lat: number;
|
||||
lng: number;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user