import { LngLat } from "maplibre-gl"; import React, { Component } from "react"; import BaseMap from "../src"; import { Popup } from "../src/styled"; const center: [number, number] = [45.522862, -122.667837]; type State = { contents?: React.ReactNode; location?: [number, number]; }; type Props = Record; export default class ContextMenuDemo extends Component { constructor(props: Props) { super(props); this.state = { contents: null, location: center }; } handleContextMenu = (e: { lngLat: LngLat }): void => { this.setState({ contents:

Context Popup

, location: [e.lngLat.lat, e.lngLat.lng] }); }; render(): JSX.Element { const { contents, location } = this.state; return (
{contents && location && ( { this.setState({ contents: null }); }} > {contents} )}
); } }