Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
Test vector tiles (#1041)
Browse files Browse the repository at this point in the history
* experiment mapbox vector tiles

* make vector tile popup

* Release 0.3.7-0

* Release 0.3.7-1

* Release 0.3.7-2
  • Loading branch information
hoanphungt authored Mar 1, 2022
1 parent c8f8d4f commit c32f404
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 219 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lizard-management-client",
"version": "0.3.6",
"version": "0.3.7-2",
"private": true,
"repository": {
"type": "git",
Expand Down
56 changes: 56 additions & 0 deletions src/components/MapPopup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React, { Popup } from "react-map-gl";
import MDSpinner from "react-md-spinner";
import { useQuery } from "react-query";

interface Props {
data: any,
setData: any
}

export const MapPopup: React.FC<Props> = ({ data, setData }) => {
const properties = data.features.map((feature: any) => feature.properties);
const property = properties[0];
const { object_id } = property;
const {
data: apiData,
isFetched
} = useQuery(
`${object_id}`,
() => fetch(`/api/v4/measuringstations/${object_id}`).then(res => res.json())
);
return (
<Popup
latitude={data.lngLat[1]}
longitude={data.lngLat[0]}
closeButton={true}
closeOnClick={false}
onClose={() => setData(null)}
anchor="top"
>
<h3>Properties</h3>
{data.features.map((feature: any, i: number) => {
return (
<div key={i}>
<hr />
<h4>{feature.source}</h4>
{Object.keys(feature.properties).map(key => {
return (
<div key={key}>
{key}: {feature.properties[key]}
</div>
);
})}
{isFetched && feature.source === 'measuringstation' ? (
<>
<div>code: {apiData.code}</div>
<div>frequency: {apiData.frequency}</div>
<div>region: {apiData.region}</div>
</>
) : feature.source === 'measuringstation' ? (
<MDSpinner />
) : null}
</div>
)})}
</Popup>
)
}
Loading

0 comments on commit c32f404

Please sign in to comment.