forked from opentripplanner/otp-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(BaseMap): Add support for map contextMenu event.
- Loading branch information
1 parent
cb9e7ea
commit b58a255
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* eslint-disable react/prop-types */ | ||
import React, { Component } from "react"; | ||
import BaseMap from ".."; | ||
|
||
export default class ContextMenuDemo extends Component { | ||
constructor() { | ||
super(); | ||
|
||
this.state = { location: null }; | ||
} | ||
|
||
handleContextMenu = e => { | ||
this.setState({ location: [e.latlng.lat, e.latlng.lng] }); | ||
}; | ||
|
||
render() { | ||
const { location } = this.state; | ||
const center = [45.522862, -122.667837]; | ||
|
||
return ( | ||
<div> | ||
<BaseMap | ||
center={center} | ||
popup={{ location, contents: <h1>Context Menu</h1> }} | ||
onContextMenu={this.handleContextMenu} | ||
/> | ||
</div> | ||
); | ||
} | ||
} |
This file contains 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
This file contains 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