@uiw/react-amap-map
Advanced tools
Comparing version 2.5.1 to 2.6.0
@@ -6,3 +6,3 @@ /// <reference types="@uiw/react-amap-types" /> | ||
declare type RenderProps = { | ||
children: (data: { | ||
children?: (data: { | ||
AMap: typeof AMap; | ||
@@ -13,3 +13,3 @@ map: AMap.Map; | ||
} | { | ||
children: React.ReactNode; | ||
children?: React.ReactNode; | ||
}; | ||
@@ -19,2 +19,3 @@ export interface MapProps extends AMap.MapEvents, AMap.MapOptions { | ||
style?: React.HTMLAttributes<HTMLDivElement>['style']; | ||
container?: HTMLDivElement | null; | ||
} | ||
@@ -21,0 +22,0 @@ export declare const Map: import("react").ForwardRefExoticComponent<(MapProps & RenderProps) & import("react").RefAttributes<MapProps & { |
@@ -66,3 +66,3 @@ "use strict"; | ||
var _useMap = (0, _useMap2.useMap)((0, _objectSpread2["default"])({ | ||
container: elmRef.current | ||
container: props.container || elmRef.current | ||
}, props)), | ||
@@ -80,3 +80,3 @@ setContainer = _useMap.setContainer, | ||
AMap: AMap, | ||
container: elmRef.current | ||
container: props.container || elmRef.current | ||
}); | ||
@@ -101,3 +101,3 @@ }, [map]); | ||
}, | ||
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", { | ||
children: [!props.container && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", { | ||
ref: elmRef, | ||
@@ -104,0 +104,0 @@ className: className, |
@@ -48,5 +48,10 @@ "use strict"; | ||
if (container && !map && AMap) { | ||
instance = new AMap.Map(container, (0, _objectSpread2["default"])({ | ||
var wapper = document.createElement('div'); | ||
wapper.className = 'react-amap-wapper'; | ||
wapper.style.height = '100%'; | ||
wapper.style.width = '100%'; | ||
instance = new AMap.Map(wapper, (0, _objectSpread2["default"])({ | ||
zoom: zoom | ||
}, other)); | ||
container.appendChild(wapper); | ||
setMap(instance); | ||
@@ -58,2 +63,5 @@ } | ||
instance.destroy(); | ||
instance.clearMap(); | ||
instance.clearInfoWindow(); | ||
instance.clearLimitBounds(); | ||
setMap(undefined); | ||
@@ -60,0 +68,0 @@ } |
@@ -6,3 +6,3 @@ /// <reference types="@uiw/react-amap-types" /> | ||
declare type RenderProps = { | ||
children: (data: { | ||
children?: (data: { | ||
AMap: typeof AMap; | ||
@@ -13,3 +13,3 @@ map: AMap.Map; | ||
} | { | ||
children: React.ReactNode; | ||
children?: React.ReactNode; | ||
}; | ||
@@ -19,2 +19,3 @@ export interface MapProps extends AMap.MapEvents, AMap.MapOptions { | ||
style?: React.HTMLAttributes<HTMLDivElement>['style']; | ||
container?: HTMLDivElement | null; | ||
} | ||
@@ -21,0 +22,0 @@ export declare const Map: import("react").ForwardRefExoticComponent<(MapProps & RenderProps) & import("react").RefAttributes<MapProps & { |
@@ -27,3 +27,3 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
} = useMap(_extends({ | ||
container: elmRef.current | ||
container: props.container || elmRef.current | ||
}, props)); | ||
@@ -34,3 +34,3 @@ useEffect(() => setContainer(elmRef.current), [elmRef.current]); | ||
AMap, | ||
container: elmRef.current | ||
container: props.container || elmRef.current | ||
}), [map]); | ||
@@ -52,3 +52,3 @@ var childs = Children.toArray(children); | ||
}, | ||
children: [/*#__PURE__*/_jsx("div", { | ||
children: [!props.container && /*#__PURE__*/_jsx("div", { | ||
ref: elmRef, | ||
@@ -55,0 +55,0 @@ className: className, |
@@ -22,5 +22,10 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
if (container && !map && AMap) { | ||
instance = new AMap.Map(container, _extends({ | ||
var wapper = document.createElement('div'); | ||
wapper.className = 'react-amap-wapper'; | ||
wapper.style.height = '100%'; | ||
wapper.style.width = '100%'; | ||
instance = new AMap.Map(wapper, _extends({ | ||
zoom | ||
}, other)); | ||
container.appendChild(wapper); | ||
setMap(instance); | ||
@@ -32,2 +37,5 @@ } | ||
instance.destroy(); | ||
instance.clearMap(); | ||
instance.clearInfoWindow(); | ||
instance.clearLimitBounds(); | ||
setMap(undefined); | ||
@@ -34,0 +42,0 @@ } |
{ | ||
"name": "@uiw/react-amap-map", | ||
"version": "2.5.1", | ||
"version": "2.6.0", | ||
"description": "基于 React 封装的高德地图组件。AMap Component Based On React.", | ||
@@ -34,4 +34,4 @@ "homepage": "https://uiwjs.github.io/react-amap/#/map", | ||
"dependencies": { | ||
"@uiw/react-amap-types": "2.5.1", | ||
"@uiw/react-amap-utils": "2.5.1" | ||
"@uiw/react-amap-types": "2.6.0", | ||
"@uiw/react-amap-utils": "2.6.0" | ||
}, | ||
@@ -38,0 +38,0 @@ "devDependencies": { |
@@ -281,2 +281,3 @@ Map 组件 | ||
|--------- |-------- |--------- |-------- | | ||
| container | (**默认不需要传递**) 构造一个地图对象,参数 container 中传入地图容器 DIV 对象。<br />注意:地图容器在创建之前必须拥有实际大小,否则可能出现底图无法渲染的问题。 | `HTMLDivElement` | - | | ||
| center | 初始中心经纬度 | `[number, number] \| LngLat` | - | | ||
@@ -283,0 +284,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64027
787
316
+ Added@uiw/react-amap-types@2.6.0(transitive)
+ Added@uiw/react-amap-utils@2.6.0(transitive)
- Removed@uiw/react-amap-types@2.5.1(transitive)
- Removed@uiw/react-amap-utils@2.5.1(transitive)
Updated@uiw/react-amap-types@2.6.0
Updated@uiw/react-amap-utils@2.6.0