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

Error getting locations from server

1 Answer 50 Views
Map
This is a migrated thread and some comments may be shown as answers.
Iwan van Ee
Top achievements
Rank 1
Iwan van Ee asked on 23 Sep 2014, 06:41 AM
I get an error in kendo.all.min.js when I try to get locations from my server.
Using this code with version 2014.2.716:

@(Html.Kendo().Map()
    .Name("map")
    .Center(52.0364073866421, 5.08653521339329)
    .Zoom(17)
    .Layers(layers =>
    {
        layers.Add()
            .Type(MapLayerType.Tile)
            .UrlTemplateId("http://#= subdomain #.tile.openstreetmap.org/#= zoom #/#= x #/#= y #.png")
            .Subdomains("a", "b", "c")
            .Attribution("© <a href='http://osm.org/copyright'>OpenStreetMap contributors</a>");
 
        layers.Add()
            .Type(MapLayerType.Marker)
            .DataSource(dataSource => dataSource
                  .Read(read =>
                      read.Action("GetMapLocations", "Map")
 
                      )
            )
            .LocationField("LatLng")
            .TitleField("Name");
    })
)

I don't get any markers on the map, but just the error 'Uncaught TypeError: undefined is not a function ' in the kendo file.

The Data I get back from the GetMapLocations is:
{
    "Data": [
        {
            "Id": "193bfa30-ab5a-4752-9e9c-1d5187d49047",
            "Name": "1",
            "Position": {
                "Id": "4f0e020c-2e94-4761-93c7-eef076b348ce",
                "Latitude": 52.014538374454474,
                "Longitude": 5.114317642759112,
                "LatLng": [
                    52.014538374454474,
                    5.114317642759112
                ]
            },
            "LatLng": [
                52.014538374454474,
                5.114317642759112
            ]
        },
        {
            "Id": "8c85a22f-3c8e-4ccc-9470-f4b8af99db5c",
            "Name": "100",
            "Position": {
                "Id": "050d1479-74b3-45dc-8828-7dbecdd5c71b",
                "Latitude": 52.03355319309421,
                "Longitude": 5.084548511286869,
                "LatLng": [
                    52.03355319309421,
                    5.084548511286869
                ]
            },
            "LatLng": [
                52.03355319309421,
                5.084548511286869
            ]
        }
    ],
    "Total": 9360
}

Any idea what's wrong?





1 Answer, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 24 Sep 2014, 12:23 PM
Hello,

The bound fields of your model are nested within a "Data" array.
Is there any chance that you're returning a DataSourceResult from your controller?

Try returning the data directly if this is the case?

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Map
Asked by
Iwan van Ee
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Share this question
or