Error getting locations from server

2 posts, 0 answers
  1. Iwan van Ee
    Iwan van Ee avatar
    22 posts
    Member since:
    Dec 2009

    Posted 23 Sep 2014 Link to this post

    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?





  2. T. Tsonev
    Admin
    T. Tsonev avatar
    2772 posts

    Posted 24 Sep 2014 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
Back to Top