Angular Map - Zoom and Center the Map

The center property centers the Map on a specific location. The center property accepts the following location formats in addition to the formats the current provider accepts:

  • { lat: 40.749825, lng: -73.987963 }
  • "40.749825, -73.987963"
  • [ 40.749825, -73.987963 ]
  • "Brooklyn Bridge,New York,NY"

To zoom the Map, set the zoom property. The lower the value, the larger the displayed area.

  • <template>
  • <DxMap
  • :zoom="10"
  • :center="centerCoordinates"
  • />
  • </template>
  •  
  • <script>
  • import 'devextreme/dist/css/dx.light.css';
  •  
  • import { DxMap } from 'devextreme-vue/map';
  •  
  • export default {
  • components: {
  • DxMap
  • },
  • data() {
  • return {
  • centerCoordinates: { lat: 40.749825, lng: -73.987963 }
  • };
  • }
  • }
  • </script>

Note that the UI component can automatically change the center and zoom properties to display all markers and routes and align them with the UI component's center. To disable this behavior, assign false to the autoAdjust property.

  • <template>
  • <DxMap
  • :zoom="7"
  • :center="centerCoordinates"
  • :autoAdjust="false"
  • :markers="mapMarkers"
  • />
  • </template>
  •  
  • <script>
  • import 'devextreme/dist/css/dx.light.css';
  •  
  • import { DxMap } from 'devextreme-vue/map';
  •  
  • export default {
  • components: {
  • DxMap
  • },
  • data() {
  • return {
  • centerCoordinates: { lat: 40.749825, lng: -73.987963 },
  • mapMarkers: [
  • { location: "42.743244, -71.594375" },
  • { location: "37.058435, -74.903842" }
  • ]
  • };
  • }
  • }
  • </script>
See Also