mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Added type definition for non-npm package amap-js-api-place-search (#34134)
This commit is contained in:
parent
1e2d5403fc
commit
f7a22e9682
435
types/amap-js-api-place-search/amap-js-api-place-search-tests.ts
Normal file
435
types/amap-js-api-place-search/amap-js-api-place-search-tests.ts
Normal file
@ -0,0 +1,435 @@
|
||||
declare const map: AMap.Map;
|
||||
declare const div: HTMLElement;
|
||||
declare const lnglat: AMap.LngLat;
|
||||
declare const lnglatTuple: [number, number];
|
||||
declare const bounds: AMap.Bounds;
|
||||
declare const polygon: AMap.Polygon;
|
||||
declare const lang: AMap.Lang;
|
||||
|
||||
// $ExpectType PlaceSearch
|
||||
const placeSearch = new AMap.PlaceSearch();
|
||||
// $ExpectType PlaceSearch
|
||||
new AMap.PlaceSearch({});
|
||||
// $ExpectType PlaceSearch
|
||||
new AMap.PlaceSearch({
|
||||
city: '深圳',
|
||||
citylimit: true,
|
||||
children: 1,
|
||||
type: '餐饮服务',
|
||||
lang: 'zh_cn',
|
||||
pageSize: 10,
|
||||
pageIndex: 10,
|
||||
extensions: 'all',
|
||||
map,
|
||||
panel: div,
|
||||
showCover: true,
|
||||
renderStyle: 'newpc',
|
||||
autoFitView: true
|
||||
});
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.search('keyword', (status, result) => {
|
||||
const temp: 'error' | 'complete' | 'no_data' = status;
|
||||
// $ExpectType string | SearchResult
|
||||
result;
|
||||
if (typeof result !== 'string') {
|
||||
// $ExpectType string
|
||||
result.info;
|
||||
// $ExpectType PoiList
|
||||
result.poiList;
|
||||
// $ExpectType string[] | undefined
|
||||
result.keywordList;
|
||||
// $ExpectType CityInfo[] | undefined
|
||||
result.cityList;
|
||||
|
||||
const poiList = result.poiList;
|
||||
// $ExpectType number
|
||||
poiList.pageIndex;
|
||||
// $ExpectType number
|
||||
poiList.pageSize;
|
||||
// $ExpectType number
|
||||
poiList.count;
|
||||
|
||||
const poi = poiList.pois[0];
|
||||
// $ExpectType string
|
||||
poi.address;
|
||||
// $ExpectType number
|
||||
poi.distance;
|
||||
// $ExpectType string
|
||||
poi.id;
|
||||
// $ExpectType LngLat | null
|
||||
poi.location;
|
||||
// $ExpectType string
|
||||
poi.name;
|
||||
// $ExpectType string
|
||||
poi.shopinfo;
|
||||
// $ExpectType string
|
||||
poi.tel;
|
||||
// $ExpectType string
|
||||
poi.type;
|
||||
if ('website' in poi) {
|
||||
// $ExpectType string
|
||||
poi.adcode;
|
||||
// $ExpectType string
|
||||
poi.adname;
|
||||
// $ExpectType string
|
||||
poi.citycode;
|
||||
// $ExpectType string
|
||||
poi.cityname;
|
||||
// $ExpectType boolean
|
||||
poi.discount;
|
||||
// $ExpectType string
|
||||
poi.email;
|
||||
// $ExpectType LngLat | null
|
||||
poi.entr_location;
|
||||
// $ExpectType LngLat | null
|
||||
poi.exit_location;
|
||||
// $ExpectType boolean
|
||||
poi.groupbuy;
|
||||
if (poi.indoor_map) {
|
||||
const indoorData = poi.indoor_data;
|
||||
// $ExpectType string
|
||||
indoorData.cpid;
|
||||
// $ExpectType string
|
||||
indoorData.floor;
|
||||
// $ExpectType string
|
||||
indoorData.truefloor;
|
||||
}
|
||||
poi.pcode;
|
||||
// $ExpectType PoiPhoto[]
|
||||
poi.photos;
|
||||
// $ExpectType string
|
||||
poi.pname;
|
||||
// $ExpectType string
|
||||
poi.postcode;
|
||||
// $ExpectType string
|
||||
poi.website;
|
||||
|
||||
const photo = poi.photos[0];
|
||||
// $ExpectType string
|
||||
photo.title;
|
||||
// $ExpectType string
|
||||
photo.url;
|
||||
// $ExpectType Groupbuy[] | undefined
|
||||
poi.groupbuys;
|
||||
if (poi.groupbuys) {
|
||||
const groupbuy = poi.groupbuys[0];
|
||||
// $ExpectType string
|
||||
groupbuy.title;
|
||||
// $ExpectType string
|
||||
groupbuy.type_code;
|
||||
// $ExpectType string
|
||||
groupbuy.type;
|
||||
// $ExpectType string
|
||||
groupbuy.detail;
|
||||
// $ExpectType string
|
||||
groupbuy.stime;
|
||||
// $ExpectType string
|
||||
groupbuy.etime;
|
||||
// $ExpectType number
|
||||
groupbuy.count;
|
||||
// $ExpectType number
|
||||
groupbuy.sold_num;
|
||||
// $ExpectType number
|
||||
groupbuy.original_price;
|
||||
// $ExpectType number
|
||||
groupbuy.groupbuy_price;
|
||||
// $ExpectType number
|
||||
groupbuy.discount;
|
||||
// $ExpectType string
|
||||
groupbuy.ticket_address;
|
||||
// $ExpectType string
|
||||
groupbuy.ticket_tel;
|
||||
// $ExpectType PoiPhoto[]
|
||||
groupbuy.photos;
|
||||
// $ExpectType string
|
||||
groupbuy.url;
|
||||
// $ExpectType string
|
||||
groupbuy.provider;
|
||||
}
|
||||
// $ExpectType Discount[] | undefined
|
||||
poi.discounts;
|
||||
if (poi.discounts) {
|
||||
const discount = poi.discounts[0];
|
||||
// $ExpectType string
|
||||
discount.title;
|
||||
// $ExpectType string
|
||||
discount.detail;
|
||||
// $ExpectType string
|
||||
discount.start_time;
|
||||
// $ExpectType string
|
||||
discount.end_time;
|
||||
// $ExpectType number
|
||||
discount.sold_num;
|
||||
// $ExpectType PoiPhoto[]
|
||||
discount.photos;
|
||||
// $ExpectType string
|
||||
discount.url;
|
||||
// $ExpectType string
|
||||
discount.provider;
|
||||
}
|
||||
if (poi.deep_type === 'CINEMA') {
|
||||
// $ExpectType Cinema
|
||||
const cinema = poi.cinema;
|
||||
// $ExpectType string
|
||||
cinema.intro;
|
||||
// $ExpectType string
|
||||
cinema.rating;
|
||||
// $ExpectType string
|
||||
cinema.deep_src;
|
||||
// $ExpectType string
|
||||
cinema.parking;
|
||||
// $ExpectType string
|
||||
cinema.opentime_GDF;
|
||||
// $ExpectType string
|
||||
cinema.opentime;
|
||||
// $ExpectType PoiPhoto[]
|
||||
cinema.photos;
|
||||
}
|
||||
if (poi.deep_type === 'DINING') {
|
||||
// $ExpectType Dining
|
||||
const dining = poi.dining;
|
||||
// $ExpectType string
|
||||
dining.cuisines;
|
||||
// $ExpectType string
|
||||
dining.tag;
|
||||
// $ExpectType string
|
||||
dining.intro;
|
||||
// $ExpectType string
|
||||
dining.rating;
|
||||
// $ExpectType string
|
||||
dining.cp_rating;
|
||||
// $ExpectType string
|
||||
dining.deep_src;
|
||||
// $ExpectType string
|
||||
dining.taste_rating;
|
||||
// $ExpectType string
|
||||
dining.environment_rating;
|
||||
// $ExpectType string
|
||||
dining.service_rating;
|
||||
// $ExpectType string
|
||||
dining.cost;
|
||||
// $ExpectType string
|
||||
dining.recommend;
|
||||
// $ExpectType string
|
||||
dining.atmosphere;
|
||||
// $ExpectType string
|
||||
dining.ordering_wap_url;
|
||||
// $ExpectType string
|
||||
dining.ordering_web_url;
|
||||
// $ExpectType string
|
||||
dining.ordering_app_url;
|
||||
// $ExpectType string
|
||||
dining.opentime_GDF;
|
||||
// $ExpectType string
|
||||
dining.opentime;
|
||||
// $ExpectType string
|
||||
dining.addition;
|
||||
// $ExpectType PoiPhoto[]
|
||||
dining.photos;
|
||||
}
|
||||
if (poi.deep_type === 'SCENIC') {
|
||||
// $ExpectType Scenic
|
||||
const scenic = poi.scenic;
|
||||
// $ExpectType string
|
||||
scenic.intro;
|
||||
// $ExpectType string
|
||||
scenic.rating;
|
||||
// $ExpectType string
|
||||
scenic.deep_src;
|
||||
// $ExpectType string
|
||||
scenic.level;
|
||||
// $ExpectType string
|
||||
scenic.price;
|
||||
// $ExpectType string
|
||||
scenic.season;
|
||||
// $ExpectType string
|
||||
scenic.recommend;
|
||||
// $ExpectType string
|
||||
scenic.theme;
|
||||
// $ExpectType string
|
||||
scenic.ordering_wap_url;
|
||||
// $ExpectType string
|
||||
scenic.ordering_web_url;
|
||||
// $ExpectType string
|
||||
scenic.opentime_GDF;
|
||||
// $ExpectType string
|
||||
scenic.opentime;
|
||||
// $ExpectType PoiPhoto[]
|
||||
scenic.photos;
|
||||
}
|
||||
if (poi.deep_type === 'HOTEL') {
|
||||
// $ExpectType Hotel
|
||||
const hotel = poi.hotel;
|
||||
// $ExpectType string
|
||||
hotel.rating;
|
||||
// $ExpectType string
|
||||
hotel.star;
|
||||
// $ExpectType string
|
||||
hotel.intro;
|
||||
// $ExpectType string
|
||||
hotel.lowest_price;
|
||||
// $ExpectType string
|
||||
hotel.faci_rating;
|
||||
// $ExpectType string
|
||||
hotel.health_rating;
|
||||
// $ExpectType string
|
||||
hotel.environment_rating;
|
||||
// $ExpectType string
|
||||
hotel.service_rating;
|
||||
// $ExpectType string
|
||||
hotel.traffic;
|
||||
// $ExpectType string
|
||||
hotel.addition;
|
||||
// $ExpectType string
|
||||
hotel.deep_src;
|
||||
// $ExpectType PoiPhoto[]
|
||||
hotel.photos;
|
||||
}
|
||||
}
|
||||
|
||||
if (result.cityList) {
|
||||
const city = result.cityList[0];
|
||||
// $ExpectType string
|
||||
city.adcode;
|
||||
// $ExpectType string
|
||||
city.citycode;
|
||||
// $ExpectType number
|
||||
city.count;
|
||||
// $ExpectType string
|
||||
city.name;
|
||||
}
|
||||
} else {
|
||||
// $ExpectType string
|
||||
result;
|
||||
}
|
||||
});
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.searchNearBy('keyword', lnglat, 10, (status, result) => {
|
||||
const temp: 'error' | 'complete' | 'no_data' = status;
|
||||
// $ExpectType string | SearchResult
|
||||
result;
|
||||
});
|
||||
// $ExpectType void
|
||||
placeSearch.searchNearBy('keyword', lnglatTuple, 10, () => { });
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.searchInBounds('keyword', bounds, (status, result) => {
|
||||
const temp: 'error' | 'complete' | 'no_data' = status;
|
||||
// $ExpectType string | SearchResult
|
||||
result;
|
||||
});
|
||||
// $ExpectType void
|
||||
placeSearch.searchInBounds('keyword', polygon, () => { });
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.getDetails('id', (status, result) => {
|
||||
const temp: 'error' | 'complete' | 'no_data' = status;
|
||||
// $ExpectType string | SearchResult
|
||||
result;
|
||||
});
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.setType('type');
|
||||
// $ExpectType void
|
||||
placeSearch.setType();
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.setCityLimit(true);
|
||||
// $ExpectType void
|
||||
placeSearch.setCityLimit();
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.setPageIndex(1);
|
||||
// $ExpectType void
|
||||
placeSearch.setPageIndex();
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.setPageSize(1);
|
||||
// $ExpectType void
|
||||
placeSearch.setPageSize();
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.setCity('city');
|
||||
// $ExpectType void
|
||||
placeSearch.setCity();
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.setLang(lang);
|
||||
// $ExpectType void
|
||||
placeSearch.setLang();
|
||||
|
||||
// $ExpectType "zh_cn" | "en" | "zh_en" | undefined
|
||||
placeSearch.getLang();
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.clear();
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.poiOnAMAP({
|
||||
id: 'id',
|
||||
});
|
||||
// $ExpectType void
|
||||
placeSearch.poiOnAMAP({
|
||||
location: lnglat,
|
||||
id: 'id',
|
||||
name: 'name'
|
||||
});
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.detailOnAMAP({
|
||||
id: 'id',
|
||||
});
|
||||
// $ExpectType void
|
||||
placeSearch.detailOnAMAP({
|
||||
location: lnglat,
|
||||
id: 'id',
|
||||
name: 'name'
|
||||
});
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.open();
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.close();
|
||||
|
||||
placeSearch.on('complete', (event: AMap.PlaceSearch.EventMap['complete']) => {
|
||||
// $ExpectType "complete"
|
||||
event.type;
|
||||
// $ExpectType string
|
||||
event.info;
|
||||
// $ExpectType PoiList
|
||||
event.poiList;
|
||||
// $ExpectType string[] | undefined
|
||||
event.keywordList;
|
||||
// $ExpectType CityInfo[] | undefined
|
||||
event.cityList;
|
||||
});
|
||||
|
||||
placeSearch.on('listElementClick', (event: AMap.PlaceSearch.EventMap['listElementClick']) => {
|
||||
// $ExpectType MouseEvent
|
||||
event.event;
|
||||
// $ExpectType string
|
||||
event.id;
|
||||
// $ExpectType number
|
||||
event.index;
|
||||
// $ExpectType Marker<any>
|
||||
event.marker;
|
||||
// $ExpectType HTMLLIElement
|
||||
event.listElement;
|
||||
});
|
||||
|
||||
placeSearch.on('markerClick', (event: AMap.PlaceSearch.EventMap['markerClick']) => {
|
||||
const markerEvent = event.event;
|
||||
// $ExpectType Marker<any>
|
||||
markerEvent.target;
|
||||
// $ExpectType string
|
||||
event.id;
|
||||
// $ExpectType number
|
||||
event.index;
|
||||
// $ExpectType Marker<any>
|
||||
event.marker;
|
||||
// $ExpectType HTMLLIElement
|
||||
event.listElement;
|
||||
});
|
||||
737
types/amap-js-api-place-search/index.d.ts
vendored
Normal file
737
types/amap-js-api-place-search/index.d.ts
vendored
Normal file
@ -0,0 +1,737 @@
|
||||
// Type definitions for non-npm package amap-js-api-place-search 1.4
|
||||
// Project: https://lbs.amap.com/api/javascript-api/reference/search#m_AMap.PlaceSearch
|
||||
// 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 PlaceSearch {
|
||||
interface EventMap {
|
||||
complete: Event<'complete', SearchResult>;
|
||||
error: Event<'error', { info: string }>;
|
||||
selectChanged: Event<'selectChanged', {
|
||||
selected: SelectChangeEventData | EventMap['markerClick'] | EventMap['listElementClick'];
|
||||
lastSelected: SelectChangeEventData | EventMap['markerClick'] | EventMap['listElementClick'] | null;
|
||||
}>;
|
||||
listElementClick: SelectChangeEvent<'listElementClick', MouseEvent>;
|
||||
markerClick: SelectChangeEvent<'markerClick', Marker.EventMap['click']>;
|
||||
// internal
|
||||
renderComplete: Event<'renderComplete', {
|
||||
result: SelectChangeEventData[];
|
||||
markers: Marker[];
|
||||
listElements: HTMLElement[];
|
||||
}>;
|
||||
infoWindowClick: Event<'infoWindowClick', SelectChangeEventData & {
|
||||
event: MouseEvent;
|
||||
infoWindow: InfoWindow;
|
||||
infoWindowContentDom: HTMLDivElement;
|
||||
}>;
|
||||
willClear: Event<'willClear', {
|
||||
id: string;
|
||||
index: number;
|
||||
data: Poi[];
|
||||
}>;
|
||||
markerDestoryed: Event<'markerDestoryed', SelectChangeEventData>; // typo in source code
|
||||
listElementDetroyed: Event<'listElementDetroyed', SelectChangeEventData>; // typo too
|
||||
}
|
||||
|
||||
interface SelectChangeEventData {
|
||||
/**
|
||||
* 当前选中的POI的ID
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* 索引
|
||||
*/
|
||||
index: number;
|
||||
/**
|
||||
* 当前选中的POI对应的在地图中的Marker对象
|
||||
*/
|
||||
marker: Marker;
|
||||
/**
|
||||
* 当前选中的POI在结果面板中对应的列表项
|
||||
*/
|
||||
listElement: HTMLLIElement;
|
||||
/**
|
||||
* 当前选中的POI的信息
|
||||
*/
|
||||
data: Poi[];
|
||||
}
|
||||
type SelectChangeEvent<N extends string, E> = Event<N, SelectChangeEventData & {
|
||||
event: E;
|
||||
}>;
|
||||
interface PoiPhoto {
|
||||
/**
|
||||
* 图片名称
|
||||
*/
|
||||
title: string;
|
||||
/**
|
||||
* 图片url
|
||||
*/
|
||||
url: string;
|
||||
}
|
||||
interface PoiBase {
|
||||
/**
|
||||
* 全局唯一ID
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* 兴趣点类型
|
||||
*/
|
||||
type: string;
|
||||
/**
|
||||
* 兴趣点经纬度
|
||||
*/
|
||||
location: LngLat | null;
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
address: string;
|
||||
/**
|
||||
* 离中心点距离
|
||||
*/
|
||||
distance: number;
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
tel: string;
|
||||
shopinfo: string;
|
||||
children?: any[]; // TODO Array<{location: LngLat | null}>
|
||||
}
|
||||
interface Groupbuy {
|
||||
/**
|
||||
* 团购标题
|
||||
*/
|
||||
title: string;
|
||||
/**
|
||||
* 团购分类代码
|
||||
*/
|
||||
type_code: string;
|
||||
/**
|
||||
* 团购分类
|
||||
*/
|
||||
type: string;
|
||||
/**
|
||||
* 团购详情
|
||||
*/
|
||||
detail: string;
|
||||
/**
|
||||
* 团购开始时间
|
||||
*/
|
||||
stime: string;
|
||||
/**
|
||||
* 团购结束时间
|
||||
*/
|
||||
etime: string;
|
||||
/**
|
||||
* 团购总量
|
||||
*/
|
||||
count: number;
|
||||
/**
|
||||
* 已卖出数量
|
||||
*/
|
||||
sold_num: number;
|
||||
/**
|
||||
* 原价
|
||||
*/
|
||||
original_price: number;
|
||||
/**
|
||||
* 折扣价
|
||||
*/
|
||||
groupbuy_price: number;
|
||||
/**
|
||||
* 折扣
|
||||
*/
|
||||
discount: number;
|
||||
/**
|
||||
* 取票地址
|
||||
*/
|
||||
ticket_address: string;
|
||||
/**
|
||||
* 取票电话
|
||||
*/
|
||||
ticket_tel: string;
|
||||
/**
|
||||
* 图片信息
|
||||
*/
|
||||
photos: PoiPhoto[];
|
||||
/**
|
||||
* 来源url
|
||||
*/
|
||||
url: string;
|
||||
/**
|
||||
* 来源标识
|
||||
*/
|
||||
provider: string;
|
||||
}
|
||||
interface Discount {
|
||||
/**
|
||||
* 优惠标题
|
||||
*/
|
||||
title: string;
|
||||
/**
|
||||
* 优惠详情
|
||||
*/
|
||||
detail: string;
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
start_time: string;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
end_time: string;
|
||||
/**
|
||||
* 已卖出数量
|
||||
*/
|
||||
sold_num: number;
|
||||
/**
|
||||
* 图片信息列表
|
||||
*/
|
||||
photos: PoiPhoto[];
|
||||
/**
|
||||
* 来源url
|
||||
*/
|
||||
url: string;
|
||||
/**
|
||||
* 来源标识
|
||||
*/
|
||||
provider: string;
|
||||
}
|
||||
interface Cinema {
|
||||
/**
|
||||
* 简介
|
||||
*/
|
||||
intro: string;
|
||||
/**
|
||||
* 综合评分
|
||||
*/
|
||||
rating: string;
|
||||
/**
|
||||
* 信息来源
|
||||
*/
|
||||
deep_src: string;
|
||||
/**
|
||||
* 停车场设施
|
||||
*/
|
||||
parking: string;
|
||||
/**
|
||||
* 规范格式的营业时间
|
||||
*/
|
||||
opentime_GDF: string;
|
||||
/**
|
||||
* 非规范格式的营业时间
|
||||
*/
|
||||
opentime: string;
|
||||
/**
|
||||
* 图片信息列表
|
||||
*/
|
||||
photos: PoiPhoto[];
|
||||
}
|
||||
interface Dining {
|
||||
/**
|
||||
* 菜系
|
||||
*/
|
||||
cuisines: string;
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
tag: string;
|
||||
/**
|
||||
* 简介
|
||||
*/
|
||||
intro: string;
|
||||
/**
|
||||
* 综合评分
|
||||
*/
|
||||
rating: string;
|
||||
/**
|
||||
* 单数据源的评分
|
||||
*/
|
||||
cp_rating: string;
|
||||
/**
|
||||
* 信息来源
|
||||
*/
|
||||
deep_src: string;
|
||||
/**
|
||||
* 口味评分
|
||||
*/
|
||||
taste_rating: string;
|
||||
/**
|
||||
* 环境评分
|
||||
*/
|
||||
environment_rating: string;
|
||||
/**
|
||||
* 服务评分
|
||||
*/
|
||||
service_rating: string;
|
||||
/**
|
||||
* 人均消费
|
||||
*/
|
||||
cost: string;
|
||||
/**
|
||||
* 特色菜
|
||||
*/
|
||||
recommend: string;
|
||||
/**
|
||||
* 氛围
|
||||
*/
|
||||
atmosphere: string;
|
||||
/**
|
||||
* 订餐wap链接
|
||||
*/
|
||||
ordering_wap_url: string;
|
||||
/**
|
||||
* 订餐web链接
|
||||
*/
|
||||
ordering_web_url: string;
|
||||
/**
|
||||
* 订餐APP URL
|
||||
*/
|
||||
ordering_app_url: string;
|
||||
/**
|
||||
* 规范格式的营业时间
|
||||
*/
|
||||
opentime_GDF: string;
|
||||
/**
|
||||
* 非规范格式的营业时间
|
||||
*/
|
||||
opentime: string;
|
||||
/**
|
||||
* 餐厅特色
|
||||
*/
|
||||
addition: string;
|
||||
/**
|
||||
* 图片信息列表
|
||||
*/
|
||||
photos: PoiPhoto[];
|
||||
}
|
||||
interface Scenic {
|
||||
/**
|
||||
* 简介
|
||||
*/
|
||||
intro: string;
|
||||
/**
|
||||
* 综合评分
|
||||
*/
|
||||
rating: string;
|
||||
/**
|
||||
* 信息来源
|
||||
*/
|
||||
deep_src: string;
|
||||
/**
|
||||
* 景区国标级别
|
||||
*/
|
||||
level: string;
|
||||
/**
|
||||
* 门票价格
|
||||
*/
|
||||
price: string;
|
||||
/**
|
||||
* 适合游玩的季节
|
||||
*/
|
||||
season: string;
|
||||
/**
|
||||
* 推荐景点
|
||||
*/
|
||||
recommend: string;
|
||||
/**
|
||||
* 景区主题
|
||||
*/
|
||||
theme: string;
|
||||
/**
|
||||
* wap购票链接
|
||||
*/
|
||||
ordering_wap_url: string;
|
||||
/**
|
||||
* web购票链接
|
||||
*/
|
||||
ordering_web_url: string;
|
||||
/**
|
||||
* 规范格式的营业时间
|
||||
*/
|
||||
opentime_GDF: string;
|
||||
/**
|
||||
* 非规范格式的营业时间
|
||||
*/
|
||||
opentime: string;
|
||||
/**
|
||||
* 图片信息列表
|
||||
*/
|
||||
photos: PoiPhoto[];
|
||||
}
|
||||
interface Hotel {
|
||||
/**
|
||||
* 综合评分
|
||||
*/
|
||||
rating: string;
|
||||
/**
|
||||
* 星级
|
||||
*/
|
||||
star: string;
|
||||
/**
|
||||
* 简介
|
||||
*/
|
||||
intro: string;
|
||||
/**
|
||||
* 最低房价
|
||||
*/
|
||||
lowest_price: string;
|
||||
/**
|
||||
* 设施评分
|
||||
*/
|
||||
faci_rating: string;
|
||||
/**
|
||||
* 卫生评分
|
||||
*/
|
||||
health_rating: string;
|
||||
/**
|
||||
* 环境评分
|
||||
*/
|
||||
environment_rating: string;
|
||||
/**
|
||||
* 服务评分
|
||||
*/
|
||||
service_rating: string;
|
||||
/**
|
||||
* 交通提示
|
||||
*/
|
||||
traffic: string;
|
||||
/**
|
||||
* 特色服务
|
||||
*/
|
||||
addition: string;
|
||||
/**
|
||||
* 信息来源
|
||||
*/
|
||||
deep_src: string;
|
||||
/**
|
||||
* 图片信息列表
|
||||
*/
|
||||
photos: PoiPhoto[];
|
||||
}
|
||||
type PoiExt = PoiBase & {
|
||||
/**
|
||||
* 网址
|
||||
*/
|
||||
website: string;
|
||||
/**
|
||||
* 所在省份编码
|
||||
*/
|
||||
pcode: string;
|
||||
/**
|
||||
* 所在城市编码
|
||||
*/
|
||||
citycode: string;
|
||||
/**
|
||||
* 所在区域编码
|
||||
*/
|
||||
adcode: string;
|
||||
/**
|
||||
* 邮编
|
||||
*/
|
||||
postcode: string;
|
||||
/**
|
||||
* 所在省份
|
||||
*/
|
||||
pname: string;
|
||||
/**
|
||||
* 所在城市名称
|
||||
*/
|
||||
cityname: string;
|
||||
/**
|
||||
* 所在行政区名称
|
||||
*/
|
||||
adname: string;
|
||||
/**
|
||||
* 电子邮箱
|
||||
*/
|
||||
email: string;
|
||||
/**
|
||||
* 照片
|
||||
*/
|
||||
photos: PoiPhoto[];
|
||||
/**
|
||||
* 入口经纬度
|
||||
*/
|
||||
entr_location: LngLat | null;
|
||||
/**
|
||||
* 出口经纬度
|
||||
*/
|
||||
exit_location: LngLat | null;
|
||||
/**
|
||||
* @deprecated 是否有团购信息
|
||||
*/
|
||||
groupbuy: boolean;
|
||||
/**
|
||||
* @deprecated 是否有优惠信息
|
||||
*/
|
||||
discount: boolean;
|
||||
} & ({
|
||||
indoor_map: true;
|
||||
indoor_data: {
|
||||
cpid: string;
|
||||
floor: string;
|
||||
truefloor: string;
|
||||
};
|
||||
} | {
|
||||
indoor_map: false;
|
||||
}) & {
|
||||
/**
|
||||
* @deprecated 团购信息
|
||||
*/
|
||||
groupbuys?: Groupbuy[];
|
||||
/**
|
||||
* @deprecated 优惠信息
|
||||
*/
|
||||
discounts?: Discount[];
|
||||
} & ({
|
||||
deep_type: 'CINEMA';
|
||||
/**
|
||||
* @deprecated 影院类深度信息
|
||||
*/
|
||||
cinema: Cinema;
|
||||
} | {
|
||||
deep_type: 'DINING';
|
||||
/**
|
||||
* @deprecated 餐饮类深度信息
|
||||
*/
|
||||
dining: Dining;
|
||||
} | {
|
||||
deep_type: 'SCENIC';
|
||||
/**
|
||||
* @deprecated 景点类深度信息
|
||||
*/
|
||||
scenic: Scenic;
|
||||
} | {
|
||||
deep_type: 'HOTEL';
|
||||
/**
|
||||
* @deprecated 酒店类深度信息
|
||||
*/
|
||||
hotel: Hotel;
|
||||
});
|
||||
interface Options {
|
||||
/**
|
||||
* 兴趣点城市
|
||||
*/
|
||||
city?: string;
|
||||
/**
|
||||
* 是否强制限制在设置的城市内搜索
|
||||
*/
|
||||
citylimit?: boolean;
|
||||
/**
|
||||
* 是否按照层级展示子POI数据
|
||||
* children=1,展示子节点POI数据,children=0,不展示子节点数据
|
||||
*/
|
||||
children?: number;
|
||||
/**
|
||||
* 兴趣点类别,多个类别用“|”分割
|
||||
*/
|
||||
type?: string;
|
||||
/**
|
||||
* 检索语言类型
|
||||
*/
|
||||
lang?: Lang;
|
||||
/**
|
||||
* 单页显示结果条数
|
||||
*/
|
||||
pageSize?: number;
|
||||
/**
|
||||
* 页码
|
||||
*/
|
||||
pageIndex?: number;
|
||||
/**
|
||||
* 是否返回详细信息
|
||||
* base返回基本地址信息;all返回基本+详细信息
|
||||
*/
|
||||
extensions?: 'base' | 'all';
|
||||
/**
|
||||
* Map对象
|
||||
*/
|
||||
map?: Map;
|
||||
/**
|
||||
* 结果列表的HTML容器id或容器元素
|
||||
*/
|
||||
panel?: string | HTMLElement;
|
||||
/**
|
||||
* 是否在地图上显示周边搜索的圆或者范围搜索的多边形
|
||||
*/
|
||||
showCover?: boolean;
|
||||
/**
|
||||
* 绘制的UI风格
|
||||
*/
|
||||
renderStyle?: 'newpc' | 'default';
|
||||
/**
|
||||
* 是否自动调整地图视野使绘制的Marker点都处于视口的可见范围
|
||||
*/
|
||||
autoFitView?: boolean;
|
||||
|
||||
// internal
|
||||
renderEngine?: string;
|
||||
rankBy?: string;
|
||||
}
|
||||
interface PoiList {
|
||||
/**
|
||||
* Poi列表
|
||||
*/
|
||||
pois: Poi[]; // PlaceSearchPoiBase[] | PlaceSearchPoiExt[];
|
||||
/**
|
||||
* 页码
|
||||
*/
|
||||
pageIndex: number;
|
||||
/**
|
||||
* 单页结果数
|
||||
*/
|
||||
pageSize: number;
|
||||
/**
|
||||
* 查询结果总数
|
||||
*/
|
||||
count: number;
|
||||
}
|
||||
interface CityInfo {
|
||||
/**
|
||||
* 建议城市名称
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* 城市编码
|
||||
*/
|
||||
citycode: string;
|
||||
/**
|
||||
* 行政区编码
|
||||
*/
|
||||
adcode: string;
|
||||
/**
|
||||
* 该城市的建议结果数目
|
||||
*/
|
||||
count: number;
|
||||
}
|
||||
interface SearchResult {
|
||||
/**
|
||||
* 成功状态说明
|
||||
*/
|
||||
info: string;
|
||||
/**
|
||||
* 兴趣点列表
|
||||
*/
|
||||
poiList: PoiList;
|
||||
/**
|
||||
* 建议关键字列表
|
||||
*/
|
||||
keywordList?: string[];
|
||||
/**
|
||||
* 城市建议列表
|
||||
*/
|
||||
cityList?: CityInfo[];
|
||||
}
|
||||
type Poi = PoiBase | PoiExt;
|
||||
type SearchStatus = 'complete' | 'error' | 'no_data';
|
||||
}
|
||||
class PlaceSearch extends EventEmitter {
|
||||
/**
|
||||
* 地点搜索服务
|
||||
* @param options 选项
|
||||
*/
|
||||
constructor(options?: PlaceSearch.Options);
|
||||
/**
|
||||
* 根据关键字搜索
|
||||
* @param keyword 根据关键字搜索
|
||||
* @param callback 回调
|
||||
*/
|
||||
search(
|
||||
keyword: string,
|
||||
callback: (status: PlaceSearch.SearchStatus, result: string | PlaceSearch.SearchResult) => void
|
||||
): void;
|
||||
/**
|
||||
* 周边查询
|
||||
* @param keyword 关键字
|
||||
* @param center 搜索中心
|
||||
* @param radius 搜索半径
|
||||
* @param callback 回调
|
||||
*/
|
||||
searchNearBy(
|
||||
keyword: string,
|
||||
center: LocationValue,
|
||||
radius: number,
|
||||
callback: (status: PlaceSearch.SearchStatus, result: string | PlaceSearch.SearchResult) => void
|
||||
): void;
|
||||
/**
|
||||
* 根据范围和关键词进行范围查询
|
||||
* @param keyword 关键字
|
||||
* @param bounds 搜索范围
|
||||
* @param callback 回调
|
||||
*/
|
||||
searchInBounds(
|
||||
keyword: string,
|
||||
bounds: Bounds | Polygon,
|
||||
callback: (status: PlaceSearch.SearchStatus, result: string | PlaceSearch.SearchResult) => void
|
||||
): void;
|
||||
/**
|
||||
* 根据POIID 查询POI 详细信息
|
||||
* @param POIID POIID
|
||||
* @param callback 搜索回调
|
||||
*/
|
||||
getDetails(
|
||||
POIID: string,
|
||||
callback: (status: PlaceSearch.SearchStatus, result: string | PlaceSearch.SearchResult) => void
|
||||
): void;
|
||||
/**
|
||||
* 设置查询类别
|
||||
* @param type 查询类别
|
||||
*/
|
||||
setType(type?: string): void;
|
||||
/**
|
||||
* 设置是否强制限制城市
|
||||
* @param limit 是否强制限制城市
|
||||
*/
|
||||
setCityLimit(limit?: boolean): void;
|
||||
/**
|
||||
* 设置查询结果特定页数
|
||||
* @param pageIndex 页码
|
||||
*/
|
||||
setPageIndex(pageIndex?: number): void;
|
||||
/**
|
||||
* 设置查询单页结果数
|
||||
* @param pageSize 结果数
|
||||
*/
|
||||
setPageSize(pageSize?: number): void;
|
||||
/**
|
||||
* 设置查询城市
|
||||
* @param city 城市
|
||||
*/
|
||||
setCity(city?: string): void;
|
||||
/**
|
||||
* 设置检索语言类型
|
||||
* @param lang 语言类型
|
||||
*/
|
||||
setLang(lang?: Lang): void;
|
||||
/**
|
||||
* 获取检索语言类型
|
||||
*/
|
||||
getLang(): Lang | undefined;
|
||||
/**
|
||||
* 清除搜索结果
|
||||
*/
|
||||
clear(): void;
|
||||
/**
|
||||
* 唤起高德地图客户端marker页
|
||||
* @param obj 唤起参数
|
||||
*/
|
||||
poiOnAMAP(obj: { location?: LocationValue; id: string; name?: string; }): void;
|
||||
/**
|
||||
* 唤起高德地图客户端POI详情页
|
||||
* @param obj 唤起参数
|
||||
*/
|
||||
detailOnAMAP(obj: { location?: LocationValue; id: string; name?: string; }): void;
|
||||
|
||||
// internal
|
||||
open(): void;
|
||||
close(): void;
|
||||
}
|
||||
}
|
||||
24
types/amap-js-api-place-search/tsconfig.json
Normal file
24
types/amap-js-api-place-search/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-place-search-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/amap-js-api-place-search/tslint.json
Normal file
3
types/amap-js-api-place-search/tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user