@neshan-maps-platform/react-openlayers 2.0.13 → 2.0.15
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/README.md
CHANGED
|
@@ -70,7 +70,7 @@ English | [Português](./README-pt_BR.md) | [简体中文](./README-zh_CN.md) |
|
|
|
70
70
|
You need a map key to use our map on your react web application.
|
|
71
71
|
You can signup and get a key from [Our Platfrom](https://platform.neshan.org/panel/api-key).
|
|
72
72
|
<br/>
|
|
73
|
-
For
|
|
73
|
+
For more information, visit our [doc page](https://platform.neshan.org/sdk/react-component#).
|
|
74
74
|
|
|
75
75
|
|
|
76
76
|
## 📦 Install
|
|
@@ -83,14 +83,20 @@ npm install @neshan-maps-platform/react-openlayers
|
|
|
83
83
|
yarn add @neshan-maps-platform/react-openlayers
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
+
If you want full type defenitions including openlayers types, you need to install them as dev dependency.
|
|
87
|
+
```bash
|
|
88
|
+
yarn add -D @types/ol@5
|
|
89
|
+
```
|
|
90
|
+
|
|
86
91
|
## 🔨 Usage
|
|
87
92
|
|
|
88
93
|
```jsx
|
|
89
94
|
import { useEffect, useRef, useState } from "react"
|
|
90
95
|
import "@neshan-maps-platform/react-openlayers/dist/style.css"
|
|
91
96
|
|
|
97
|
+
import { NeshanMap } from "@neshan-maps-platform/react-openlayers"
|
|
92
98
|
// If you want to use ol types like below, your project has to support typescript.
|
|
93
|
-
import {
|
|
99
|
+
import { NeshanMapRef, OlMap, Ol } from "@neshan-maps-platform/react-openlayers"
|
|
94
100
|
|
|
95
101
|
function App() {
|
|
96
102
|
const mapRef = useRef<NeshanMapRef | null>(null)
|
package/dist/React-Openlayers.js
CHANGED
|
@@ -22,15 +22,15 @@ function Er() {
|
|
|
22
22
|
return L;
|
|
23
23
|
Fe = 1;
|
|
24
24
|
var s = Ne, f = Symbol.for("react.element"), P = Symbol.for("react.fragment"), b = Object.prototype.hasOwnProperty, v = s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, F = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
25
|
-
function A(
|
|
25
|
+
function A(O, m, x) {
|
|
26
26
|
var _, T = {}, j = null, C = null;
|
|
27
|
-
|
|
27
|
+
x !== void 0 && (j = "" + x), m.key !== void 0 && (j = "" + m.key), m.ref !== void 0 && (C = m.ref);
|
|
28
28
|
for (_ in m)
|
|
29
29
|
b.call(m, _) && !F.hasOwnProperty(_) && (T[_] = m[_]);
|
|
30
|
-
if (
|
|
31
|
-
for (_ in m =
|
|
30
|
+
if (O && O.defaultProps)
|
|
31
|
+
for (_ in m = O.defaultProps, m)
|
|
32
32
|
T[_] === void 0 && (T[_] = m[_]);
|
|
33
|
-
return { $$typeof: f, type:
|
|
33
|
+
return { $$typeof: f, type: O, key: j, ref: C, props: T, _owner: v.current };
|
|
34
34
|
}
|
|
35
35
|
return L.Fragment = P, L.jsx = A, L.jsxs = A, L;
|
|
36
36
|
}
|
|
@@ -47,7 +47,7 @@ var W = {};
|
|
|
47
47
|
var Me;
|
|
48
48
|
function br() {
|
|
49
49
|
return Me || (Me = 1, process.env.NODE_ENV !== "production" && function() {
|
|
50
|
-
var s = Ne, f = Symbol.for("react.element"), P = Symbol.for("react.portal"), b = Symbol.for("react.fragment"), v = Symbol.for("react.strict_mode"), F = Symbol.for("react.profiler"), A = Symbol.for("react.provider"),
|
|
50
|
+
var s = Ne, f = Symbol.for("react.element"), P = Symbol.for("react.portal"), b = Symbol.for("react.fragment"), v = Symbol.for("react.strict_mode"), F = Symbol.for("react.profiler"), A = Symbol.for("react.provider"), O = Symbol.for("react.context"), m = Symbol.for("react.forward_ref"), x = Symbol.for("react.suspense"), _ = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), j = Symbol.for("react.lazy"), C = Symbol.for("react.offscreen"), S = Symbol.iterator, Y = "@@iterator";
|
|
51
51
|
function H(e) {
|
|
52
52
|
if (e === null || typeof e != "object")
|
|
53
53
|
return null;
|
|
@@ -75,7 +75,7 @@ function br() {
|
|
|
75
75
|
var X = !1, $ = !1, Z = !1, Q = !1, ee = !1, V;
|
|
76
76
|
V = Symbol.for("react.module.reference");
|
|
77
77
|
function B(e) {
|
|
78
|
-
return !!(typeof e == "string" || typeof e == "function" || e === b || e === F || ee || e === v || e ===
|
|
78
|
+
return !!(typeof e == "string" || typeof e == "function" || e === b || e === F || ee || e === v || e === x || e === _ || Q || e === C || X || $ || Z || typeof e == "object" && e !== null && (e.$$typeof === j || e.$$typeof === T || e.$$typeof === A || e.$$typeof === O || e.$$typeof === m || // This needs to include all possible module reference object
|
|
79
79
|
// types supported by any Flight configuration anywhere since
|
|
80
80
|
// we don't know which Flight build this will end up being used
|
|
81
81
|
// with.
|
|
@@ -107,14 +107,14 @@ function br() {
|
|
|
107
107
|
return "Profiler";
|
|
108
108
|
case v:
|
|
109
109
|
return "StrictMode";
|
|
110
|
-
case
|
|
110
|
+
case x:
|
|
111
111
|
return "Suspense";
|
|
112
112
|
case _:
|
|
113
113
|
return "SuspenseList";
|
|
114
114
|
}
|
|
115
115
|
if (typeof e == "object")
|
|
116
116
|
switch (e.$$typeof) {
|
|
117
|
-
case
|
|
117
|
+
case O:
|
|
118
118
|
var r = e;
|
|
119
119
|
return g(r) + ".Consumer";
|
|
120
120
|
case A:
|
|
@@ -303,7 +303,7 @@ function br() {
|
|
|
303
303
|
if (typeof e == "string")
|
|
304
304
|
return U(e);
|
|
305
305
|
switch (e) {
|
|
306
|
-
case
|
|
306
|
+
case x:
|
|
307
307
|
return U("Suspense");
|
|
308
308
|
case _:
|
|
309
309
|
return U("SuspenseList");
|
|
@@ -486,7 +486,7 @@ function br() {
|
|
|
486
486
|
function ue(e) {
|
|
487
487
|
return typeof e == "object" && e !== null && e.$$typeof === f;
|
|
488
488
|
}
|
|
489
|
-
function
|
|
489
|
+
function Oe() {
|
|
490
490
|
{
|
|
491
491
|
if (ie.current) {
|
|
492
492
|
var e = l(ie.current.type);
|
|
@@ -509,10 +509,10 @@ Check your code at ` + r + ":" + t + ".";
|
|
|
509
509
|
return "";
|
|
510
510
|
}
|
|
511
511
|
}
|
|
512
|
-
var
|
|
512
|
+
var xe = {};
|
|
513
513
|
function ir(e) {
|
|
514
514
|
{
|
|
515
|
-
var r =
|
|
515
|
+
var r = Oe();
|
|
516
516
|
if (!r) {
|
|
517
517
|
var t = typeof e == "string" ? e : e.displayName || e.name;
|
|
518
518
|
t && (r = `
|
|
@@ -528,9 +528,9 @@ Check the top-level render call using <` + t + ">.");
|
|
|
528
528
|
return;
|
|
529
529
|
e._store.validated = !0;
|
|
530
530
|
var t = ir(r);
|
|
531
|
-
if (
|
|
531
|
+
if (xe[t])
|
|
532
532
|
return;
|
|
533
|
-
|
|
533
|
+
xe[t] = !0;
|
|
534
534
|
var n = "";
|
|
535
535
|
e && e._owner && e._owner !== ie.current && (n = " It was passed a child from " + l(e._owner.type) + "."), M(e), y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, n), M(null);
|
|
536
536
|
}
|
|
@@ -598,7 +598,7 @@ Check the top-level render call using <` + t + ">.");
|
|
|
598
598
|
var a = "";
|
|
599
599
|
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (a += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
|
|
600
600
|
var E = or(i);
|
|
601
|
-
E ? a += E : a +=
|
|
601
|
+
E ? a += E : a += Oe();
|
|
602
602
|
var d;
|
|
603
603
|
e === null ? d = "null" : ae(e) ? d = "array" : e !== void 0 && e.$$typeof === f ? (d = "<" + (l(e.type) || "Unknown") + " />", a = " Did you accidentally export a JSX literal instead of a component?") : d = typeof e, y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", d, a);
|
|
604
604
|
}
|
|
@@ -663,7 +663,7 @@ const Rr = "_map_1yxt5_2", Tr = "_touch_1yxt5_26", Cr = "_floaten_1yxt5_45", Pr
|
|
|
663
663
|
}, Ie = () => ({
|
|
664
664
|
longitude: 51.36281969540723,
|
|
665
665
|
latitude: 35.69672648316882
|
|
666
|
-
}),
|
|
666
|
+
}), Or = {
|
|
667
667
|
reverse: "https://api.neshan.org/v4/reverse",
|
|
668
668
|
search: "https://api.neshan.org/v1/search",
|
|
669
669
|
map: "https://static.neshan.org/sdk/openlayers/5.3.0/ol.js"
|
|
@@ -681,7 +681,7 @@ const Rr = "_map_1yxt5_2", Tr = "_touch_1yxt5_26", Cr = "_floaten_1yxt5_45", Pr
|
|
|
681
681
|
map: null,
|
|
682
682
|
mapType: "neshan",
|
|
683
683
|
mapContainer: null
|
|
684
|
-
},
|
|
684
|
+
}, xr = (s, f) => {
|
|
685
685
|
switch (f.type) {
|
|
686
686
|
case "SET_MAP":
|
|
687
687
|
return {
|
|
@@ -697,7 +697,7 @@ const Rr = "_map_1yxt5_2", Tr = "_touch_1yxt5_26", Cr = "_floaten_1yxt5_45", Pr
|
|
|
697
697
|
return $e;
|
|
698
698
|
}
|
|
699
699
|
}, jr = (s) => {
|
|
700
|
-
const [f, P] = vr(
|
|
700
|
+
const [f, P] = vr(xr, $e), b = {
|
|
701
701
|
...f,
|
|
702
702
|
setMap: (v) => {
|
|
703
703
|
P({
|
|
@@ -728,9 +728,9 @@ const Rr = "_map_1yxt5_2", Tr = "_touch_1yxt5_26", Cr = "_floaten_1yxt5_45", Pr
|
|
|
728
728
|
defaultType: v = "neshan",
|
|
729
729
|
scale: F,
|
|
730
730
|
center: A,
|
|
731
|
-
poi:
|
|
731
|
+
poi: O = !0,
|
|
732
732
|
traffic: m = !0,
|
|
733
|
-
onInit:
|
|
733
|
+
onInit: x,
|
|
734
734
|
className: _,
|
|
735
735
|
style: T
|
|
736
736
|
}, j) => {
|
|
@@ -785,19 +785,20 @@ const Rr = "_map_1yxt5_2", Tr = "_touch_1yxt5_26", Cr = "_floaten_1yxt5_45", Pr
|
|
|
785
785
|
key: f || "",
|
|
786
786
|
mapType: v,
|
|
787
787
|
// poi: store.state.poiLayer,
|
|
788
|
-
poi:
|
|
788
|
+
poi: O,
|
|
789
789
|
// traffic: store.state.trafficLayer,
|
|
790
790
|
traffic: m,
|
|
791
791
|
view: new ol.View({
|
|
792
792
|
center: ol.proj.fromLonLat(g),
|
|
793
|
-
zoom: b
|
|
794
|
-
|
|
793
|
+
zoom: b
|
|
794
|
+
// Not in ol@5
|
|
795
|
+
// smoothExtentConstraint: true,
|
|
795
796
|
// projection: 'EPSG:4326' //Default was EPSG:3857
|
|
796
797
|
}),
|
|
797
798
|
controls: [],
|
|
798
799
|
...s
|
|
799
800
|
});
|
|
800
|
-
l.setMapType(v), C.setMap(l), (h = C.map) == null || h.setMapType(v), C.setMapType(v), H(!0),
|
|
801
|
+
l.setMapType(v), C.setMap(l), (h = C.map) == null || h.setMapType(v), C.setMapType(v), H(!0), x && x(ol, l);
|
|
801
802
|
}, B = () => {
|
|
802
803
|
let u, g, l;
|
|
803
804
|
return u = new Promise((h, D) => {
|
|
@@ -813,7 +814,7 @@ const Rr = "_map_1yxt5_2", Tr = "_touch_1yxt5_26", Cr = "_floaten_1yxt5_45", Pr
|
|
|
813
814
|
const u = B();
|
|
814
815
|
return () => u.cancelPromise();
|
|
815
816
|
} else {
|
|
816
|
-
const u = ee(
|
|
817
|
+
const u = ee(Or.map), g = () => {
|
|
817
818
|
B();
|
|
818
819
|
};
|
|
819
820
|
return u.addEventListener("load", g), () => u.removeEventListener("load", g);
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var de;function Be(){if(de)return W;de=1;var s=m,f=Symbol.for("react.element"),S=Symbol.for("react.fragment"),R=Object.prototype.hasOwnProperty,v=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,I={key:!0,ref:!0,__self:!0,__source:!0};function F(x,y,j){var E,
|
|
9
|
+
*/var de;function Be(){if(de)return W;de=1;var s=m,f=Symbol.for("react.element"),S=Symbol.for("react.fragment"),R=Object.prototype.hasOwnProperty,v=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,I={key:!0,ref:!0,__self:!0,__source:!0};function F(x,y,j){var E,P={},k=null,C=null;j!==void 0&&(k=""+j),y.key!==void 0&&(k=""+y.key),y.ref!==void 0&&(C=y.ref);for(E in y)R.call(y,E)&&!I.hasOwnProperty(E)&&(P[E]=y[E]);if(x&&x.defaultProps)for(E in y=x.defaultProps,y)P[E]===void 0&&(P[E]=y[E]);return{$$typeof:f,type:x,key:k,ref:C,props:P,_owner:v.current}}return W.Fragment=S,W.jsx=F,W.jsxs=F,W}var Y={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var pe;function Ue(){return pe||(pe=1,process.env.NODE_ENV!=="production"&&function(){var s=m,f=Symbol.for("react.element"),S=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),I=Symbol.for("react.profiler"),F=Symbol.for("react.provider"),x=Symbol.for("react.context"),y=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),
|
|
17
|
+
*/var pe;function Ue(){return pe||(pe=1,process.env.NODE_ENV!=="production"&&function(){var s=m,f=Symbol.for("react.element"),S=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),I=Symbol.for("react.profiler"),F=Symbol.for("react.provider"),x=Symbol.for("react.context"),y=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),C=Symbol.for("react.offscreen"),w=Symbol.iterator,U="@@iterator";function q(e){if(e===null||typeof e!="object")return null;var r=w&&e[w]||e[U];return typeof r=="function"?r:null}var O=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function h(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];ge("error",e,t)}}function ge(e,r,t){{var n=O.ReactDebugCurrentFrame,i=n.getStackAddendum();i!==""&&(r+="%s",t=t.concat([i]));var c=t.map(function(o){return String(o)});c.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,c)}}var ee=!1,z=!1,re=!1,te=!1,ne=!1,J;J=Symbol.for("react.module.reference");function G(e){return!!(typeof e=="string"||typeof e=="function"||e===R||e===I||ne||e===v||e===j||e===E||te||e===C||ee||z||re||typeof e=="object"&&e!==null&&(e.$$typeof===k||e.$$typeof===P||e.$$typeof===F||e.$$typeof===x||e.$$typeof===y||e.$$typeof===J||e.getModuleId!==void 0))}function u(e,r,t){var n=e.displayName;if(n)return n;var i=r.displayName||r.name||"";return i!==""?t+"("+i+")":t}function _(e){return e.displayName||"Context"}function l(e){if(e==null)return null;if(typeof e.tag=="number"&&h("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case R:return"Fragment";case S:return"Portal";case I:return"Profiler";case v:return"StrictMode";case j:return"Suspense";case E:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case x:var r=e;return _(r)+".Consumer";case F:var t=e;return _(t._context)+".Provider";case y:return u(e,e.render,"ForwardRef");case P:var n=e.displayName||null;return n!==null?n:l(e.type)||"Memo";case k:{var i=e,c=i._payload,o=i._init;try{return l(o(c))}catch{return null}}}return null}var g=Object.assign,M=0,_e,Ee,be,Re,Te,Pe,Ce;function Se(){}Se.__reactDisabledLog=!0;function Qe(){{if(M===0){_e=console.log,Ee=console.info,be=console.warn,Re=console.error,Te=console.group,Pe=console.groupCollapsed,Ce=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Se,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}M++}}function $e(){{if(M--,M===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:g({},e,{value:_e}),info:g({},e,{value:Ee}),warn:g({},e,{value:be}),error:g({},e,{value:Re}),group:g({},e,{value:Te}),groupCollapsed:g({},e,{value:Pe}),groupEnd:g({},e,{value:Ce})})}M<0&&h("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ae=O.ReactCurrentDispatcher,oe;function K(e,r,t){{if(oe===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);oe=n&&n[1]||""}return`
|
|
18
18
|
`+oe+e}}var ie=!1,H;{var qe=typeof WeakMap=="function"?WeakMap:Map;H=new qe}function we(e,r){if(!e||ie)return"";{var t=H.get(e);if(t!==void 0)return t}var n;ie=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var c;c=ae.current,ae.current=null,Qe();try{if(r){var o=function(){throw Error()};if(Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(A){n=A}Reflect.construct(e,[],o)}else{try{o.call()}catch(A){n=A}e.call(o.prototype)}}else{try{throw Error()}catch(A){n=A}e()}}catch(A){if(A&&n&&typeof A.stack=="string"){for(var a=A.stack.split(`
|
|
19
19
|
`),b=n.stack.split(`
|
|
20
20
|
`),d=a.length-1,p=b.length-1;d>=1&&p>=0&&a[d]!==b[p];)p--;for(;d>=1&&p>=0;d--,p--)if(a[d]!==b[p]){if(d!==1||p!==1)do if(d--,p--,p<0||a[d]!==b[p]){var T=`
|
|
21
|
-
`+a[d].replace(" at new "," at ");return e.displayName&&T.includes("<anonymous>")&&(T=T.replace("<anonymous>",e.displayName)),typeof e=="function"&&H.set(e,T),T}while(d>=1&&p>=0);break}}}finally{ie=!1,ae.current=c,$e(),Error.prepareStackTrace=i}var L=e?e.displayName||e.name:"",Ye=L?K(L):"";return typeof e=="function"&&H.set(e,Ye),Ye}function er(e,r,t){return we(e,!1)}function rr(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function X(e,r,t){if(e==null)return"";if(typeof e=="function")return we(e,rr(e));if(typeof e=="string")return K(e);switch(e){case j:return K("Suspense");case E:return K("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case y:return er(e.render);case
|
|
21
|
+
`+a[d].replace(" at new "," at ");return e.displayName&&T.includes("<anonymous>")&&(T=T.replace("<anonymous>",e.displayName)),typeof e=="function"&&H.set(e,T),T}while(d>=1&&p>=0);break}}}finally{ie=!1,ae.current=c,$e(),Error.prepareStackTrace=i}var L=e?e.displayName||e.name:"",Ye=L?K(L):"";return typeof e=="function"&&H.set(e,Ye),Ye}function er(e,r,t){return we(e,!1)}function rr(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function X(e,r,t){if(e==null)return"";if(typeof e=="function")return we(e,rr(e));if(typeof e=="string")return K(e);switch(e){case j:return K("Suspense");case E:return K("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case y:return er(e.render);case P:return X(e.type,r,t);case k:{var n=e,i=n._payload,c=n._init;try{return X(c(i),r,t)}catch{}}}return""}var Z=Object.prototype.hasOwnProperty,Oe={},xe=O.ReactDebugCurrentFrame;function Q(e){if(e){var r=e._owner,t=X(e.type,e._source,r?r.type:null);xe.setExtraStackFrame(t)}else xe.setExtraStackFrame(null)}function tr(e,r,t,n,i){{var c=Function.call.bind(Z);for(var o in e)if(c(e,o)){var a=void 0;try{if(typeof e[o]!="function"){var b=Error((n||"React class")+": "+t+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw b.name="Invariant Violation",b}a=e[o](r,o,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(d){a=d}a&&!(a instanceof Error)&&(Q(i),h("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,o,typeof a),Q(null)),a instanceof Error&&!(a.message in Oe)&&(Oe[a.message]=!0,Q(i),h("Failed %s type: %s",t,a.message),Q(null))}}}var nr=Array.isArray;function se(e){return nr(e)}function ar(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function or(e){try{return je(e),!1}catch{return!0}}function je(e){return""+e}function ke(e){if(or(e))return h("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ar(e)),je(e)}var V=O.ReactCurrentOwner,ir={key:!0,ref:!0,__self:!0,__source:!0},Ae,De,ue;ue={};function sr(e){if(Z.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function ur(e){if(Z.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function cr(e,r){if(typeof e.ref=="string"&&V.current&&r&&V.current.stateNode!==r){var t=l(V.current.type);ue[t]||(h('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',l(V.current.type),e.ref),ue[t]=!0)}}function lr(e,r){{var t=function(){Ae||(Ae=!0,h("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function fr(e,r){{var t=function(){De||(De=!0,h("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var dr=function(e,r,t,n,i,c,o){var a={$$typeof:f,type:e,key:r,ref:t,props:o,_owner:c};return a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(a,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(a,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function pr(e,r,t,n,i){{var c,o={},a=null,b=null;t!==void 0&&(ke(t),a=""+t),ur(r)&&(ke(r.key),a=""+r.key),sr(r)&&(b=r.ref,cr(r,i));for(c in r)Z.call(r,c)&&!ir.hasOwnProperty(c)&&(o[c]=r[c]);if(e&&e.defaultProps){var d=e.defaultProps;for(c in d)o[c]===void 0&&(o[c]=d[c])}if(a||b){var p=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&lr(o,p),b&&fr(o,p)}return dr(e,a,b,i,n,V.current,o)}}var ce=O.ReactCurrentOwner,Fe=O.ReactDebugCurrentFrame;function N(e){if(e){var r=e._owner,t=X(e.type,e._source,r?r.type:null);Fe.setExtraStackFrame(t)}else Fe.setExtraStackFrame(null)}var le;le=!1;function fe(e){return typeof e=="object"&&e!==null&&e.$$typeof===f}function Me(){{if(ce.current){var e=l(ce.current.type);if(e)return`
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+e+"`."}return""}}function vr(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),t=e.lineNumber;return`
|
|
24
24
|
|
|
25
25
|
Check your code at `+r+":"+t+"."}return""}}var Ie={};function mr(e){{var r=Me();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+t+">.")}return r}}function Ne(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=mr(r);if(Ie[t])return;Ie[t]=!0;var n="";e&&e._owner&&e._owner!==ce.current&&(n=" It was passed a child from "+l(e._owner.type)+"."),N(e),h('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),N(null)}}function Le(e,r){{if(typeof e!="object")return;if(se(e))for(var t=0;t<e.length;t++){var n=e[t];fe(n)&&Ne(n,r)}else if(fe(e))e._store&&(e._store.validated=!0);else if(e){var i=q(e);if(typeof i=="function"&&i!==e.entries)for(var c=i.call(e),o;!(o=c.next()).done;)fe(o.value)&&Ne(o.value,r)}}}function yr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===y||r.$$typeof===
|
|
27
|
+
Check the top-level render call using <`+t+">.")}return r}}function Ne(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=mr(r);if(Ie[t])return;Ie[t]=!0;var n="";e&&e._owner&&e._owner!==ce.current&&(n=" It was passed a child from "+l(e._owner.type)+"."),N(e),h('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),N(null)}}function Le(e,r){{if(typeof e!="object")return;if(se(e))for(var t=0;t<e.length;t++){var n=e[t];fe(n)&&Ne(n,r)}else if(fe(e))e._store&&(e._store.validated=!0);else if(e){var i=q(e);if(typeof i=="function"&&i!==e.entries)for(var c=i.call(e),o;!(o=c.next()).done;)fe(o.value)&&Ne(o.value,r)}}}function yr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===y||r.$$typeof===P))t=r.propTypes;else return;if(t){var n=l(r);tr(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!le){le=!0;var i=l(r);h("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",i||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&h("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function hr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){N(e),h("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),N(null);break}}e.ref!==null&&(N(e),h("Invalid attribute `ref` supplied to `React.Fragment`."),N(null))}}function We(e,r,t,n,i,c){{var o=G(e);if(!o){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var b=vr(i);b?a+=b:a+=Me();var d;e===null?d="null":se(e)?d="array":e!==void 0&&e.$$typeof===f?(d="<"+(l(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):d=typeof e,h("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",d,a)}var p=pr(e,r,t,i,c);if(p==null)return p;if(o){var T=r.children;if(T!==void 0)if(n)if(se(T)){for(var L=0;L<T.length;L++)Le(T[L],e);Object.freeze&&Object.freeze(T)}else h("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Le(T,e)}return e===R?hr(p):yr(p),p}}function gr(e,r,t){return We(e,r,t,!0)}function _r(e,r,t){return We(e,r,t,!1)}var Er=_r,br=gr;Y.Fragment=R,Y.jsx=Er,Y.jsxs=br}()),Y}(function(s){process.env.NODE_ENV==="production"?s.exports=Be():s.exports=Ue()})(Ve);const B=$.jsx,Rr="",ze={map:"_map_1yxt5_2","map-popup-container":"_map-popup-container_1yxt5_7",touch:"_touch_1yxt5_26","mobile-layers-button":"_mobile-layers-button_1yxt5_30",floaten:"_floaten_1yxt5_45",float:"_float_1yxt5_45"},ve=s=>s?s instanceof Object?[s.longitude,s.latitude]:s:void 0,Je=async()=>{try{const f=await new Promise((S,R)=>{navigator.geolocation.getCurrentPosition(v=>{S(v)},v=>R(v))});return f&&ve(f.coords)||Object.values(me())}catch(s){console.error(s);const f=me();return[f.longitude,f.latitude]}},me=()=>({longitude:51.36281969540723,latitude:35.69672648316882}),Ge={reverse:"https://api.neshan.org/v4/reverse",search:"https://api.neshan.org/v1/search",map:"https://static.neshan.org/sdk/openlayers/5.3.0/ol.js"},ye=m.createContext({map:null,mapType:"neshan",mapContainer:null,setMap:s=>{},setMapType:s=>{},setMapContainer:s=>{}}),he={map:null,mapType:"neshan",mapContainer:null},Ke=(s,f)=>{switch(f.type){case"SET_MAP":return{...s,map:f.payload};case"SET_MAP_TYPE":return{...s,title:f.payload};default:return he}},He=s=>{const[f,S]=m.useReducer(Ke,he),R={...f,setMap:v=>{S({type:"SET_MAP",payload:v})},setMapType:v=>{S({type:"SET_MAP_TYPE",payload:v})},setMapContainer:v=>{S({type:"SET_MAP_CONTAINER",payload:v})}};return B(ye.Provider,{value:R,children:s.children})},Xe=m.forwardRef(({options:s,mapKey:f,serviceKey:S="",zoom:R=12,defaultType:v="neshan",scale:I,center:F,poi:x=!0,traffic:y=!0,onInit:j,className:E,style:P},k)=>{const C=m.useContext(ye),w=m.useRef(null),[U,q]=m.useState(!1),[O,h]=m.useState(null),[ge,ee]=m.useState();m.useImperativeHandle(k,()=>({get mapContainer(){return w},get ol(){return typeof ol<"u"?ol:void 0},get map(){return C.map},get isInitiated(){return U}}),[U,C.map]);const z=()=>{var _,l;if(O)return O;const u=(l=(_=w.current)==null?void 0:_.querySelector(".ol-viewport"))==null?void 0:l.querySelectorAll("div:last-child");if(u)return h(Array.from(u)[u.length-1]),O},re=()=>{const u=z();u==null||u.style.setProperty("scale",""+I)},te=()=>{const u=z();u==null||u.style.setProperty("bottom","0.2em"),u==null||u.style.setProperty("left","0.4em")},ne=(u,_="my-openlayer")=>{const l=document.getElementById(_);if(l)return l;const g=document.createElement("script");return g.src=u,g.id=_,document.getElementsByTagName("head")[0].appendChild(g),g},J=async()=>{var g;if(!w.current)return;const u=ve(F);ee(u);const _=u||await Je(),l=new ol.Map({target:w.current,key:f||"",mapType:v,poi:x,traffic:y,view:new ol.View({center:ol.proj.fromLonLat(_),zoom:R}),controls:[],...s});l.setMapType(v),C.setMap(l),(g=C.map)==null||g.setMapType(v),C.setMapType(v),q(!0),j&&j(ol,l)},G=()=>{let u,_,l;return u=new Promise((g,M)=>{l=M,_=g,J().then(()=>{re(),te(),_()}).catch(()=>{l()})}),{promise:u,cancelPromise:()=>l()}};return m.useEffect(()=>{if(w.current&&C.setMapContainer(w.current),typeof ol<"u"){const u=G();return()=>u.cancelPromise()}else{const u=ne(Ge.map),_=()=>{G()};return u.addEventListener("load",_),()=>u.removeEventListener("load",_)}},[]),B("div",{ref:w,className:E||ze.map,style:P})}),Ze=m.forwardRef((s,f)=>B(He,{children:B(Xe,{ref:f,...s})}));D.NeshanMap=Ze,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -123,7 +123,6 @@ export declare type Ol = {
|
|
|
123
123
|
TileCache: typeof mainOl.TileCache;
|
|
124
124
|
TileQueue: typeof mainOl.TileQueue;
|
|
125
125
|
TileRange: typeof mainOl.TileRange;
|
|
126
|
-
VectorRenderTile: typeof mainOl.VectorRenderTile;
|
|
127
126
|
VectorTile: typeof mainOl.VectorTile;
|
|
128
127
|
View: typeof mainOl.View;
|
|
129
128
|
getUid: typeof mainOl.getUid;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"title": "react-neshanmap-openlayers",
|
|
4
4
|
"description": "A react map component wrapping neshan openlayers map.",
|
|
5
5
|
"private": false,
|
|
6
|
-
"version": "2.0.
|
|
6
|
+
"version": "2.0.15",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"types": "./dist/types/components/index.ts",
|
|
9
9
|
"files": [
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^18.11.18",
|
|
26
|
-
"@types/ol": "
|
|
26
|
+
"@types/ol": "5",
|
|
27
27
|
"@types/react": "^18.0.27",
|
|
28
28
|
"@types/react-dom": "^18.0.10",
|
|
29
29
|
"@vitejs/plugin-react": "^3.1.0",
|