google-maps-react-markers 1.0.8 → 1.0.9
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 +45 -36
- package/dist/google-map.d.ts +3 -0
- package/dist/google-map.d.ts.map +1 -0
- package/dist/hooks/useGoogleMaps.d.ts +5 -0
- package/dist/hooks/useGoogleMaps.d.ts.map +1 -0
- package/dist/hooks/useMemoCompare.d.ts +10 -0
- package/dist/hooks/useMemoCompare.d.ts.map +1 -0
- package/dist/hooks/useScript.d.ts +10 -0
- package/dist/hooks/useScript.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/map/map.d.ts +34 -0
- package/dist/map/map.d.ts.map +1 -0
- package/dist/map/markers.d.ts +14 -0
- package/dist/map/markers.d.ts.map +1 -0
- package/dist/map/overlay-view.d.ts +23 -0
- package/dist/map/overlay-view.d.ts.map +1 -0
- package/dist/map/overlay.d.ts +18 -0
- package/dist/map/overlay.d.ts.map +1 -0
- package/dist/utils/utils.d.ts +2 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ The library implements [Google Maps Custom Overlays](https://developers.google.c
|
|
|
15
15
|
## Install
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
yarn add
|
|
18
|
+
yarn add google-maps-react-markers
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
or
|
|
@@ -28,40 +28,40 @@ npm install --save google-maps-react-markers
|
|
|
28
28
|
|
|
29
29
|
```jsx
|
|
30
30
|
const App = () => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
31
|
+
const mapRef = useRef(null);
|
|
32
|
+
const [mapReady, setMapReady] = useState(false);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @description This function is called when the map is ready
|
|
36
|
+
* @param {Object} map - reference to the map instance
|
|
37
|
+
* @param {Object} maps - reference to the maps library
|
|
38
|
+
*/
|
|
39
|
+
const onGoogleApiLoaded = ({ map, maps }) => {
|
|
40
|
+
mapRef.current = map;
|
|
41
|
+
setMapReady(true);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const onMarkerClick = (markerId) => {
|
|
45
|
+
console.log("This is ->", markerId);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<>
|
|
50
|
+
{mapReady && <div>Map is ready. See for logs in developer console.</div>}
|
|
51
|
+
<GoogleMap
|
|
52
|
+
defaultCenter={{ lat: 45.4046987, lng: 12.2472504 }}
|
|
53
|
+
defaultZoom={5}
|
|
54
|
+
options={mapOptions}
|
|
55
|
+
mapMinHeight="100vh"
|
|
56
|
+
onGoogleApiLoaded={onGoogleApiLoaded}
|
|
57
|
+
onChange={(map) => console.log("Map moved", map)}
|
|
58
|
+
>
|
|
59
|
+
{coordinates.map(({ lat, lng, name }, index) => (
|
|
60
|
+
<Marker key={index} lat={lat} lng={lng} markerId={name} onClick={onMarkerClick} />
|
|
61
|
+
))}
|
|
62
|
+
</GoogleMap>
|
|
63
|
+
</>
|
|
64
|
+
);
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
export default App;
|
|
@@ -93,8 +93,17 @@ For clustering, follow this [guide](https://www.leighhalliday.com/google-maps-cl
|
|
|
93
93
|
const onMapChange = ({ bounds, zoom }) => {
|
|
94
94
|
const ne = bounds.getNorthEast();
|
|
95
95
|
const sw = bounds.getSouthWest();
|
|
96
|
-
|
|
96
|
+
/**
|
|
97
|
+
* useSupercluster accepts bounds in the form of [westLng, southLat, eastLng, northLat]
|
|
98
|
+
* const { clusters, supercluster } = useSupercluster({
|
|
99
|
+
* points: points,
|
|
100
|
+
* bounds: mapBounds.bounds,
|
|
101
|
+
* zoom: mapBounds.zoom,
|
|
102
|
+
* })
|
|
103
|
+
*/
|
|
97
104
|
setMapBounds({ ...mapBounds, bounds: [sw.lng(), sw.lat(), ne.lng(), ne.lat()], zoom });
|
|
105
|
+
|
|
106
|
+
console.log("New bounds and zoom -> ", { bounds, zoom });
|
|
98
107
|
};
|
|
99
108
|
```
|
|
100
109
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-map.d.ts","sourceRoot":"","sources":["../src/google-map.js"],"names":[],"mappings":";AAKA,6BAsBE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGoogleMaps.d.ts","sourceRoot":"","sources":["../../src/hooks/useGoogleMaps.js"],"names":[],"mappings":"AAKO;;;IAFM,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAclD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default useMemoCompare;
|
|
2
|
+
/**
|
|
3
|
+
* A hook that compares the previous and current values of a reference.
|
|
4
|
+
* @param {any} value - the current value of the reference
|
|
5
|
+
* @param {function} compare - a function that compares the previous and current values
|
|
6
|
+
* @returns {any} the previous value of the reference
|
|
7
|
+
* @ref https://usehooks.com/useMemoCompare/
|
|
8
|
+
*/
|
|
9
|
+
declare function useMemoCompare(next: any, compare: Function): any;
|
|
10
|
+
//# sourceMappingURL=useMemoCompare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMemoCompare.d.ts","sourceRoot":"","sources":["../../src/hooks/useMemoCompare.js"],"names":[],"mappings":";AAEA;;;;;;GAMG;AACH,+DAHa,GAAG,CAoBf"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function useScript(script?: {
|
|
2
|
+
src: string;
|
|
3
|
+
attributes?: any;
|
|
4
|
+
callbacks?: {
|
|
5
|
+
onLoadCallback?: Function;
|
|
6
|
+
onErrorCallback?: Function;
|
|
7
|
+
};
|
|
8
|
+
elementIdToAppend?: string;
|
|
9
|
+
}): "idle" | "loading" | "ready" | "error";
|
|
10
|
+
//# sourceMappingURL=useScript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useScript.d.ts","sourceRoot":"","sources":["../../src/hooks/useScript.js"],"names":[],"mappings":"AA0BO;IApBmB,GAAG,EAAlB,MAAM;IACU,UAAU;IACV,SAAS;QACG,cAAc;QACd,eAAe;;IAC3B,iBAAiB,GAAjC,MAAM;IACJ,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAwGlD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export default MapComponent;
|
|
2
|
+
declare function MapComponent({ children, style, defaultCenter, defaultZoom, onGoogleApiLoaded, onChange, ...props }: {
|
|
3
|
+
[x: string]: any;
|
|
4
|
+
children: any;
|
|
5
|
+
style: any;
|
|
6
|
+
defaultCenter: any;
|
|
7
|
+
defaultZoom: any;
|
|
8
|
+
onGoogleApiLoaded: any;
|
|
9
|
+
onChange: any;
|
|
10
|
+
}): any;
|
|
11
|
+
declare namespace MapComponent {
|
|
12
|
+
namespace defaultProps {
|
|
13
|
+
namespace style {
|
|
14
|
+
const width: string;
|
|
15
|
+
const height: string;
|
|
16
|
+
const left: number;
|
|
17
|
+
const top: number;
|
|
18
|
+
const margin: number;
|
|
19
|
+
const padding: number;
|
|
20
|
+
const position: string;
|
|
21
|
+
}
|
|
22
|
+
function onGoogleApiLoaded(): void;
|
|
23
|
+
function onChange(): void;
|
|
24
|
+
}
|
|
25
|
+
namespace propTypes {
|
|
26
|
+
export const children: any;
|
|
27
|
+
export { object as style };
|
|
28
|
+
export const defaultCenter: any;
|
|
29
|
+
export const defaultZoom: any;
|
|
30
|
+
export { func as onGoogleApiLoaded };
|
|
31
|
+
export { func as onChange };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/map/map.js"],"names":[],"mappings":";AAOA;;;;;;;;QAyEC;;;;;;;;;;;;QAYmB,mCAAQ;QACjB,0BAAQ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default MapMarkers;
|
|
2
|
+
declare function MapMarkers({ children, map, maps }: {
|
|
3
|
+
children: any;
|
|
4
|
+
map: any;
|
|
5
|
+
maps: any;
|
|
6
|
+
}): any;
|
|
7
|
+
declare namespace MapMarkers {
|
|
8
|
+
namespace propTypes {
|
|
9
|
+
export const children: ReactNode;
|
|
10
|
+
export { object as map };
|
|
11
|
+
export const maps: object;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=markers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markers.d.ts","sourceRoot":"","sources":["../../src/map/markers.js"],"names":[],"mappings":";AAIA;;;;QAkBC;;;;;2BAiBU,MAAM"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export default OverlayView;
|
|
2
|
+
/**
|
|
3
|
+
* @param {HTMLElement} container
|
|
4
|
+
* @param {google.maps.MapPanes} pane - The pane on which to display the overlay. This is the Pane name, not the Pane itself. Defaults to floatPane.
|
|
5
|
+
* @param {google.maps.LatLng | google.maps.LatLngLiteral} position
|
|
6
|
+
* @returns {void}
|
|
7
|
+
* @ref [MapPanes](https://developers.google.com/maps/documentation/javascript/reference/overlay-view#MapPanes)
|
|
8
|
+
*/
|
|
9
|
+
declare function OverlayView({ position, pane, map, maps, zIndex, children }: HTMLElement): void;
|
|
10
|
+
declare namespace OverlayView {
|
|
11
|
+
namespace defaultProps {
|
|
12
|
+
const zIndex: number;
|
|
13
|
+
}
|
|
14
|
+
namespace propTypes {
|
|
15
|
+
export { string as pane };
|
|
16
|
+
export const position: google.maps.LatLng | google.maps.LatLngLiteral;
|
|
17
|
+
export const map: google.maps.Map;
|
|
18
|
+
export const maps: object;
|
|
19
|
+
export { number as zIndex };
|
|
20
|
+
export const children: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=overlay-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay-view.d.ts","sourceRoot":"","sources":["../../src/map/overlay-view.js"],"names":[],"mappings":";AAMA;;;;;;GAMG;AACH,8EANW,WAAW,GAGT,IAAI,CAwChB;;;;;;;+BAgBU,8CAA8C;;2BAiB9C,MAAM"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default createOverlay;
|
|
2
|
+
/**
|
|
3
|
+
* @param {HTMLElement} container
|
|
4
|
+
* @param {google.maps.MapPanes} pane
|
|
5
|
+
* @param {google.maps.LatLng | google.maps.LatLngLiteral} position
|
|
6
|
+
* @param {google.maps} maps
|
|
7
|
+
* @returns {void}
|
|
8
|
+
*/
|
|
9
|
+
declare function createOverlay({ container, pane, position, maps }: HTMLElement): void;
|
|
10
|
+
declare namespace createOverlay {
|
|
11
|
+
namespace propTypes {
|
|
12
|
+
const container: any;
|
|
13
|
+
const pane: google.maps.MapPanes;
|
|
14
|
+
const position: google.maps.LatLng | google.maps.LatLngLiteral;
|
|
15
|
+
const maps: any;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=overlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/map/overlay.js"],"names":[],"mappings":";AAEA;;;;;;GAMG;AACH,oEANW,WAAW,GAIT,IAAI,CA0ChB;;;;;wBAiBU,8CAA8C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.js"],"names":[],"mappings":"AAAO,8EAUN"}
|