Ajax call to get GeoJson data from ASP.NET MVC Controller

后端 未结 2 1945
伪装坚强ぢ
伪装坚强ぢ 2021-02-08 19:35

Using ASP.NET MVC 3 with C# I have a web page to display a map onto which I want to add a polyline consisting of several latitude and longitude coordinates. With the Lea

2条回答
  •  野的像风
    2021-02-08 20:16

    I don't really have a magic bullet for this but I believe I can at least point you in the right direction.

    If you happen to be using PostGres/PostGIS, you could use the ST_AsGeoJson function to just return GeoJson straight from the database, which is handy. Otherwise you'll want to start out by looking into JSON.NET, which is the defacto standard JSON serialization library for ASP MVC. I found it to be a bit full-on, and I've not delved into it deep enough to suggest how you might proceed beyond just gaining a bit of familiarity.

    Also, it appears that there's a GeoJson plugin for JSON.NET which has a Nuget Package and corresponding GitHub repo. I've not used it personally so I can't exactly vouch for it's stability/feature set etc etc, but in any event it might be a good jumping off point.

    Hope this helps, and I'd be interested in hearing what you end up going with!

提交回复
热议问题