-
Data Grids / Data Management
-
Data Grid
- Overview
-
Data Binding
-
Filtering
- Sorting
-
Editing
-
Grouping
-
Selection
- Focused Row
- Paging
-
Scrolling
-
Columns
-
Master-Detail
-
Data Summaries
-
Drag & Drop
-
Export to PDF
-
Export to Excel
- Appearance
-
Customization
- State Persistence
-
Adaptability
-
Keyboard Navigation
- Right-To-Left Support
-
Tree List
- Overview
-
Data Binding
-
Filtering
- Sorting
-
Editing
-
Selection
- Focused Row
- Paging
-
Columns
- Drag & Drop
- State Persistence
- Adaptability
-
Keyboard Navigation
-
Card View
-
Pivot Grid
- Overview
-
Data Binding
-
Field Management
-
Data Summaries
- Drill Down
- Filtering
-
Scrolling
-
Export to Excel
- Chart Integration
- Customization
- State Persistence
-
Filter Builder
-
-
Data Visualization
-
Charts
- Overview
-
Data Binding
-
Common Concepts
-
Axis
-
Aggregation
-
Tooltips
-
Selection
-
Customization
-
Zooming
-
Export
-
-
Area Charts
-
Bar Charts
- Bullet Charts
-
Doughnut Charts
-
Financial Charts
-
Funnel and Pyramid Charts
-
Line Charts
- Pareto Chart
-
Pie Charts
-
Point Charts
-
Polar and Radar Charts
-
Range Charts
- Sankey Chart
-
Sparkline Charts
-
Tree Map
-
Gauges
- Overview
-
Runtime update
-
Bar Gauge
-
Circular Gauge
-
Linear Gauge
-
Diagram
- Overview
-
Data Binding
-
Featured Shapes
-
Custom Shapes
-
Document Capabilities
-
User Interaction
- UI Customization
- Adaptability
-
-
Scheduling / Planning
-
Scheduler
- Overview
-
Data Binding
-
Views
-
Appointments
-
Timetable
- Editing
-
Grouping
- Virtual Scrolling
- Drag & Drop
-
Customization
- Adaptability
-
Gantt
- Overview
- Data Binding
-
Filtering
- Sorting
- Strip Lines
- Export to PDF
- Validation
-
Customization
-
-
Messaging
-
WYSIWYG Editor
-
Forms
-
Data Editors
- Overview
-
Common Concepts
-
Calendar
- Check Box
- Color Box
- Date Box
-
Date Range Box
-
Number Box
- Radio Group
-
Range Selector
- Range Slider
- Slider
- Switch
- Text Area
- Text Box
-
Drop-Downs
- Autocomplete
-
Drop Down Box
-
Select Box
-
Tag Box
-
Lookup
-
Buttons
-
File Upload / File Management
-
File Manager
- Overview
-
File System Types
-
Customization
-
File Uploader
-
-
Popup and Notifications
-
Navigation
- Overview
- Accordion
-
Context Menu
-
Menu
- Multi View
-
Drawer
-
Tab Panel
-
Tabs
-
Toolbar
-
Stepper
- Pagination
-
List
-
Tree View
- Right-to-Left Support
-
Layout
-
Tile View
- Splitter
-
Gallery
- Scroll View
-
-
Interactive Wrappers
-
Sortable
- Resizable
-
-
Progress Indicators
-
Maps
- Overview
-
Map
-
Vector Map
-
Data Binding
- Multiple Layers
-
Markers
- Legend
-
Zooming and Panning
-
Customization
-
-
Localization
Related Demos:
Your search did not match any results.
Vector Map - Dynamic Viewport
This demo illustrates how to change the map's viewport. Use the drop-down menu under the map to choose a continent and change the visible area so that the chosen continent is displayed optimally.
To implement this functionality, call the viewport(viewportCoordinates) method every time the drop-down box value changes. You can also implement the onCenterChanged and onZoomFactorChanged functions to display the map center's coordinates and the current zoom factor in text boxes under the map.
Was this demo helpful?
Feel free to share demo-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.
Backend API
@model IEnumerable<DevExtreme.MVC.Demos.Models.ViewportCoordinate>
@(Html.DevExtreme().VectorMap()
.ID("vector-map")
.Layers(l => l.Add().DataSource(new JS("DevExpress.viz.map.sources.world")))
.Bounds(new double[] { -180, 85, 180, -60 })
.OnZoomFactorChanged("vectorMap_onZoomFactorChanged")
.OnCenterChanged("vectorMap_onCenterChanged")
)
<div class="options">
<div class="caption">Options</div>
<div class="wrapper-option">
<div class="column">
<div class="option">
<span>Continent</span>
@(Html.DevExtreme().SelectBox()
.ID("choose-continent")
.DataSource(Model)
.InputAttr("aria-label", "Continent")
.Width(210)
.DisplayExpr("Continent")
.ValueExpr("Coordinates")
.Value(Model.First().Coordinates)
.OnValueChanged("selectBox_onValueChanged")
)
</div>
<div class="option">
<span>Zoom factor</span>
@(Html.DevExtreme().TextBox()
.ID("zoom-factor")
.Width(210)
.InputAttr("aria-label", "Zoom")
.ReadOnly(true)
.Value("1.00")
)
</div>
<div class="option">
<span>Center</span>
@(Html.DevExtreme().TextBox()
.ID("center")
.Width(210)
.ReadOnly(true)
.InputAttr("aria-label", "Center")
.Value("0.000, 46.036")
)
</div>
</div>
<div class="column">
<div class="option">
<span>Pan control</span>
@(Html.DevExtreme().Switch()
.OnValueChanged("switch_valueChanged")
.Value(true)
)
</div>
<div class="option">
<span>Zoom bar</span>
@(Html.DevExtreme().Switch()
.OnValueChanged("switch_valueChanged")
.Value(true)
)
</div>
</div>
</div>
</div>
<script>
function vectorMap_onZoomFactorChanged(e) {
$("#zoom-factor").dxTextBox("instance").option("value", e.zoomFactor.toFixed(2));
}
function vectorMap_onCenterChanged(e) {
$("#center").dxTextBox("instance").option("value", e.center[0].toFixed(3) +
", " + e.center[1].toFixed(3));
}
function selectBox_onValueChanged(data) {
$("#vector-map").dxVectorMap("instance").viewport(data.value);
}
function switch_panVisible(data) {
$("#vector-map").dxVectorMap("instance").option('controlBar.panVisible', data.value);
}
function switch_zoomVisible(data) {
$("#vector-map").dxVectorMap("instance").option('controlBar.zoomVisible', data.value);
}
</script>
using DevExtreme.MVC.Demos.Models.SampleData;
using System.Text.Json;
using System.Web.Mvc;
namespace DevExtreme.MVC.Demos.Controllers {
public class VectorMapController : Controller {
public ActionResult DynamicViewport() {
return View(SampleData.ViewportCoordinateData);
}
}
}
namespace DevExtreme.MVC.Demos.Models {
public class ViewportCoordinate {
public string Continent { get; set; }
public object Coordinates { get; set; }
}
}
using System.Collections.Generic;
namespace DevExtreme.MVC.Demos.Models.SampleData {
public partial class SampleData {
public static readonly IEnumerable<ViewportCoordinate> ViewportCoordinateData = new[] {
new ViewportCoordinate() {
Continent = "all",
Coordinates = "null"
},
new ViewportCoordinate() {
Continent = "NorthAmerica",
Coordinates = new[] { -180, 84.52, -22.11, -1.57 }
},
new ViewportCoordinate() {
Continent = "SouthAmerica",
Coordinates = new[] { -112.47, 14.26, -27.52, -57.44 }
},
new ViewportCoordinate() {
Continent = "Africa",
Coordinates = new[] { -29.34, 39.09, 55.60, -39.00 }
},
new ViewportCoordinate() {
Continent = "Europe",
Coordinates = new[] { -2.35, 70.91, 61.35, 35.84 }
},
new ViewportCoordinate() {
Continent = "Asia",
Coordinates = new[] { 27.62, 83.11, 180, -19.36 }
},
new ViewportCoordinate() {
Continent = "Australia",
Coordinates = new[] { 104.87, -6.61, 149.98, -45.87 }
}
};
}
}
#vector-map {
height: 420px;
}
.options {
padding: 20px;
background-color: rgba(191, 191, 191, 0.15);
margin-top: 20px;
}
.wrapper-option {
display: flex;
gap: 24px;
padding-top: 16px;
}
.column {
display: flex;
gap: 10px;
flex-direction: column;
}
.option {
display: flex;
align-items: center;
min-height: 34px;
}
.caption {
font-size: 18px;
font-weight: 500;
}
.option > span {
width: 140px;
}
To show or hide the control bar, enable or disable the panVisible and zoomVisible properties. You can toggle switches under the map to see how these settings affect the control bar.