This is a migrated thread and some comments may be shown as answers.
Updating datasource
4 Answers 94 Views
Map
This is a migrated thread and some comments may be shown as answers.
arno
Top achievements
Rank 1
arno asked on 30 Sep 2015, 07:06 AM

Hi,

What is the most efficient way to update the map layer datasource? For this map I use a url I'd like updated (because a get parameter changes).

I read this: http://d585tldpucybw.cloudfront.net/forums/change-marker-layer%27s-data-source

But it's outdated, currently there is no more _initDataSource() and the setDataSource() did find its way to the layer object but I can't get it to work:

don't find an example for it.

 also, I tried:

var layer = $("#selectionMap").data("kendoMap").layers[0];
layer.dataSource.transport ={read:$scope.baseUrl+"/MapStatistics"+"?countryvar="+$scope.ui.subSelections.countryVar};
layer.reset();

 Also tried this:

layer.setDataSource({type: "geojson",transport: {read:$scope.baseUrl+"/MapStatistics"+"?countryvar="+$scope.ui.subSelections.countryVar}})

 

Error: this.dataSource.unbind is not a function

So my question: Is there an efficient way to do this so the map is reloaded on layer url update?

thanks,

Arno
       

 

4 Answers, 1 is accepted

Sort by
0
arno
Top achievements
Rank 1
answered on 30 Sep 2015, 09:38 AM

For whomever would have the same issue, the following worked for me.

Change the layer as an option

var map = $("#selectionMap").data("kendoMap")
var layer = map.layers[0];
map.setOptions({layers:[{type: "shape",dataSource: {type: "geojson",transport: {read:$scope.PythonbaseUrl+"/MapStatistics"+"?countryvar="+$scope.ui.subSelections.countryVar}}  }]})

 Then reinitialize the layers

map._initLayers()

0
T. Tsonev
Telerik team
answered on 02 Oct 2015, 07:53 AM
Hello,

Thanks for sharing your findings with the community.

The layer setDataSource would be our recommendation, but I see that it has some issues we need to address.
First, it's not part of the documentation (yikes!). Second, it does require a live DataSource instance:
var dataSource = new kendo.data.DataSource({type: "geojson", ...});
layer.setDataSource(dataSource)

I'll update the docs and will also amend the method to accept configuration as well to match other widgets.
Apologies for the caused inconvenience.

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
K
Top achievements
Rank 1
answered on 02 Jul 2018, 02:33 PM

Hello,

Can you post the location of the documentation?  I am trying to update marker DataSource from button click event.  

Thanks, K

0
Alex Hajigeorgieva
Telerik team
answered on 04 Jul 2018, 10:57 AM
Hi, Karen,

The Kendo UI Map MarkerLayer setDataSource() method is documented at:

https://docs.telerik.com/kendo-ui/api/javascript/dataviz/map/marker-layer/methods/setdatasource

Let me know if you need further assistance.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Map
Asked by
arno
Top achievements
Rank 1
Answers by
arno
Top achievements
Rank 1
T. Tsonev
Telerik team
K
Top achievements
Rank 1
Alex Hajigeorgieva
Telerik team
Share this question
or