I can not seem to get a GeoJSON layer with MultiPoint data to display. My map code looks like this (using the ASP.NET MVC wrapper):
My action code looks like (using JSON.NET Linq):
I have verified that the action gets called and that it generates the following GeoJSON file:
None of the points are shown on the map. The alert in onShapeCreated also doesn't get called, which makes me think there's something wrong with the GeoJSON - but it looks good to me based on the specification. What am I missing?
Thanks,
Dave
@(Html.Kendo().Map()
.Name("map")
.Center(39.50, -98.35)
.Zoom(3)
.Layers(x =>
{
x.Add().Type(MapLayerType.Tile).UrlTemplateId("http://tile.openstreetmap.org/#= zoom #/#= x #/#= y #.png");
x.Add().Type(MapLayerType.Shape)
.Style(y => y.Fill(z => z.Color("#000000").Opacity(1)))
.DataSource(y => y.GeoJson().Read(z => z.Action(MVC.MyController.Map())));
})
.Events(events => events
.ShapeCreated("onShapeCreated")
)
)
<
script
>
function onShapeCreated(e) {
alert('shape!');
}
</
script
>
My action code looks like (using JSON.NET Linq):
public
virtual
ActionResult Map()
{
List<Tuple<
double
,
double
>> coordinates =
new
List<Tuple<
double
,
double
>>(){
new
Tuple<
double
,
double
>(39.50, -98.35),
new
Tuple<
double
,
double
>(30.268107, -97.744821)
};
JObject featureCollection =
new
JObject(
new
JProperty(
"type"
,
"FeatureCollection"
),
new
JProperty(
"features"
,
new
JArray(
new
JObject(
new
JProperty(
"type"
,
"Feature"
),
new
JProperty(
"properties"
,
new
JObject()),
new
JProperty(
"geometry"
,
new
JObject(
new
JProperty(
"type"
,
"MultiPoint"
),
new
JProperty(
"coordinates"
, coordinates.Select(c =>
new
JArray(c.Item1, c.Item2)).ToArray())
))
)
))
);
ContentResult result =
new
ContentResult();
result.Content = featureCollection.ToString();
result.ContentType =
"application/json"
;
return
result;
}
I have verified that the action gets called and that it generates the following GeoJSON file:
{
"type"
:
"FeatureCollection"
,
"features"
: [
{
"type"
:
"Feature"
,
"properties"
: {},
"geometry"
: {
"type"
:
"MultiPoint"
,
"coordinates"
: [
[
39.5,
-98.35
],
[
30.268107,
-97.744821
]
]
}
}
]
}
None of the points are shown on the map. The alert in onShapeCreated also doesn't get called, which makes me think there's something wrong with the GeoJSON - but it looks good to me based on the specification. What am I missing?
Thanks,
Dave