Skip to content

Instantly share code, notes, and snippets.

@duanebester
Last active December 2, 2019 19:34
Show Gist options
  • Save duanebester/5a1d47d972d2ee423d37d8fde737b451 to your computer and use it in GitHub Desktop.
Save duanebester/5a1d47d972d2ee423d37d8fde737b451 to your computer and use it in GitHub Desktop.
User Features 1
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