This is a migrated thread and some comments may be shown as answers.

Change marker layer's data source

1 Answer 158 Views
Map
This is a migrated thread and some comments may be shown as answers.
Marc Arbesman
Top achievements
Rank 2
Marc Arbesman asked on 18 Jun 2014, 04:00 PM
Hello,

I am trying to set marks on a marker layer via JSON returned from my MVC controller.  I am capturing an onCriteriaChange event from a ListView.  In the event handler function I am try the following

var mapData = $('#map').data('kendoMap');
        mapData.layers[1].dataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    url: ('@Url.Action("getMapData")'),
                    dataType: "json",
                    data: { customerId: customer.Id }
                }
            }
        });
        mapData.layers[1].dataSource.read();

My declaration code is 

$("#map").kendoMap({
                          center: [30.268107, -97.744821],
                          zoom: 15,
                          layers: [{
                              type: "tile",
                              urlTemplate: "http://#= subdomain #.tile2.opencyclemap.org/transport/#= zoom #/#= x #/#= y #.png",
                              subdomains: ["a", "b", "c"],
                              attribution: "© <a href='http://osm.org/copyright'>OpenStreetMap contributors</a>." +
                                           "Tiles courtesy of <a href='http://www.opencyclemap.org/'>Andy Allan</a>"
                          },
                          {
                              type: "marker",
                              locationField: "latlng",
                              titleField: "name",
                              
                          }]
                      });

so you can see the layer already exists.  I just want to set a marker for the lat, long returned by my controller.  

I can verify that my controller is producing JSON (see attached screenshot).   But the markers do not show. Am I doing this correctly? Any help would be appreciated.

1 Answer, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 20 Jun 2014, 08:03 AM
Hello,

The DataSource instance can't be replaced directly as there's no suitable setDataSource method.
We'll add such method for the next release, but in the meantime you can use the following workaround:
mapData.layers[1].options.dataSource = new kendo.data.DataSource({});
mapData.layers[1]._initDataSource();

Apologies for the caused inconvenience.
As a token of gratitude for your involvement your Telerik points have been updated.

Regards,
T. Tsonev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Map
Asked by
Marc Arbesman
Top achievements
Rank 2
Answers by
T. Tsonev
Telerik team
Share this question
or