Skip to content

Commit e2f8048

Browse files
feat: ✨ add 300 marker positions to docs and update next to 15.1.6
1 parent d8dcc27 commit e2f8048

File tree

8 files changed

+23
-68
lines changed

8 files changed

+23
-68
lines changed

.husky/pre-commit

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
32
. "$(dirname "$0")/common.sh"
43

54
yarn lint-staged

docs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "0.0.0",
55
"private": true,
66
"scripts": {
7-
"dev": "next dev",
7+
"dev": "next dev -H google-maps-react-markers.com.tech",
88
"build": "next build",
99
"start": "next start",
1010
"lint": "next lint"
@@ -14,7 +14,7 @@
1414
},
1515
"dependencies": {
1616
"google-maps-react-markers": "link:..",
17-
"next": "14.2.10",
17+
"next": "15.1.6",
1818
"react": "link:../node_modules/react",
1919
"react-dom": "link:../node_modules/react-dom"
2020
},
170 Bytes
Loading

docs/src/app/globals.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
--callout-border-rgb: 172, 175, 176;
2727
--card-rgb: 180, 185, 188;
2828
--card-border-rgb: 131, 134, 135;
29+
--highlight-rgb: 255, 255, 107;
2930
}
3031

3132
@media (prefers-color-scheme: dark) {

docs/src/app/page.module.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
.action {
6565
color: #000;
66-
background: rgb(255, 255, 107);
66+
background: rgba(var(--highlight-rgb));
6767
border: 0;
6868
padding: 10px;
6969
margin: 5px 0;
@@ -83,7 +83,7 @@
8383
.container h1,
8484
.container h2,
8585
.container h3 {
86-
color: rgb(255, 255, 107);
86+
color: rgba(var(--highlight-rgb));
8787
margin: 0.5rem 0;
8888
}
8989

@@ -133,7 +133,7 @@
133133

134134
.highlighted button {
135135
font-size: 1rem;
136-
color: rgb(255, 255, 107);
136+
color: rgba(var(--highlight-rgb));
137137
background-color: transparent;
138138
border: 0;
139139
padding: 4px;

docs/src/app/page.tsx

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import GoogleMap, { LatLngBounds, MapContextProps } from 'google-maps-react-markers'
4-
import { useEffect, useRef, useState } from 'react'
4+
import { useRef, useState } from 'react'
55
import coordinates from '../components/coordinates'
66
import Info from '../components/info'
77
import mapOptions from '../components/map-options.json'
@@ -12,8 +12,6 @@ export default function Home() {
1212
const mapRef = useRef<any>(null)
1313
const [mapReady, setMapReady] = useState<boolean>(false)
1414
const [mapBounds, setMapBounds] = useState<{ bounds: number[]; zoom: number }>({ bounds: [], zoom: 0 })
15-
const [usedCoordinates, setUsedCoordinates] = useState<number>(0)
16-
const [currCoordinates, setCurrCoordinates] = useState(coordinates[usedCoordinates])
1715
const [highlighted, setHighlighted] = useState<string | null>(null)
1816

1917
const [dragStart, setDragStart] = useState<{ lat: number; lng: number } | null>(null)
@@ -50,25 +48,11 @@ export default function Home() {
5048
setHighlighted(null)
5149
}
5250

53-
const updateCoordinates = () => {
54-
setUsedCoordinates(!usedCoordinates ? 1 : 0)
55-
// reset drag
56-
setDragStart(null)
57-
setDragEnd(null)
58-
setDragging(null)
59-
}
60-
61-
useEffect(() => {
62-
setCurrCoordinates(coordinates[usedCoordinates])
63-
}, [usedCoordinates])
64-
6551
return (
6652
<main className={styles.main}>
6753
<div className={styles.description}>
6854
{mapReady && (
6955
<Info
70-
buttonAction={updateCoordinates}
71-
coordinates={currCoordinates}
7256
bounds={mapBounds?.bounds}
7357
drag={{
7458
dragStart,
@@ -88,7 +72,7 @@ export default function Home() {
8872
onGoogleApiLoaded={onGoogleApiLoaded}
8973
onChange={onMapChange}
9074
>
91-
{currCoordinates.map(({ lat, lng, name }, index) => (
75+
{coordinates.map(({ lat, lng, name }, index) => (
9276
<Marker
9377
// eslint-disable-next-line react/no-array-index-key
9478
key={index}

docs/src/components/coordinates.ts

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,14 @@
11
const coordinates = [
2-
[
3-
{
4-
lat: 45.4046987,
5-
lng: 12.2472504,
6-
name: 'Venice',
7-
},
8-
{
9-
lat: 41.9102415,
10-
lng: 12.3959151,
11-
name: 'Rome',
12-
},
13-
{
14-
lat: 45.4628328,
15-
lng: 9.1076927,
16-
name: 'Milan',
17-
},
18-
],
19-
[
20-
{
21-
lat: 40.8518,
22-
lng: 14.2681,
23-
name: 'Naples',
24-
},
25-
{
26-
lat: 43.7696,
27-
lng: 11.2558,
28-
name: 'Florence',
29-
},
30-
{
31-
lat: 37.5023,
32-
lng: 15.0873,
33-
name: 'Catania',
34-
},
35-
],
2+
{
3+
lat: 45.4046987,
4+
lng: 12.2472504,
5+
name: 'Store draggable',
6+
},
7+
...[...Array(300)].map((_, i) => ({
8+
lat: parseFloat((Math.random() * 180 - 90).toFixed(6)),
9+
lng: parseFloat((Math.random() * 360 - 180).toFixed(6)),
10+
name: `Store #${i + 1}`,
11+
})),
3612
]
3713

3814
export default coordinates

docs/src/components/info.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import styles from '../app/page.module.css'
22

33
interface InfoProps {
44
bounds?: number[]
5-
buttonAction?: () => void
65
coordinates?: { lat: number; lng: number; name: string }[]
76
drag?: {
87
dragEnd: { lat: number; lng: number } | null
@@ -11,7 +10,7 @@ interface InfoProps {
1110
}
1211
}
1312

14-
const Info = ({ buttonAction = () => {}, coordinates = [], bounds, drag }: InfoProps) => (
13+
const Info = ({ coordinates = [], bounds, drag }: InfoProps) => (
1514
<div className={styles.container}>
1615
<div className={styles.info}>
1716
<div>
@@ -25,7 +24,10 @@ const Info = ({ buttonAction = () => {}, coordinates = [], bounds, drag }: InfoP
2524
</div>
2625
<div>
2726
<h3>🖐🏼 Drag</h3>
28-
<p>Drag the blue marker to see its coordinates change.</p>
27+
<p>
28+
Drag the <span style={{ color: 'rgb(var(--highlight-rgb))' }}>yellow</span> marker to see its coordinates
29+
change.
30+
</p>
2931
{drag?.dragStart && drag?.dragEnd && (
3032
<>
3133
<p>Drag start:</p>
@@ -52,13 +54,6 @@ const Info = ({ buttonAction = () => {}, coordinates = [], bounds, drag }: InfoP
5254
</div>
5355
</div>
5456
)}
55-
<div className={styles.buttonContainer}>
56-
<p>Click UPDATE below to trigger markers coordinates change.</p>
57-
<p>Or move the map to trigger bounds change.</p>
58-
<button className={styles.action} type="button" onClick={buttonAction}>
59-
UPDATE
60-
</button>
61-
</div>
6257
</div>
6358
)
6459

0 commit comments

Comments
 (0)