Skip to content

Ansyn public API

Ram Tobolski edited this page Jan 21, 2019 · 4 revisions

Get Ansyn API service

import { AnsynApi } from '@ansyn/ansyn';

@Component({ ... }) export class AppComponent { constructor(protected ansynApi: AnsynApi) { } }

Ansyn API

Ansyn as component exposes the following methods:

Layout

changeMapLayout(layout: LayoutKey)

Controls the maps layout.

export type LayoutKey = 'layout1' | 'layout2' | 'layout3' | 'layout4' | 'layout5' | 'layout6';

export const layoutOptions = new Map<LayoutKey, IMapsLayout>([
	['layout1', { id: 'layout1', mapsCount: 1 }],
	['layout2', { id: 'layout2', mapsCount: 2 }],
	['layout3', { id: 'layout3', mapsCount: 2 }],
	['layout4', { id: 'layout4', mapsCount: 3 }],
	['layout5', { id: 'layout5', mapsCount: 3 }],
	['layout6', { id: 'layout6', mapsCount: 4 }]
]);

Shadow mouse

onShadowMouseProduce$

Subscribes to shadow mouse location event updates.

Usage example:

api.onShadowMouseProduce$.subscribe((coordinates) => console.log(coordinates))

Unsubscribes from shadow mouse location event updates.

setOutSourceMouseShadow(coordinates: [number, number])

Sets a shadow mouse location in the component.

Position

goToPosition(position: Array)

Active Map Receives a position in EPSG:4326 and flies to the given location.

getMapPosition(): ICaseMapPosition

get active map position in EPSG:4326.

Usage Example:

export interface ICaseMapPosition {
	projectedState?: ICaseMapProjectedState;
	extentPolygon?: GEOJSON.Polygon;
}

export interface ICaseMapProjectedState {
	projection: {
		code: string;
	};
	center?: [number, number];
	resolution?: number;
	rotation?: number
	zoom?: number;
}

getActiveCenter$

register to active center changes

api.onShadowMouseProduce$.subscribe((coordinates) => console.log(coordinates))

setMapPositionByRect(rect: Polygon)

rect: a rectangle polygon. It should be closed (the last coordinate same as the first).

setMapPositionByRadius(center: Point, radiusInMeters: number, search: boolean = false)

When the search parameter is true, the component performs a search for overlays, at the center point.

Overlays display

displayOverLay(overlay: IOverlay, mapNumber: number = -1)

Displays an overlay on map #mapNumber.
If the mapNumber param is omitted, display on the active map.

setOverlays(overlays: IOverlay[])

Sets overlays in the timeline.

export interface IOverlay {
        id: string;
	sourceType?: string;
	footprint?: any;
	sensorType?: string;
	sensorName?: string;
	channel?: number;
	bestResolution?: number;
	cloudCoverage?: number;
	isStereo?: boolean;
	name: string;
	imageUrl?: string;
	baseImageUrl?: string;
	thumbnailUrl?: string;
	photoTime: string;
	date: Date;
	azimuth: number; // radians
	approximateTransform?: any;
	csmState?: string;
	isGeoRegistered: boolean;
	tag?: any; // original metadata
	projection?: string;
	token?: string;
	catalogID?: string,
}

Annotations

setAnnotations(featureCollection: FeatureCollection)

Sets Anotations To all imagery maps

deleteAllAnnotations()

Remove all anotations from imagery

Search for overlays

setOverlaysCriteria(criteria: IOverlaysCriteria)

export interface IOverlaysCriteria {
	time?: ICaseTimeState;
	region?: CaseRegionState;
	dataInputFilters?: ICaseDataInputFiltersState;

export interface ICaseTimeState {
	type: 'absolute',
	from: Date,
	to: Date
}

export type CaseRegionState = any | Feature<Polygon> | Point | Polygon | Position;

export interface ICaseDataInputFiltersState {
	fullyChecked: boolean,
	filters: IDataInputFilterValue[],
	active: boolean
}

export interface IDataInputFilterValue {
	providerName: string,
	sensorType: string,
	sensorName: string
}

General

destroy()

kills the map and dispose it's resources