Updating datasource

3 posts, 0 answers
  1. arno
    arno avatar
    14 posts
    Member since:
    Jun 2014

    Posted 30 Sep 2015 Link to this post


    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};

     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?




  2. arno
    arno avatar
    14 posts
    Member since:
    Jun 2014

    Posted 30 Sep 2015 in reply to arno Link to this post

    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


  3. T. Tsonev
    T. Tsonev avatar
    2762 posts

    Posted 02 Oct 2015 Link to this post


    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", ...});

    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.

    T. Tsonev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top