I’m trying to build a map in the controller and pass it as the Model into the view. Here’s my View:
<div class="twelve columns" id="main">
@Html.ThinkGeo().Map(Model).Render();
</div>
When I run this controller action, the map comes up empty; and when I try to zoom in on the empty map, I get a message saying “parameter is not valid” :
public ActionResult Index()
{
var currentlocation = new RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962);
var map = new Map("Map1", new System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage), 512)
{
MapBackground = new BackgroundLayer(new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"))),
CurrentExtent = currentlocation,
MapUnit = GeographyUnit.DecimalDegree
};
var osmLayer = new OpenStreetMapLayer { TileCache = new FileBitmapTileCache(@"C:\Test\OSMTileCache") };
LayerOverlay osmOverlay = new LayerOverlay("OSMOverlay")
{
Name = "OSM Map",
IsVisible = true,
ServerCache = new ServerCache(@"C:\Test\ServerCache"),
IsBaseOverlay = true
};
osmOverlay.Layers.Add(osmLayer);
map.CustomOverlays.Add(osmOverlay);
return View(map);
}
… if I run this in the controller instead, the map shows up fine, but I haven’t found anywhere to set the caching properties using this approach:
…
var osmOverlay = new OpenStreetMapOverlay("osmoverlay");
map.CustomOverlays.Add(osmOverlay);
return View(map);
My goal is to get create the map from the controller with server-side tile caching.
Any help would be appreciated.
Thanks,
Eric