added google map api
This commit is contained in:
parent
25e27d9d4d
commit
1539dfef7f
@ -27,11 +27,9 @@ export function GeolocationInput({
|
|||||||
const [isMapModalOpen, setIsMapModalOpen] = useState(false);
|
const [isMapModalOpen, setIsMapModalOpen] = useState(false);
|
||||||
const [mapMarkerPos, setMapMarkerPos] = useState<{ lat: number; lng: number } | null>(null);
|
const [mapMarkerPos, setMapMarkerPos] = useState<{ lat: number; lng: number } | null>(null);
|
||||||
|
|
||||||
const isLocalhost = typeof window !== 'undefined' && (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1');
|
|
||||||
|
|
||||||
const { isLoaded } = useJsApiLoader({
|
const { isLoaded } = useJsApiLoader({
|
||||||
id: 'google-map-script',
|
id: 'google-map-script',
|
||||||
googleMapsApiKey: isLocalhost ? '' : (import.meta.env.VITE_GOOGLE_MAPS_API_KEY || '')
|
googleMapsApiKey: import.meta.env.VITE_GOOGLE_MAPS_API_KEY || ''
|
||||||
});
|
});
|
||||||
|
|
||||||
// Extract lat, lng & accuracy from value (supporting both latitude/longitude and lat/lng)
|
// Extract lat, lng & accuracy from value (supporting both latitude/longitude and lat/lng)
|
||||||
|
|||||||
@ -50,11 +50,9 @@ export function DailyLogMap({
|
|||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const mapRef = useRef<google.maps.Map | null>(null);
|
const mapRef = useRef<google.maps.Map | null>(null);
|
||||||
|
|
||||||
const isLocalhost = typeof window !== 'undefined' && (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1');
|
|
||||||
|
|
||||||
const { isLoaded } = useJsApiLoader({
|
const { isLoaded } = useJsApiLoader({
|
||||||
id: 'google-map-script',
|
id: 'google-map-script',
|
||||||
googleMapsApiKey: isLocalhost ? '' : (import.meta.env.VITE_GOOGLE_MAPS_API_KEY || '')
|
googleMapsApiKey: import.meta.env.VITE_GOOGLE_MAPS_API_KEY || ''
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchNearestStores = async (lat: number, lng: number) => {
|
const fetchNearestStores = async (lat: number, lng: number) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user