Dynamic Marker display on RadMap
1 Answer 7 Views
Map
Kostas
Top achievements
Rank 1
Kostas asked on 15 Jul 2021, 05:17 PM

Hello,

I have followed the example shown here https://demos.telerik.com/aspnet-ajax/map/examples/data-binding/dataset/defaultcs.aspx to add a marker collection via a DataSet on my map.

I am now trying to remove or update the locations without success, either by re-setting the DataSource object or my clearing the MarkersCollection without any success. For example:

protected void ClearMarkers_Click(object sender, EventArgs e) { 
    RadMap.MarkersCollection.Clear();
    RadMap.DataSource=null;
    RadMap.DataBind();
}
How can I dynamically remove/update the markers in the map?
Thanks

1 Answer, 1 is accepted

Sort by
0
Doncho
Telerik team
answered on 20 Jul 2021, 07:13 AM

Hi Kostas,

I have already sent an answer to your formal support ticket on the same topic. In case any further questions come up, I would suggest proceeding with the conversation in the support thread only.

For better visibility I am pasting my answer here as well:

The RadMap control is a server-side wrapper of the entirely client-side Kendo Map widget, see Map Overview.

With this in mind, I would suggest you use a client-side approach for clearing the markers:

For instance on a Button client click:

<telerik:RadButton runat="server" ID="RadButton2" Text="Call JavaScript function" AutoPostBack="false" OnClientClicked="OnClientClicked" />
<script>
    function OnClientClicked(sender, args) {
        var map = $find("<%= RadMap1.ClientID %>");
        map.kendoWidget.markers.destroy();
    }
</script>

On the other hand, you can also interact with the MarkersCollection on the server-side, see How to Add Markers. And to remove the markers you can try simply calling the  RadMap1.MarkersCollection.Clear() method without binding the Map again.

 

Kind regards,
Doncho
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Map
Asked by
Kostas
Top achievements
Rank 1
Answers by
Doncho
Telerik team
Share this question
or