@biodiv-platform/naksha-gmaps-view 4.5.1-beta.0 → 4.5.1
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/dist/index.cjs +124 -1
- package/dist/index.js +92 -1
- package/package.json +4 -4
- package/dist/esm/index.js +0 -100
package/dist/index.cjs
CHANGED
|
@@ -1 +1,124 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.tsx
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
NakshaGmapsView: () => NakshaGmapsView
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
var import_naksha_commons = require("@biodiv-platform/naksha-commons");
|
|
37
|
+
var import_api = require("@react-google-maps/api");
|
|
38
|
+
var import_react = require("react");
|
|
39
|
+
|
|
40
|
+
// src/static/constants.tsx
|
|
41
|
+
var GMAP_OPTIONS = {
|
|
42
|
+
mapTypeControlOptions: {
|
|
43
|
+
position: 10
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// src/utils/geojson.tsx
|
|
48
|
+
var import_bbox = __toESM(require("@turf/bbox"), 1);
|
|
49
|
+
var calculateBounds = (geojson) => {
|
|
50
|
+
const b = (0, import_bbox.default)(geojson);
|
|
51
|
+
return {
|
|
52
|
+
east: b[2],
|
|
53
|
+
north: b[3],
|
|
54
|
+
south: b[1],
|
|
55
|
+
west: b[0]
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// src/index.tsx
|
|
60
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
61
|
+
function NakshaGmapsView({
|
|
62
|
+
defaultViewState,
|
|
63
|
+
gmapAccessToken,
|
|
64
|
+
gmapRegion,
|
|
65
|
+
features,
|
|
66
|
+
mapStyle,
|
|
67
|
+
maxZoom,
|
|
68
|
+
options
|
|
69
|
+
}) {
|
|
70
|
+
const mapRef = (0, import_react.useRef)(null);
|
|
71
|
+
const [viewPort] = (0, import_react.useState)((0, import_naksha_commons.mapboxToGmapsViewState)(defaultViewState));
|
|
72
|
+
const [isLoaded, setIsLoaded] = (0, import_react.useState)();
|
|
73
|
+
const reloadFeatures = () => {
|
|
74
|
+
mapRef.current.state.map.data.forEach(function(feature) {
|
|
75
|
+
mapRef.current.state.map.data.remove(feature);
|
|
76
|
+
});
|
|
77
|
+
const fullGeoJson = Array.isArray(features) ? { type: "FeatureCollection", features } : features;
|
|
78
|
+
if (fullGeoJson) {
|
|
79
|
+
fullGeoJson && mapRef.current.state.map.data.addGeoJson(fullGeoJson);
|
|
80
|
+
const bounds = calculateBounds(fullGeoJson);
|
|
81
|
+
bounds && mapRef.current.state.map.fitBounds(bounds);
|
|
82
|
+
if (maxZoom) {
|
|
83
|
+
google.maps.event.addListenerOnce(
|
|
84
|
+
mapRef.current.state.map,
|
|
85
|
+
"idle",
|
|
86
|
+
function() {
|
|
87
|
+
const z = mapRef.current.state.map.getZoom();
|
|
88
|
+
mapRef.current.state.map.setZoom(Math.min(maxZoom, z));
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
(0, import_react.useEffect)(() => {
|
|
95
|
+
if (isLoaded) {
|
|
96
|
+
reloadFeatures();
|
|
97
|
+
}
|
|
98
|
+
}, [isLoaded, features]);
|
|
99
|
+
const onMapLoaded = () => setIsLoaded(true);
|
|
100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
101
|
+
import_api.LoadScriptNext,
|
|
102
|
+
{
|
|
103
|
+
googleMapsApiKey: gmapAccessToken,
|
|
104
|
+
region: gmapRegion,
|
|
105
|
+
libraries: import_naksha_commons.GMAPS_LIBRARIES.DEFAULT,
|
|
106
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
107
|
+
import_api.GoogleMap,
|
|
108
|
+
{
|
|
109
|
+
id: "naksha-gmaps-view",
|
|
110
|
+
mapContainerStyle: mapStyle || { height: "100%", width: "100%" },
|
|
111
|
+
zoom: viewPort.zoom,
|
|
112
|
+
center: viewPort.center,
|
|
113
|
+
options: { ...GMAP_OPTIONS, ...options || {} },
|
|
114
|
+
ref: mapRef,
|
|
115
|
+
onLoad: onMapLoaded
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
+
0 && (module.exports = {
|
|
123
|
+
NakshaGmapsView
|
|
124
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -1 +1,92 @@
|
|
|
1
|
-
|
|
1
|
+
// src/index.tsx
|
|
2
|
+
import {
|
|
3
|
+
GMAPS_LIBRARIES,
|
|
4
|
+
mapboxToGmapsViewState
|
|
5
|
+
} from "@biodiv-platform/naksha-commons";
|
|
6
|
+
import { GoogleMap, LoadScriptNext } from "@react-google-maps/api";
|
|
7
|
+
import { useEffect, useRef, useState } from "react";
|
|
8
|
+
|
|
9
|
+
// src/static/constants.tsx
|
|
10
|
+
var GMAP_OPTIONS = {
|
|
11
|
+
mapTypeControlOptions: {
|
|
12
|
+
position: 10
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// src/utils/geojson.tsx
|
|
17
|
+
import bbox from "@turf/bbox";
|
|
18
|
+
var calculateBounds = (geojson) => {
|
|
19
|
+
const b = bbox(geojson);
|
|
20
|
+
return {
|
|
21
|
+
east: b[2],
|
|
22
|
+
north: b[3],
|
|
23
|
+
south: b[1],
|
|
24
|
+
west: b[0]
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// src/index.tsx
|
|
29
|
+
import { jsx } from "react/jsx-runtime";
|
|
30
|
+
function NakshaGmapsView({
|
|
31
|
+
defaultViewState,
|
|
32
|
+
gmapAccessToken,
|
|
33
|
+
gmapRegion,
|
|
34
|
+
features,
|
|
35
|
+
mapStyle,
|
|
36
|
+
maxZoom,
|
|
37
|
+
options
|
|
38
|
+
}) {
|
|
39
|
+
const mapRef = useRef(null);
|
|
40
|
+
const [viewPort] = useState(mapboxToGmapsViewState(defaultViewState));
|
|
41
|
+
const [isLoaded, setIsLoaded] = useState();
|
|
42
|
+
const reloadFeatures = () => {
|
|
43
|
+
mapRef.current.state.map.data.forEach(function(feature) {
|
|
44
|
+
mapRef.current.state.map.data.remove(feature);
|
|
45
|
+
});
|
|
46
|
+
const fullGeoJson = Array.isArray(features) ? { type: "FeatureCollection", features } : features;
|
|
47
|
+
if (fullGeoJson) {
|
|
48
|
+
fullGeoJson && mapRef.current.state.map.data.addGeoJson(fullGeoJson);
|
|
49
|
+
const bounds = calculateBounds(fullGeoJson);
|
|
50
|
+
bounds && mapRef.current.state.map.fitBounds(bounds);
|
|
51
|
+
if (maxZoom) {
|
|
52
|
+
google.maps.event.addListenerOnce(
|
|
53
|
+
mapRef.current.state.map,
|
|
54
|
+
"idle",
|
|
55
|
+
function() {
|
|
56
|
+
const z = mapRef.current.state.map.getZoom();
|
|
57
|
+
mapRef.current.state.map.setZoom(Math.min(maxZoom, z));
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (isLoaded) {
|
|
65
|
+
reloadFeatures();
|
|
66
|
+
}
|
|
67
|
+
}, [isLoaded, features]);
|
|
68
|
+
const onMapLoaded = () => setIsLoaded(true);
|
|
69
|
+
return /* @__PURE__ */ jsx(
|
|
70
|
+
LoadScriptNext,
|
|
71
|
+
{
|
|
72
|
+
googleMapsApiKey: gmapAccessToken,
|
|
73
|
+
region: gmapRegion,
|
|
74
|
+
libraries: GMAPS_LIBRARIES.DEFAULT,
|
|
75
|
+
children: /* @__PURE__ */ jsx(
|
|
76
|
+
GoogleMap,
|
|
77
|
+
{
|
|
78
|
+
id: "naksha-gmaps-view",
|
|
79
|
+
mapContainerStyle: mapStyle || { height: "100%", width: "100%" },
|
|
80
|
+
zoom: viewPort.zoom,
|
|
81
|
+
center: viewPort.center,
|
|
82
|
+
options: { ...GMAP_OPTIONS, ...options || {} },
|
|
83
|
+
ref: mapRef,
|
|
84
|
+
onLoad: onMapLoaded
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
NakshaGmapsView
|
|
92
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@biodiv-platform/naksha-gmaps-view",
|
|
3
|
-
"version": "4.5.1
|
|
3
|
+
"version": "4.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "harshzalavadiya",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"react-map-gl": "^8.1.3",
|
|
36
36
|
"tsup": "^9.0.0",
|
|
37
37
|
"typescript": "^5.8.3",
|
|
38
|
-
"@biodiv-platform/tsconfig": "4.
|
|
39
|
-
"@biodiv-platform/eslint-preset": "4.
|
|
38
|
+
"@biodiv-platform/tsconfig": "4.5.0",
|
|
39
|
+
"@biodiv-platform/eslint-preset": "4.5.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@turf/bbox": "^7.4.0",
|
|
43
|
-
"@biodiv-platform/naksha-commons": "5.0.0
|
|
43
|
+
"@biodiv-platform/naksha-commons": "5.0.0"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
package/dist/esm/index.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// src/index.tsx
|
|
19
|
-
import { GMAPS_LIBRARIES, mapboxToGmapsViewState } from "@biodiv-platform/naksha-commons";
|
|
20
|
-
import { GoogleMap, LoadScriptNext } from "@react-google-maps/api";
|
|
21
|
-
import { useEffect, useRef, useState } from "react";
|
|
22
|
-
|
|
23
|
-
// src/static/constants.tsx
|
|
24
|
-
var GMAP_OPTIONS = {
|
|
25
|
-
mapTypeControlOptions: {
|
|
26
|
-
position: 10
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
// src/utils/geojson.tsx
|
|
31
|
-
import bbox from "@turf/bbox";
|
|
32
|
-
var calculateBounds = (geojson) => {
|
|
33
|
-
const b = bbox(geojson);
|
|
34
|
-
return {
|
|
35
|
-
east: b[2],
|
|
36
|
-
north: b[3],
|
|
37
|
-
south: b[1],
|
|
38
|
-
west: b[0]
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// src/index.tsx
|
|
43
|
-
import { jsx } from "react/jsx-runtime";
|
|
44
|
-
function NakshaGmapsView({
|
|
45
|
-
defaultViewState,
|
|
46
|
-
gmapAccessToken,
|
|
47
|
-
gmapRegion,
|
|
48
|
-
features,
|
|
49
|
-
mapStyle,
|
|
50
|
-
maxZoom,
|
|
51
|
-
options
|
|
52
|
-
}) {
|
|
53
|
-
const mapRef = useRef(null);
|
|
54
|
-
const [viewPort] = useState(mapboxToGmapsViewState(defaultViewState));
|
|
55
|
-
const [isLoaded, setIsLoaded] = useState();
|
|
56
|
-
const reloadFeatures = () => {
|
|
57
|
-
mapRef.current.state.map.data.forEach(function(feature) {
|
|
58
|
-
mapRef.current.state.map.data.remove(feature);
|
|
59
|
-
});
|
|
60
|
-
const fullGeoJson = Array.isArray(features) ? { type: "FeatureCollection", features } : features;
|
|
61
|
-
if (fullGeoJson) {
|
|
62
|
-
fullGeoJson && mapRef.current.state.map.data.addGeoJson(fullGeoJson);
|
|
63
|
-
const bounds = calculateBounds(fullGeoJson);
|
|
64
|
-
bounds && mapRef.current.state.map.fitBounds(bounds);
|
|
65
|
-
if (maxZoom) {
|
|
66
|
-
google.maps.event.addListenerOnce(
|
|
67
|
-
mapRef.current.state.map,
|
|
68
|
-
"idle",
|
|
69
|
-
function() {
|
|
70
|
-
const z = mapRef.current.state.map.getZoom();
|
|
71
|
-
mapRef.current.state.map.setZoom(Math.min(maxZoom, z));
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
if (isLoaded) {
|
|
79
|
-
reloadFeatures();
|
|
80
|
-
}
|
|
81
|
-
}, [isLoaded, features]);
|
|
82
|
-
const onMapLoaded = () => setIsLoaded(true);
|
|
83
|
-
return /* @__PURE__ */ jsx(LoadScriptNext, {
|
|
84
|
-
googleMapsApiKey: gmapAccessToken,
|
|
85
|
-
region: gmapRegion,
|
|
86
|
-
libraries: GMAPS_LIBRARIES.DEFAULT,
|
|
87
|
-
children: /* @__PURE__ */ jsx(GoogleMap, {
|
|
88
|
-
id: "naksha-gmaps-view",
|
|
89
|
-
mapContainerStyle: mapStyle || { height: "100%", width: "100%" },
|
|
90
|
-
zoom: viewPort.zoom,
|
|
91
|
-
center: viewPort.center,
|
|
92
|
-
options: __spreadValues(__spreadValues({}, GMAP_OPTIONS), options || {}),
|
|
93
|
-
ref: mapRef,
|
|
94
|
-
onLoad: onMapLoaded
|
|
95
|
-
})
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
export {
|
|
99
|
-
NakshaGmapsView
|
|
100
|
-
};
|