aio-map 3.2.2 → 3.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -2
- package/index.js +9 -15
- package/package.json +2 -3
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FC, ReactNode } from "react";
|
|
1
|
+
import { type FC, type ReactNode } from "react";
|
|
2
2
|
import * as Leaflet from 'leaflet';
|
|
3
3
|
import 'leaflet/dist/leaflet.css';
|
|
4
4
|
import './index.css';
|
|
@@ -87,7 +87,6 @@ type I_searchResult = {
|
|
|
87
87
|
before?: ReactNode;
|
|
88
88
|
after?: ReactNode;
|
|
89
89
|
};
|
|
90
|
-
export declare const smooth: (points: [number, number][], acc?: 'low' | 'medium' | 'high') => any;
|
|
91
90
|
export declare function getCenterOfPoints(points: {
|
|
92
91
|
lat: number;
|
|
93
92
|
lng: number;
|
package/index.js
CHANGED
|
@@ -13,10 +13,9 @@ import { createContext, isValidElement, useContext, useEffect, useRef, useState
|
|
|
13
13
|
import * as Leaflet from 'leaflet';
|
|
14
14
|
import * as ReactLeaflet from 'react-leaflet';
|
|
15
15
|
import MarkerClusterGroup from "react-leaflet-cluster";
|
|
16
|
-
import AIOInput from "aio-input";
|
|
16
|
+
import AIOInput from "./../../npm/aio-input";
|
|
17
17
|
import 'leaflet/dist/leaflet.css';
|
|
18
|
-
import { Debounce } from 'aio-utils';
|
|
19
|
-
import simplify from 'simplify-js';
|
|
18
|
+
import { Debounce } from '../aio-utils';
|
|
20
19
|
import './index.css';
|
|
21
20
|
const MAPCTX = createContext({});
|
|
22
21
|
const AIMap = (props) => {
|
|
@@ -28,7 +27,7 @@ const AIMap = (props) => {
|
|
|
28
27
|
const [p, setPos] = useState(propsPos);
|
|
29
28
|
const posRef = useRef(p);
|
|
30
29
|
posRef.current = p;
|
|
31
|
-
function changeZoom(newZoom
|
|
30
|
+
function changeZoom(newZoom) {
|
|
32
31
|
if (newZoom === zoomRef.current) {
|
|
33
32
|
return;
|
|
34
33
|
}
|
|
@@ -40,11 +39,12 @@ const AIMap = (props) => {
|
|
|
40
39
|
if (props.actionsRef) {
|
|
41
40
|
props.actionsRef.current = {
|
|
42
41
|
flyTo: (p) => {
|
|
43
|
-
|
|
42
|
+
const zoom = p.zoom || map.getZoom();
|
|
43
|
+
map.flyTo([p.lat, p.lng], zoom);
|
|
44
44
|
const onMoveEnd = () => {
|
|
45
45
|
map.off("moveend", onMoveEnd);
|
|
46
|
-
if (
|
|
47
|
-
changeZoom(
|
|
46
|
+
if (zoom !== zoomRef.current) {
|
|
47
|
+
changeZoom(zoom);
|
|
48
48
|
p.callback();
|
|
49
49
|
}
|
|
50
50
|
};
|
|
@@ -153,8 +153,8 @@ const MapMarker = ({ pos, html, eventHandlers }) => {
|
|
|
153
153
|
function getHtmlIcon(html) {
|
|
154
154
|
return Leaflet.divIcon({
|
|
155
155
|
html: JSXToHTML(html),
|
|
156
|
-
className: '',
|
|
157
|
-
iconSize: [32, 32],
|
|
156
|
+
className: '',
|
|
157
|
+
iconSize: [32, 32],
|
|
158
158
|
iconAnchor: [16, 32], // point of the icon which will correspond to marker's location
|
|
159
159
|
});
|
|
160
160
|
}
|
|
@@ -219,12 +219,6 @@ function AddToAttrs(attrs, p) {
|
|
|
219
219
|
let newStyle = Object.assign(Object.assign({}, attrs.style), style);
|
|
220
220
|
return Object.assign(Object.assign(Object.assign({}, attrs), { className, style: newStyle }), p.attrs);
|
|
221
221
|
}
|
|
222
|
-
export const smooth = (points, acc) => {
|
|
223
|
-
acc = acc || 'medium';
|
|
224
|
-
const points2D = points.map((p) => ({ x: p[1], y: p[0] })); // simplify-js با x,y کار میکنه
|
|
225
|
-
const simplified = simplify(points2D, acc === 'low' ? 0.001 : (acc === 'medium' ? 0.002 : 0.003), true); // 10 = tolerance (متر تقریبی), true = highQuality
|
|
226
|
-
return simplified.map(p => ([p.y, p.x]));
|
|
227
|
-
};
|
|
228
222
|
export function getCenterOfPoints(points) {
|
|
229
223
|
const filteredPoints = points.filter(({ lat, lng }) => typeof lat === 'number' && typeof lng === 'number');
|
|
230
224
|
let totalLat = 0, totalLng = 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aio-map",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"main": "index.js",
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
"aio-input": "latest",
|
|
17
17
|
"leaflet": "^1.9.4",
|
|
18
18
|
"react-leaflet": "^5.0.0",
|
|
19
|
-
"react-leaflet-cluster": "^2.1.0"
|
|
20
|
-
"simplify-js": "^1.2.4"
|
|
19
|
+
"react-leaflet-cluster": "^2.1.0"
|
|
21
20
|
},
|
|
22
21
|
"author": "mohammad sharif feiz feiz.ms@gmail.com",
|
|
23
22
|
"license": "ISC",
|