React Map - Handle the Related Events
The Map UI component fires the routeAdded and routeRemoved events when a marker is added or removed. To handle them, assign functions to the onRouteAdded and onRouteRemoved properties, respectively.
- import React from 'react';
- import 'devextreme/dist/css/dx.light.css';
- import { Map } from 'devextreme-react/map';
- const centerCoordinates = { lat: 40.749825, lng: -73.987963 };
- class App extends React.Component {
- constructor(props) {
- super(props);
- this.routeRemoved = this.routeAdded.bind(this);
- this.routeRemoved = this.routeRemoved.bind(this);
- }
- routeAdded(e) {
- const addedRoute = e.options;
- // The original route used by the current map provider
- const originalRoute = e.originalRoute;
- // Event handling commands go here
- }
- routeRemoved(e) {
- const removedRoute = e.options;
- // Event handling commands go here
- }
- render() {
- return (
- <Map
- defaultZoom={10}
- defaultCenter={centerCoordinates}
- onRouteAdded={this.routeAdded}
- onRouteRemoved={this.routeRemoved}
- />
- );
- }
- }
- export default App;
See Also
Feel free to share topic-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.