Skip to content

Commit

Permalink
RC #251 - Testing adding "map" prop to PlaceMarker component
Browse files Browse the repository at this point in the history
  • Loading branch information
dleadbetter committed Feb 21, 2024
1 parent c5f096b commit 4dcad27
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/core-data/src/components/PlaceMarker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow

import { Map as MapUtils } from '@performant-software/geospatial';
import { MixedGeoJSONLayer, PulsingMarkerLayer, useMap } from '@peripleo/maplibre';
import { MixedGeoJSONLayer, PulsingMarkerLayer, type Map } from '@peripleo/maplibre';
import React, { useCallback, useEffect, useState } from 'react';

type Props = {
Expand All @@ -15,6 +15,8 @@ type Props = {
*/
fillStyle?: { [key: string]: any },

map?: () => Map,

/**
* GeoJSON layer point style.
*/
Expand All @@ -37,8 +39,6 @@ type Props = {
const PlaceMarker = (props: Props) => {
const [place, setPlace] = useState();

const map = useMap();

/**
* Converts the passed data to a feature collection and sets it on the state.
*
Expand Down Expand Up @@ -72,11 +72,11 @@ const PlaceMarker = (props: Props) => {
* Sets the bounding box on the map.
*/
useEffect(() => {
if (map && place) {
if (props.map && place) {
const boundingBox = MapUtils.getBoundingBox(place, props.buffer);
map.fitBounds(boundingBox);
props.map.fitBounds(boundingBox);
}
}, [map, place, props.buffer]);
}, [place, props.buffer, props.map]);

if (!place) {
return null;
Expand Down

0 comments on commit 4dcad27

Please sign in to comment.