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

Binding radmap shapes layer from javascript

1 Answer 117 Views
Map
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 24 May 2015, 10:30 PM

Hi

 I'm trying to bind a RadMap to some JSON returned from an ASPX page.

 

<script>
    function TestGetMap()
    {
        var shapeData = "";
        $.ajax({
             type: "GET",
            url: "/Data/GetJsonTrip.aspx",
            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                shapeData = JSON.stringify(msg);
                var ds = new kendo.data.DataSource(shapeData);
                var kendoMap = $telerik.$("#<%=tripMap.ClientID %>").data("kendoMap");
                kendoMap.layers[1].dataSource = ds;
            }
        });
    }
</script>

I've tried setting the datasource to msg instead of the string version, tried different layers, etc.

My map looks like this

<telerik:RadMap runat="server" ID="tripMap">
    <LayersCollection>
        <telerik:MapLayer></telerik:MapLayer>
        <telerik:MapLayer Type="Shape"  Opacity="0.7">                   
            <StyleSettings>
                <StrokeSettings Color="#ffffff" Width="10" />
            </StyleSettings>
        </telerik:MapLayer>
    </LayersCollection>
    <CenterSettings  Latitude="-32.962926"  Longitude="151.699727"/>
</telerik:RadMap>

 I'm setting the first map layer in code to bing

MapLayer mapLayer = tripMap.LayersCollection[0];
mapLayer.Type = Telerik.Web.UI.Map.LayerType.Bing;
mapLayer.ImagerySet = "AerialWithLabels";

I confirmed that I'm getting back valid geojson from the aspx page.

I'm not getting any javascript errors in the console.

What I don't understand is: How in a click event in javascript can I set the dataource for a shapes layer of a radmap?

 

Thanks
Matt

 

 

 

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 26 May 2015, 03:31 AM

Hi Matthew,

The described situation have already been discussed in a ticket thread opened to us (ID 938403). Let us continue the conversation there.

For anyone interested on that matter. The suggestions are to use RadDataSource control for the data-binding scenario. Also, the layer to be bound, should be initially configured with a Type property set to Shape.

Additional materials:


Regards,

Ianko
Telerik
Tags
Map
Asked by
Matthew
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Share this question
or