Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/optimize auto complete #285

Merged
merged 20 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
77f55fc
feat:修复 LabelMarker,以便兼容高德地图JS API v1.4.xxx。
peidongGuo Dec 5, 2022
9163710
Merge pull request #1 from peidongGuo/feature/fixLabelMarker
peidongGuo Dec 5, 2022
336e9c0
fix:修复细节
peidongGuo Dec 5, 2022
657ca76
Merge pull request #2 from peidongGuo/feature/fixLabelMarker
peidongGuo Dec 5, 2022
8a5a399
feat:添加Polyline-Editor Poly-Editor组件项目,修改PolyLine、Polygon、PolygonEdit…
peidongGuo Dec 6, 2022
b1646f7
Merge branch 'uiwjs:master' into master
peidongGuo Dec 6, 2022
4642651
Merge pull request #3 from peidongGuo/feature/addPolyEditor
peidongGuo Dec 6, 2022
9f61a1e
feat:添加MouseTool组件项目,以便支持 MouseTool 插件功能。
peidongGuo Dec 7, 2022
2f662d3
Merge pull request #4 from peidongGuo/feature/addMouseTool
peidongGuo Dec 7, 2022
70f1779
解决PR时的冲突
peidongGuo Dec 7, 2022
d20aef0
Merge branch 'master' into feature/addMouseTool
peidongGuo Dec 7, 2022
5d30c96
Merge pull request #5 from peidongGuo/feature/addMouseTool
peidongGuo Dec 7, 2022
14c20c6
Merge branch 'uiwjs:master' into master
peidongGuo Dec 7, 2022
c114927
Merge branch 'uiwjs:master' into master
peidongGuo Dec 8, 2022
9d7d2a3
Merge branch 'uiwjs:master' into master
peidongGuo Dec 8, 2022
169150b
Merge branch 'uiwjs:master' into master
peidongGuo Dec 9, 2022
afe9417
Merge branch 'uiwjs:master' into master
peidongGuo Dec 11, 2022
aab9525
Merge branch 'uiwjs:master' into master
peidongGuo Jan 10, 2023
c35f894
Merge branch 'uiwjs:master' into master
peidongGuo Jan 11, 2023
782e57e
feat:优化 AutoComplete,让其支持 V1.x.xx 版本 API
peidongGuo Jan 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/auto-complete/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const Example = () => {
}

const Mount = () => (
<APILoader akay="a7a90e05a37d3f6bf76d4a9032fc9129">
<APILoader akay="59f5427313d130faa39c947b5eb92503">
<Example />
</APILoader>
);
Expand Down
17 changes: 13 additions & 4 deletions packages/auto-complete/src/useAutoComplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@ export const useAutoComplete = (props = {} as UseAutoComplete) => {
useEffect(() => {
if (AMap && !autoComplete) {
let instance: AMap.AutoComplete;
AMap.plugin(['AMap.AutoComplete'], () => {
instance = new AMap.AutoComplete(props);
setAutoComplete(instance);
});

if (AMap.v) {
AMap.plugin(['AMap.Autocomplete'], () => {
instance = new AMap.Autocomplete(props);
setAutoComplete(instance);
});
} else {
AMap.plugin(['AMap.AutoComplete'], () => {
instance = new AMap.AutoComplete(props);
setAutoComplete(instance);
});
}

return () => {
if (instance) {
setAutoComplete(undefined);
Expand Down
7 changes: 6 additions & 1 deletion packages/types/src/base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ declare global {
}

declare namespace AMap {
const version: string;
/** 1.x.xx 版本 API,版本号用的是这个字段 */
const v:string;

/** 2.x.xx 版本 API,版本号用的是这个字段 */
const version: string;

/**
* 经纬度坐标,用来描述地图上的一个点位置, 目前高德地图使用的是 GCJ-02 坐标,如果你采集的是 WGS84 坐标,请先进行坐标转换
*/
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ declare namespace AMap {
}
type ControlType =
'AMap.AutoComplete' |
'AMap.Autocomplete' |
'AMap.ControlBar' |
'AMap.CloudDataSearch' |
'AMap.Driving' |
Expand Down
15 changes: 15 additions & 0 deletions packages/types/src/services.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,19 @@ declare namespace AMap {
/**类型 */
type: string;
}

/**
* 根据输入关键字提示匹配信息,可将Poi类型和城市作为输入提示的限制条件。用户可以通过自定义回调函数取回并显
*/
class Autocomplete extends MapEventListener<'choose' | 'select'> {
constructor(opts: AutoCompleteOptions);
/** 设置提示Poi类型,多个类型用“|”分隔,POI相关类型请在网站“相关下载”处下载,目前只支持Poi类型编码如“050000” 默认值:所有类别 */
setType(type: string): void;
/** 设置城市 */
setCity(city: string): void;
/** 设置是否强制限制城市 */
setCityLimit(citylimit: boolean): void;
/** 设置是否强制限制城市 */
search(keyword?: string, callback?: (status: 'complete' | 'error' | 'no_data', result?: AutoCompleteSearchCallback) => void): void;
}
}