Skip to content

Commit

Permalink
VectorMap ZoomingAndCentering Demo - Use separate component methods c…
Browse files Browse the repository at this point in the history
…alls instead of chain (#27743)
  • Loading branch information
mpreyskurantov authored Jul 9, 2024
1 parent 917a17e commit 1e1fd43
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
} from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { DxVectorMapComponent, DxVectorMapModule, DxButtonModule } from 'devextreme-angular';
import { DxButtonModule } from 'devextreme-angular';
import { DxVectorMapModule, DxVectorMapComponent, DxVectorMapTypes } from 'devextreme-angular/ui/vector-map';
import * as mapsData from 'devextreme-dist/js/vectormap-data/world.js';
import { Marker, Service } from './app.service';

Expand Down Expand Up @@ -43,9 +44,10 @@ export class AppComponent {
}
}

markerClick({ target, component }) {
if (target?.layer.type === 'marker') {
component.center(target.coordinates()).zoomFactor(10);
markerClick(e: DxVectorMapTypes.ClickEvent) {
if (e.target?.layer.type === 'marker') {
e.component.center(e.target.coordinates());
e.component.zoomFactor(10);
}
}

Expand Down
8 changes: 5 additions & 3 deletions apps/demos/Demos/VectorMap/ZoomingAndCentering/React/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import VectorMap, {
ITooltipProps,
Layer,
Tooltip,
VectorMapTypes,
} from 'devextreme-react/vector-map';

import Button from 'devextreme-react/button';
Expand All @@ -19,9 +20,10 @@ const customizeTooltip: ITooltipProps['customizeTooltip'] = (arg) => {
return null;
};

const markerClick = ({ target, component }) => {
if (target?.layer.type === 'marker') {
component.center(target.coordinates()).zoomFactor(10);
const markerClick = (e: VectorMapTypes.ClickEvent) => {
if (e.target?.layer.type === 'marker') {
e.component.center(e.target.coordinates());
e.component.zoomFactor(10);
}
};

Expand Down
7 changes: 4 additions & 3 deletions apps/demos/Demos/VectorMap/ZoomingAndCentering/ReactJs/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ const customizeTooltip = (arg) => {
}
return null;
};
const markerClick = ({ target, component }) => {
if (target?.layer.type === 'marker') {
component.center(target.coordinates()).zoomFactor(10);
const markerClick = (e) => {
if (e.target?.layer.type === 'marker') {
e.component.center(e.target.coordinates());
e.component.zoomFactor(10);
}
};
const App = () => {
Expand Down
6 changes: 4 additions & 2 deletions apps/demos/Demos/VectorMap/ZoomingAndCentering/Vue/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
DxVectorMap,
DxLayer,
DxTooltip,
DxVectorMapTypes,
} from 'devextreme-vue/vector-map';
import {
DxButton,
Expand All @@ -46,9 +47,10 @@ function customizeTooltip(info) {
}
return null;
}
function markerClick(e) {
function markerClick(e: DxVectorMapTypes.ClickEvent) {
if (e.target?.layer.type === 'marker') {
e.component.center(e.target.coordinates()).zoomFactor(10);
e.component.center(e.target.coordinates());
e.component.zoomFactor(10);
}
}
function reset() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ $(() => {
},
onClick(e) {
if (e.target && e.target.layer.type === 'marker') {
e.component.center(e.target.coordinates()).zoomFactor(10);
e.component.center(e.target.coordinates());
e.component.zoomFactor(10);
}
},
bounds: [-180, 85, 180, -60],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1e1fd43

Please sign in to comment.