Compare commits

...

4 Commits

Author SHA1 Message Date
57a65a3f60 add geomap components 2024-03-22 23:57:36 +02:00
5c29df8c1a Add map component 2024-02-24 17:59:31 +02:00
508b749903 add package lock file 2024-02-02 16:28:06 +02:00
6ad16ed54d listen from all host 2024-02-02 16:27:54 +02:00
10 changed files with 6048 additions and 135 deletions

View File

@@ -1,10 +1,10 @@
<!doctype html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> <link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title> <title>GeoMap Israel</title>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>

5958
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -10,10 +10,16 @@
"preview": "vite preview" "preview": "vite preview"
}, },
"dependencies": { "dependencies": {
"bootstrap": "^5.3.3",
"leaflet": "^1.9.4",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0" "react-bootstrap": "^2.10.1",
"react-dom": "^18.2.0",
"react-leaflet": "^4.2.1",
"react-leaflet-cluster": "^2.1.0"
}, },
"devDependencies": { "devDependencies": {
"@types/leaflet": "^1.9.8",
"@types/react": "^18.2.43", "@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17", "@types/react-dom": "^18.2.17",
"@typescript-eslint/eslint-plugin": "^6.14.0", "@typescript-eslint/eslint-plugin": "^6.14.0",

View File

@@ -1,42 +0,0 @@
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}
@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}
.card {
padding: 2em;
}
.read-the-docs {
color: #888;
}

View File

@@ -2,33 +2,15 @@ import { useState } from 'react'
import reactLogo from './assets/react.svg' import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg' import viteLogo from '/vite.svg'
import './App.css' import './App.css'
import GeoMap from './components/geomap/geomap'
function App() { function App() {
const [count, setCount] = useState(0) const [count, setCount] = useState(0)
return ( return (
<> <div id='map1111'>
<div> <GeoMap/>
<a href="https://vitejs.dev" target="_blank"> </div>
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
</>
) )
} }

View File

@@ -0,0 +1,68 @@
import {
MapContainer,
Marker,
TileLayer,
Popup,
useMap,
useMapEvents,
useMapEvent,
CircleMarker,
LayerGroup,
Circle,
} from "react-leaflet";
import "leaflet/dist/leaflet.css";
import "./gepmap.css";
import { useState } from "react";
import { LatLng, LatLngTuple } from "leaflet";
import MarkerClusterGroup from "react-leaflet-cluster";
function LocationMarker() {
const [markers, setMarkers] = useState<LatLng[]>([]); //[new LatLng(31.979163245291875, 34.89121019840241)]
useMapEvent("dblclick", (e) => setMarkers([...markers, e.latlng]));
return markers.map((marker, index) => {
return (
<Circle
key={index}
center={marker}
radius={200}
className="circle-marker"
>
<Popup>
<button
onClick={function () {
console.log(index);
setMarkers(function (prevMarkers) {
prevMarkers.splice(index, 1);
return [...prevMarkers];
});
console.log(markers);
}}
>
remove
</button>
</Popup>
</Circle>
);
});
}
function GeoMap() {
const position = new LatLng(31.979163245291875, 34.89121019840241);
return (
<div>
<MapContainer id="map" center={position} zoom={13} scrollWheelZoom={true}>
<TileLayer
attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
<MarkerClusterGroup animate={true} animateAddingMarkers={false}>
<LocationMarker />
</MarkerClusterGroup>
<LayerGroup>{/* <CircleLayer/> */}</LayerGroup>
</MapContainer>
</div>
);
}
export default GeoMap;

View File

@@ -0,0 +1,4 @@
#map {
height: 100vh;
width: 100%;
}

View File

@@ -1,68 +0,0 @@
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}
h1 {
font-size: 3.2em;
line-height: 1.1;
}
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}
@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}

View File

@@ -1,6 +1,7 @@
import React from 'react' import React from 'react'
import ReactDOM from 'react-dom/client' import ReactDOM from 'react-dom/client'
import App from './App.tsx' import App from './App.tsx'
import GeoMap from './components/geomap/geomap.tsx'
import './index.css' import './index.css'
ReactDOM.createRoot(document.getElementById('root')!).render( ReactDOM.createRoot(document.getElementById('root')!).render(

View File

@@ -3,5 +3,9 @@ import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
server: {
host: "0.0.0.0",
port: 3000,
},
plugins: [react()], plugins: [react()],
}) })