I am trying to implement a Kendo Map, using ASP MVC, using Read, called from javascript. The call works, I get my data back through the Controller, but no matter what I try, I can't seem to get the right value into the LocationField, so the bubbles on my map do not work.
Here is the cshtml:
@(Html.Kendo().Map()
.Name("crimemapping_results")
.Center(Model.DefaultLatitude, Model.DefaultLongitude)
.Zoom(3)
.MinZoom(3)
.Wraparound(true)
.Layers(layers =>
{
layers.Add()
.Type(MapLayerType.Tile)
.UrlTemplate("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().AutoBind(false)
.Type(MapLayerType.Bubble)
.Style(style => style
.Fill(fill => fill.Color("#00f").Opacity(0.4))
.Stroke(stroke => stroke.Width(0))
)
.DataSource(dataSource => dataSource
.Read(read => read.Action("CrimeMapping_Map", "Home").Data("map_get"))
)
.LocationField("latlng")
.ValueField("DataCount");
})
.Events(events => events
.ShapeMouseEnter("onShapeMouseEnter")
.Reset("onReset")
)
)
In the javascript, I just do a read: $("#crimemapping_results").data("kendoMap").layers[1].dataSource.read();
This goes through my controller to my object model, where I return a single record, with the following fields:
public
List<MapData> GetMap(
string
pJSON,
int
pUserId)
{
dynamic _Json = JObject.Parse(pJSON);
var _Results =
new
List<MapData>();
var _Result =
new
MapData();
_Result.Jurisdiction =
"Holland City"
;
_Result.lat = Convert.ToString(42.787523);
_Result.lng = Convert.ToString(-86.108930);
_Result.latlng =
"["
+ _Result.lat +
","
+ _Result.lng +
"]"
;
_Result.DataCount = 25;
_Results.Add(_Result);
return
_Results;
}
I have tried all kinds of formats for the latitude and longitude. The values lat and lng are doubles, but I have also tried them as strings, but I get the same result. LocationField in the cshtml control only takes one argument. I have tried "latitude,longitude" as a string, then I tried it with [ ] 's on it. What happens is the whole latlng value ends up in the object under the location, lat value, if I look at the map control during runtime.
I put a console.log on hover to see what 'e' is, for the point on the map and here is what that looks like (file attached). It shows my object, with my latlng value all thrown into location lat. What value should go into LocationField, so that it ends up a latitude and l