mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-06 18:20:09 +00:00
Merge pull request #33995 from breeze9527/master
Added type definitions for amap-js-api-indoor-map
This commit is contained in:
114
types/amap-js-api-indoor-map/amap-js-api-indoor-map-tests.ts
Normal file
114
types/amap-js-api-indoor-map/amap-js-api-indoor-map-tests.ts
Normal file
@@ -0,0 +1,114 @@
|
||||
// $ExpectType IndoorMap
|
||||
new AMap.IndoorMap();
|
||||
// $ExpectType IndoorMap
|
||||
new AMap.IndoorMap({});
|
||||
// $ExpectType IndoorMap
|
||||
const indoorMap = new AMap.IndoorMap({
|
||||
zIndex: 1,
|
||||
opacity: 0.5,
|
||||
cursor: 'cursor',
|
||||
hideFloorBar: false,
|
||||
alaysShow: true
|
||||
});
|
||||
|
||||
// $ExpectType void
|
||||
indoorMap.showIndoorMap('indoorMapId');
|
||||
// $ExpectType void
|
||||
indoorMap.showIndoorMap('indoorMapId', (error, result) => {
|
||||
// $ExpectType Error | null
|
||||
error;
|
||||
// $ExpectType SearchResult
|
||||
result;
|
||||
// $ExpectType string
|
||||
result.id;
|
||||
// $ExpectType 0 | 1
|
||||
result.status;
|
||||
if (result.status === 0) {
|
||||
// $ExpectType Building
|
||||
const building = result.building;
|
||||
{
|
||||
// $ExpectType number
|
||||
building.floor;
|
||||
// $ExpectType FloorDetails
|
||||
const floorDetails = building.floor_details;
|
||||
{
|
||||
// $ExpectType number[]
|
||||
floorDetails.floor_indexs;
|
||||
// $ExpectType string[]
|
||||
floorDetails.floor_names;
|
||||
// $ExpectType string[]
|
||||
floorDetails.floor_nonas;
|
||||
}
|
||||
// $ExpectType string
|
||||
building.id;
|
||||
// $ExpectType LngLat
|
||||
building.lnglat;
|
||||
// $ExpectType string
|
||||
building.name;
|
||||
}
|
||||
} else {
|
||||
// $ExpectType Error
|
||||
result.error;
|
||||
}
|
||||
});
|
||||
// $ExpectType void
|
||||
indoorMap.showIndoorMap('indoorMapId', 1);
|
||||
// $ExpectType void
|
||||
indoorMap.showIndoorMap('indoorMapId', 1, () => { });
|
||||
// $ExpectType void
|
||||
indoorMap.showIndoorMap('indoorMapId', 1, 'shopId');
|
||||
// $ExpectType void
|
||||
indoorMap.showIndoorMap('indoorMapId', 1, 'shopId', () => { });
|
||||
// $ExpectType void
|
||||
indoorMap.showIndoorMap('indoorMapId', 1, 'shopId', true);
|
||||
// $ExpectType void
|
||||
indoorMap.showIndoorMap('indoorMapId', 1, 'shopId', true, () => { });
|
||||
|
||||
let floor: undefined | false;
|
||||
floor = indoorMap.showFloor(1);
|
||||
floor = indoorMap.showFloor(1, true);
|
||||
|
||||
// $ExpectType void
|
||||
indoorMap.showFloorBar();
|
||||
|
||||
// $ExpectType void
|
||||
indoorMap.hideFloorBar();
|
||||
|
||||
// $ExpectType void
|
||||
indoorMap.hideLabels();
|
||||
|
||||
// $ExpectType string | null
|
||||
indoorMap.getSelectedBuildingId();
|
||||
|
||||
// $ExpectType Building | null
|
||||
const building = indoorMap.getSelectedBuilding();
|
||||
if (building) {
|
||||
// $ExpectType number
|
||||
building.floor;
|
||||
// $ExpectType FloorDetails
|
||||
building.floor_details;
|
||||
// $ExpectType string
|
||||
building.id;
|
||||
// $ExpectType LngLat
|
||||
building.lnglat;
|
||||
// $ExpectType string
|
||||
building.name;
|
||||
}
|
||||
|
||||
indoorMap.on('complete', (event: AMap.IndoorMap.EventMap['complete']) => {
|
||||
// $ExpectType "complete"
|
||||
event.type;
|
||||
});
|
||||
|
||||
indoorMap.on('click', (event: AMap.IndoorMap.EventMap['click']) => {
|
||||
// $ExpectType string
|
||||
event.building_id;
|
||||
// $ExpectType number
|
||||
event.floor;
|
||||
// $ExpectType LngLat
|
||||
event.lnglat;
|
||||
// $ExpectType Shop
|
||||
event.shop;
|
||||
// $ExpectType "click"
|
||||
event.type;
|
||||
});
|
||||
110
types/amap-js-api-indoor-map/index.d.ts
vendored
Normal file
110
types/amap-js-api-indoor-map/index.d.ts
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
// Type definitions for non-npm package amap-js-api-indoor-map 1.4
|
||||
// Project: https://lbs.amap.com/api/javascript-api/reference/indoormap
|
||||
// Definitions by: breeze9527 <https://github.com/breeze9527>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/// <reference types="amap-js-api" />
|
||||
|
||||
declare namespace AMap {
|
||||
namespace IndoorMap {
|
||||
interface EventMap {
|
||||
complete: Event<'complete'>;
|
||||
click: MouseEvent<'click'>;
|
||||
|
||||
floor_complete: Event<'floor_complete', SearchResult>;
|
||||
mouseover: MouseEvent<'mouseover'>;
|
||||
mouseout: MouseEvent<'mouseout'>;
|
||||
}
|
||||
type MouseEvent<N extends string> = Event<N, {
|
||||
building_id: string;
|
||||
lnglat: LngLat;
|
||||
floor: number;
|
||||
shop: Shop;
|
||||
}>;
|
||||
interface Options extends Layer.Options {
|
||||
zIndex?: number;
|
||||
opacity?: number;
|
||||
cursor?: string;
|
||||
hideFloorBar?: boolean;
|
||||
alaysShow?: boolean;
|
||||
// internal
|
||||
visible?: boolean;
|
||||
featurezIndex?: number;
|
||||
zooms?: [number, number];
|
||||
disableIconRender?: boolean;
|
||||
disableLabelRender?: boolean;
|
||||
disableHoverMarker?: boolean;
|
||||
autoLoadBuildingsInTile?: boolean;
|
||||
}
|
||||
interface FloorDetails {
|
||||
floor_indexs: number[];
|
||||
floor_nonas: string[];
|
||||
floor_names: string[];
|
||||
}
|
||||
type ShopCategory = 'public' | 'connection' | 'shop';
|
||||
interface Shop {
|
||||
id: string;
|
||||
poiId: string;
|
||||
building_id: string;
|
||||
name: string;
|
||||
lnglat: LngLat;
|
||||
category: ShopCategory;
|
||||
}
|
||||
interface Building {
|
||||
id: string;
|
||||
name: string;
|
||||
lnglat: LngLat;
|
||||
floor: number;
|
||||
floor_details: FloorDetails;
|
||||
}
|
||||
interface SearchSuccessResult {
|
||||
id: string;
|
||||
status: 0;
|
||||
building: Building;
|
||||
}
|
||||
interface SearchErrorResult {
|
||||
id: string;
|
||||
status: 1;
|
||||
error: Error;
|
||||
}
|
||||
type SearchResult = SearchSuccessResult | SearchErrorResult;
|
||||
}
|
||||
|
||||
class IndoorMap extends Layer {
|
||||
constructor(options?: IndoorMap.Options);
|
||||
showIndoorMap(
|
||||
indoorId: string,
|
||||
callback?: (error: null | Error, result: IndoorMap.SearchResult) => void
|
||||
): void;
|
||||
showIndoorMap(
|
||||
indoorId: string,
|
||||
floor?: number,
|
||||
callback?: (error: null | Error, result: IndoorMap.SearchResult) => void
|
||||
): void;
|
||||
showIndoorMap(
|
||||
indoorId: string,
|
||||
floor?: number,
|
||||
shopId?: string,
|
||||
callback?: (error: null | Error, result: IndoorMap.SearchResult) => void
|
||||
): void;
|
||||
showIndoorMap(
|
||||
indoorId: string,
|
||||
floor?: number,
|
||||
shopId?: string,
|
||||
noMove?: boolean,
|
||||
callback?: (error: null | Error, result: IndoorMap.SearchResult) => void
|
||||
): void;
|
||||
showFloor(floor: number, noMove?: boolean): false | undefined;
|
||||
showFloorBar(): void;
|
||||
hideFloorBar(): void;
|
||||
showLabels(): void;
|
||||
hideLabels(): void;
|
||||
getSelectedBuildingId(): string | null;
|
||||
getSelectedBuilding(): IndoorMap.Building | null;
|
||||
|
||||
// internal
|
||||
getFloorBar(): void;
|
||||
setSelectedBuildingId(id: string): void;
|
||||
}
|
||||
}
|
||||
24
types/amap-js-api-indoor-map/tsconfig.json
Normal file
24
types/amap-js-api-indoor-map/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noEmit": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"amap-js-api-indoor-map-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/amap-js-api-indoor-map/tslint.json
Normal file
3
types/amap-js-api-indoor-map/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user