Last active
December 2, 2019 19:34
-
-
Save duanebester/5a1d47d972d2ee423d37d8fde737b451 to your computer and use it in GitHub Desktop.
User Features 1
This file contains hidden or 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
import React from "react"; | |
import { Layer, Feature } from "react-mapbox-gl"; | |
import { gql } from "apollo-boost"; | |
import { useQuery } from "@apollo/react-hooks"; | |
function UserFeatures({ bbox }) { | |
const { loading, error, data } = useQuery(USER_FEATURES, { | |
variables: { bbox } | |
}); | |
if (loading) return <p>Loading...</p>; | |
if (error) return <p>Error: {error}</p>; | |
return ( | |
<Layer | |
type="symbol" | |
id="users" | |
layout={{ | |
"icon-image": "circle-15", | |
"icon-allow-overlap": true, | |
"icon-ignore-placement": true, | |
"text-allow-overlap": true, | |
"text-ignore-placement": true | |
}} | |
> | |
{data.geoSearch.users.hits.map(user => ( | |
<Feature | |
key={user.name} | |
coordinates={[user.location.lon, user.location.lat]} | |
/> | |
))} | |
</Layer> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment