-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #164 from Type-Style/dev
Release 1.1_2
- Loading branch information
Showing
13 changed files
with
161 additions
and
57 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,5 +28,7 @@ | |
}, | ||
"rules": { | ||
//"react/jsx-key": false | ||
} | ||
}, | ||
"ignorePatterns": ["types_easyButton.d.ts" ] | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React, { useEffect } from 'react' | ||
import { useMap } from "react-leaflet"; | ||
import L from 'leaflet'; | ||
import GpsFixedIcon from '@mui/icons-material/GpsFixed'; | ||
import { renderToString } from 'react-dom/server'; | ||
|
||
// Used to recenter the map to new coordinates | ||
export const LocationButton = ({ lat, lon }: { lat: number, lon: number }) => { | ||
const map = useMap(); | ||
const gpsIcon = renderToString(<GpsFixedIcon style={{ width: '100%', height: '100%', fill: "currentcolor" }} />); | ||
let justClicked = false; | ||
useEffect(() => { | ||
L.easyButton(gpsIcon, function (btn, map) { | ||
justClicked = true; | ||
map.locate({ | ||
enableHighAccuracy: true, | ||
watch: true, | ||
}).on("locationfound", function (e) { | ||
|
||
btn.button.classList.add("active"); | ||
const bounds = L.latLngBounds([[lat, lon], e.latlng]); | ||
if (justClicked) { | ||
map.fitBounds(bounds); | ||
} | ||
|
||
//map.flyTo(e.latlng, map.getZoom()); | ||
|
||
L.marker(e.latlng, { | ||
icon: L.divIcon({ | ||
className: "customMarkerIcon geoLocation end none", | ||
iconSize: L.point(17, 17), | ||
popupAnchor: [0, -15], | ||
}), | ||
}).bindPopup("Your are here :)").addTo(map); | ||
|
||
justClicked = false; | ||
}); | ||
}).addTo(map); | ||
}, [map]); | ||
return null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.