New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Client-side Data Binding

  • Demo Configurator

You can filter the pin markers on the map by clicking on the colorized country areas.

You can data bind RadMap Markers and Shapes on the client to a RadClientDataSource control since Q2 2014. This functionality is provided out of the box through the server-side ClientDataSourceID property of the Layer which also has its client-side counterpart - the set_clientDataSourceID() method.

Client-side data binding means fewer postbacks, easier integration with various data services and a more flexible client-side development.

The map needs JSON literals with the necessary fields:

  • for Markers you need a point with coordinates.
  • for Shapes you need objects that follow the GeoJSON specifications .
  • additional fields can be present in the objects and they can be accessed in the marker tooltip template with the #= marker.dataItem.FieldName # syntax. You can alternatively use a field to define a simple tooltip via the TitleField property.
  • you can modify shapes in the ShapeCreated event with JavaScript in case you need to apply further modifications on their structure/appearance.
  • you can provide an array of JSON literals to the map by yourself in its OnInit event to use as a datasource. More information and examples are available in the RadMap client-side data binding help article.

In this example, the RadClientDataSource control requests *.json files that contain the appropriate data. The one that works with the Shapes layer has its WebServiceDataSourceSettings.ServiceType property is set to GeoJSON. You can filter the data through the client data source control object easily and this will not require additional requests for the files (or in the common case - the service). You can read more on the matter in the ClientDataSource Filtering demo.

Click on the countries from the selected continent or use the Choose Map Destination dropdown to show points of interest for a specific country or continent respectively. The OnShapeClick event of the map are used to determine which shape was clicked so the filter collection of the RadClientDataSource is populated accordingly.

  • DefaultVB.aspx
  • DefaultVB.aspx.vb
  • scripts.js
  • styles.css
<%@ Page Title="" Language="VB"  AutoEventWireup="false" CodeFile="DefaultVB.aspx.vb" Inherits="Telerik.Web.Examples.Map.ClientSideDataBinding.DefaultVB" %>

<!DOCTYPE html>
<html xmlns=''>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link href="styles.css" rel="stylesheet" />
    <script type="text/javascript" src="scripts.js"></script>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <telerik:RadClientDataSource runat="server" ID="DestinationMarkersData">
                <Select Url="JSON/DestinationMarkersData.json" DataType="JSON" ContentType="application/json" />

    <telerik:RadClientDataSource runat="server" ID="ContinentDataSource">
            <WebServiceDataSourceSettings ServiceType="GeoJSON">
                <Select Url="JSON/Continents/continent_Europe_subunits.json" DataType="JSON" ContentType="application/json" />

    <div class="demo-container size-auto">
        <telerik:RadMap RenderMode="Lightweight" runat="server" ID="RadMap1" Zoom="3">
                        <FillSettings Color="#e4d092" Opacity="0.4" />
                        <StrokeSettings Color="#b5a58d" />
                <telerik:MapLayer Type="Tile" Subdomains="a,b,c"
                    UrlTemplate="https://#= subdomain zoom #/#= x #/#= y #.png"
                    Attribution="&copy; <a href='' title='OpenStreetMap contributors' target='_blank'>OpenStreetMap contributors</a>.">
                <telerik:MapLayer Type="Shape" ClientDataSourceID="ContinentDataSource">
                <telerik:MapLayer Type="Marker" ClientDataSourceID="DestinationMarkersData" LocationField="location" TitleField="city">
                    <TooltipSettings Template="#= # - #= #"></TooltipSettings>
            <ClientEvents OnShapeClick="OnShapeClick" OnMarkerCreated="modifyToCustomMarkers" />
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            var controlID={
                continentSelector: "<%= ContinentSelector.ClientID %>",
                markerDataSource: "<%= DestinationMarkersData.ClientID %>",
                resetButton: "<%= ResetButton.ClientID %>"

    <telerik:RadAjaxManager runat="server" ID="theAjaxManager">
            <telerik:AjaxSetting AjaxControlID="demoConfigurator">
                    <telerik:AjaxUpdatedControl ControlID="ContinentDataSource" LoadingPanelID="RadAjaxLoadingPanel" />
                    <telerik:AjaxUpdatedControl ControlID="DestinationMarkersData" LoadingPanelID="RadAjaxLoadingPanel" />
                    <telerik:AjaxUpdatedControl ControlID="RadMap1" LoadingPanelID="RadAjaxLoadingPanel" />
    <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel" Transparency="50">

    <qsf:ConfiguratorPanel ID="demoConfigurator" runat="server">
                <qsf:ConfiguratorColumn ID="ConfiguratorColumn1" runat="server" Size="wide">
                    <ul class="fb-group">
                            <qsf:ComboBox runat="server" ID="ContinentSelector" Label="Choose Main Destination: " AutoPostBack="true">
                                    <telerik:RadComboBoxItem Text="Africa" Value="AfricaDataSource" />
                                    <telerik:RadComboBoxItem Text="Asia" Value="AsiaDataSource" />
                                    <telerik:RadComboBoxItem Text="Europe" Value="EuropeDataSource" Selected="true" />
                                    <telerik:RadComboBoxItem Text="North America" Value="NorthAmericaDataSource" />
                                    <telerik:RadComboBoxItem Text="Oceania" Value="OceaniaDataSource" />
                                    <telerik:RadComboBoxItem Text="South America" Value="SouthAmericaDataSource" />
                            <qsf:Button runat="server" ID="ResetButton" AutoPostBack="false" OnClientClicked="resetContinentMarkers" Text="Show all places in destination"></qsf:Button>


Support & Learning Resources

Find Assistance