JavaScript/jQuery Map - Handle the Related Events
The Map UI component fires the markerAdded and markerRemoved events when a marker is added or removed. To handle them, assign functions to the onMarkerAdded and onMarkerRemoved 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.markerAdded = this.markerAdded.bind(this);
- this.markerRemoved = this.markerRemoved.bind(this);
- }
- markerAdded(e) {
- const addedMarker = e.options;
- // The original marker used by the current map provider
- const originalMarker = e.originalMarker;
- // Event handling commands go here
- }
- markerRemoved(e) {
- const removedMarker = e.options;
- // Event handling commands go here
- }
- render() {
- return (
- <Map
- defaultZoom={10}
- defaultCenter={centerCoordinates}
- onMarkerAdded={this.markerAdded}
- onMarkerRemoved={this.markerRemoved}
- />
- );
- }
- }
- 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.