A little bit confusing here: I am wondering what kind of map scales MVC Web version provides: no limit or a pre-defined set of scales like Google/Bing?
Also, I have ESRI shape layers on the server side to service clients through web. As I read from your documentation, the spatial data is serviced as tiles? So I need to tile these layers? or this just applies to base layers?
Please clarify,
Thanks,
Map scales unlimiteless or discrete like Google/Bing?
Hi Guangming,
If you mean defining the custom scales for the panzoombar, then yes, we can do it like the below codes, the codes shows how to define a 24 zoomlevels which is more higher than the default map with 20 zoomlevels.
For you second question, though I am not clear what you mean “I need to tile these layers?”, but I think we don’t need to care how the layer is drawn and just add the layer into the map like the codes shows:
public ActionResult DisplayASimpleMap()
{
Map map = new Map(“Map1”,
new System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage),
new System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage));
map.MapUnit = GeographyUnit.DecimalDegree;
map.CurrentExtent = new RectangleShape(-125, 72, 50, -46);
ShapeFileFeatureLayer usaLayer = new ShapeFileFeatureLayer(Server.MapPath("~/App_Data/STATES.SHP"));
usaLayer.Open();
ZoomLevelSet customZoomlevelSet = GetCustomZoomlevelSet();
foreach (var item in customZoomlevelSet.GetZoomLevels())
{
item.DefaultAreaStyle = AreaStyles.Country1;
usaLayer.ZoomLevelSet.CustomZoomLevels.Add(item);
}
LayerOverlay overlay = new LayerOverlay(“overlay”);
overlay.IsBaseOverlay = false;
overlay.Layers.Add(usaLayer);
map.ZoomLevelSet = customZoomlevelSet;
map.CustomOverlays.Add(new WorldMapKitWmsWebOverlay());
map.CustomOverlays.Add(overlay);
return View(map);
}
private ZoomLevelSet GetCustomZoomlevelSet()
{
ZoomLevelSet zoomlevelSet = new ZoomLevelSet();
ZoomLevelSet googleZoomlevelset = new GoogleMapsZoomLevelSet();
foreach (var item in googleZoomlevelset.GetZoomLevels())
{
zoomlevelSet.CustomZoomLevels.Add(item);
}
ZoomLevel zoomlevel21 = new ZoomLevel(zoomlevelSet.CustomZoomLevels[zoomlevelSet.CustomZoomLevels.Count -1].Scale/2);
zoomlevelSet.CustomZoomLevels.Add(zoomlevel21);
ZoomLevel zoomlevel22 = new ZoomLevel(zoomlevelSet.CustomZoomLevels[zoomlevelSet.CustomZoomLevels.Count -1].Scale/2);
zoomlevelSet.CustomZoomLevels.Add(zoomlevel22);
ZoomLevel zoomlevel23 = new ZoomLevel(zoomlevelSet.CustomZoomLevels[zoomlevelSet.CustomZoomLevels.Count - 1].Scale / 2);
zoomlevelSet.CustomZoomLevels.Add(zoomlevel23);
ZoomLevel zoomlevel24 = new ZoomLevel(zoomlevelSet.CustomZoomLevels[zoomlevelSet.CustomZoomLevels.Count - 1].Scale / 2);
zoomlevelSet.CustomZoomLevels.Add(zoomlevel24);
return zoomlevelSet;
}
If anything confused, please feel free to let us know.
Thanks,
Troy
Good to know we can customize the # of scales. I understand this part.
My first question is: is this the only way your product support? with this, map can only zoom to a list of pre-defined scales, for example, 1:100, 1:500. I can never get to 1:145. Traditionally, if your data is vector based, we can render them in any scale.
Related to the question, if that is the only way of scaling you support. Seems to me, it will improve performance if the spatial data is pre-generated in tiles at different pre-defined scales in the server side and they are served as images. In your case, as you can customized the # of scales, you probably generate tiles on the fly, or just server vectors to be rendered on the fly. If this is true, I have a concern of performance, as every time when we zoom/pan map, we have to ask data from the server side.
Could you give a little bit more details about these? it would be great, if you have any document.
Thanks,
Hi Guangming,
I think this should be the simplest way to define the custom scales. Also we can add the scales into the openlayer map directly, but we still need to sync them to the server side and make it harder to manager the both side. So the above one should be the recommended one.
If you want to access to the 1:145 scale, I think you just need to add the scale into the customerzoomlevels and then should can access the this level, for example:
ZoomLevel zoomlevel21 = new ZoomLevel(1000);
ZoomLevel zoomlevel22 = new ZoomLevel(500);
ZoomLevel zoomlevel23 = new ZoomLevel(145);
ZoomLevel zoomlevel24 = new ZoomLevel(100);
zoomlevelSet.CustomZoomLevels.Add(zoomlevel21);
zoomlevelSet.CustomZoomLevels.Add(zoomlevel22);
zoomlevelSet.CustomZoomLevels.Add(zoomlevel23);
zoomlevelSet.CustomZoomLevels.Add(zoomlevel24);
The next question about the tiles, I guess you must mean how to cache the layer tiles images, if yes, please refer to the TileCache Generator Tool thinkgeo.com/forums/MapSuite…fault.aspx
If any questions, don’t hesitate to let us know.
Regards,
Troy