Here are my thoughts on this.
I recently made a project that was one AJAX-based web application (I know you are not looking for an AJAX-based solution, but stay with me).
I included Google maps in this application, which was used to display the location of different objects.
When the user was looking for something, instead of doing Geo-Coding in the browser (which was, from time to time, very slow), I sent a request to the server. On the server, the incoming text was Geo-encoded (using the Google API), and the result was cached in a local database for later use. If the same request is repeated again, I will bring Geo-cordinates from the database and send it to the client.
The return type was pretty simple. i.e.
public class Marker { public double Lat{set;get;} public double Lon{set;get;} public string Title{set;get;} }
On the client, I just iterate over the list and mark the markers on the map (markers are faster to build than a geocoding request).
Now the same thing can be done in post back. All you have to do is call the initialization function
var markers = @Html.Action("GetMarkers")
this will populate the var markers with a list of all your markers, which you can then iterate over.
Remember that the return type of GetMarkers is
public JsonResult GetMarkers() { ...
source share