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

Shapes Layer

Earthquakes in April-May 2014

Earthquake magnitude: Earthquake magnitude

This example demonstrates how to data bind, display and customize shapes with RadMap. To do this, you need the data in GeoJSON format and to set the Type property of the MapLayer to Shape.

Two RadClientDataSource controls retrieve the countries and earthquakes data and provide it to the layers through their ClientDataSourceID property.

Each earthquake is represented in the GeoJSON as Feature object, where the details for the earthquake are within the Properties member. The Geometry member holds a Point object with the coordinates.

By default, each Point object in the Shape layer is automatically converted to a Marker, but it is possible to prevent the default behavior and create a circle object with coordinates and radius. To do this, we:

  • Handle the client-side OnClientMarkerCreated event and cancel it.
  • Handle the client-side OnClientShapeCreated event, obtain the dataItem associated with the Shape and calculate the radius and the color for each circle. The magnitude from the data item is used as a parameter for these calculations.

Finally, for displaying detailed information for each earthquake, we are using the client-side OnClientShapeClick event, where the event coordinates are used for calculating where the RadToolTip should be positioned. Again, the dataItem of the clicked shape is used to provide the message.

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • scripts.js
  • Styles.css
<%@ Page Language="C#"  %>

<!DOCTYPE html>
<html xmlns=''>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <script type="text/javascript" src="Scripts.js"></script>
    <link href="Styles.css" rel="stylesheet" type="text/css" />
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <telerik:RadClientDataSource runat="server" ID="RadClientDataSource1">
            <WebServiceDataSourceSettings ServiceType="GeoJSON">
                <Select Url="Content/countries.json" DataType="JSON" />
    <telerik:RadClientDataSource runat="server" ID="RadClientDataSource2">
            <WebServiceDataSourceSettings ServiceType="GeoJSON">
                <Select Url="Content/earthquakes.json" DataType="JSON" />

    <div class="demo-container size-auto">
        <h2 class="mapTitle">Earthquakes in April-May 2014</h2>
        <telerik:RadMap RenderMode="Lightweight" runat="server" ID="RadMap1" Zoom="2" MinZoom="2" Skin="Silk">
            <ClientEvents OnShapeCreated="shapeCreated" OnShapeMouseEnter="shapeMouseEnter"
                OnShapeClick="shapeClick" OnPan="clientPan" OnZoomStart="zoomStart"
                OnShapeMouseLeave="shapeMouseLeave" OnClick="clientClick" OnMarkerCreated="markerCreated" />
                <telerik:MapLayer ClientDataSourceID="RadClientDataSource1" Type="Shape" Opacity="1"></telerik:MapLayer>
                <telerik:MapLayer ClientDataSourceID="RadClientDataSource2" Type="Shape" Opacity="0.9"></telerik:MapLayer>
            <CenterSettings Longitude="32" Latitude="7" />
        <div class="mapFooter">
            <span class="aligner"></span>
            <span>Earthquake magnitude: </span>
            <img src="Legend.png" alt="Earthquake magnitude" />
    <telerik:RadToolTip RenderMode="Lightweight" runat="server" ID="Radtooltip1" Width="250px" Height="90px" TargetControlID="RadMap1" RenderInPageRoot="true"
        RelativeTo="Mouse" ShowEvent="FromCode" HideEvent="ManualClose" Position="BottomRight" Skin="Silk" EnableShadow="false">
        <div class="toolTipContentWrapper" id="toolTipContentWrapper">

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function findToolTip() {
                return $find("<%=Radtooltip1.ClientID%>");

Support & Learning Resources

Find Assistance