[mapguide-commits] r5690 - trunk/Tools/Maestro/Maestro.Base/Editor
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Thu Apr 7 10:47:30 EDT 2011
Author: jng
Date: 2011-04-07 07:47:30 -0700 (Thu, 07 Apr 2011)
New Revision: 5690
Modified:
trunk/Tools/Maestro/Maestro.Base/Editor/ResourcePreviewEngine.cs
Log:
#1651: The math to compress the spatial extent to accomodate the visible scale escapes me at the moment. So in the meantime, I've added a custom "zoom to scale" InvokeScript command to the generated web layout to assist in this workflow.
Modified: trunk/Tools/Maestro/Maestro.Base/Editor/ResourcePreviewEngine.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Editor/ResourcePreviewEngine.cs 2011-04-07 14:27:51 UTC (rev 5689)
+++ trunk/Tools/Maestro/Maestro.Base/Editor/ResourcePreviewEngine.cs 2011-04-07 14:47:30 UTC (rev 5690)
@@ -69,8 +69,11 @@
//Create temp map definition to house our current layer
var mdfId = "Session:" + sessionId + "//" + Guid.NewGuid() + ".MapDefinition";
- var mdf = ObjectFactory.CreateMapDefinition(conn, Properties.Resources.PreviewMap, ldf.GetCoordinateSystemWkt(), ldf.GetSpatialExtent(true));
+ var extent = ldf.GetSpatialExtent(true);
+ //TODO: Based on the visible scales in this layer, size this extents accordingly
+ var mdf = ObjectFactory.CreateMapDefinition(conn, Properties.Resources.PreviewMap, ldf.GetCoordinateSystemWkt(), extent);
+
mdf.AddLayer(null, ResourceIdentifier.GetName(ldf.ResourceID), ldf.ResourceID);
conn.ResourceService.SaveResourceAs(mdf, mdfId);
@@ -79,6 +82,10 @@
{
//Create temp web layout to house this map
var wl = ObjectFactory.CreateWebLayout(_edSvc.GetEditedResource().CurrentConnection, new Version(1, 0, 0), mdfId);
+
+ //Add a custom zoom command (to assist previews of layers that aren't [0, infinity] scale)
+ AttachZoomToScaleCommand(wl);
+
var resId = "Session:" + sessionId + "//" + Guid.NewGuid() + ".WebLayout";
conn.ResourceService.SaveResourceAs(wl, resId);
@@ -99,6 +106,28 @@
return url;
}
+ private static void AttachZoomToScaleCommand(IWebLayout wl)
+ {
+ var cmd = wl.CreateInvokeScriptCommand();
+ cmd.Name = "ZoomScale";
+ cmd.Label = "Zoom to Scale"; //LOCALIZEME
+ cmd.Tooltip = "Zoom to a specified scale";
+ cmd.Script = @"
+ var map = parent.parent.GetMapFrame();
+ var center = map.GetCenter();
+ var scale = parseFloat(prompt('Enter the scale:'));
+ map.ZoomToView(center.X, center.Y, scale, true);
+ ";
+
+ cmd.TargetViewer = TargetViewerType.Ajax;
+ cmd.ImageURL = "../stdicons/icon_zoom.gif";
+
+ wl.CommandSet.AddCommand(cmd);
+
+ var item = wl.CreateCommandItem(cmd.Name);
+ wl.ToolBar.AddItem(item);
+ }
+
private string GenerateMapPreviewUrl(IResource res)
{
string url = _rootUrl;
@@ -116,6 +145,10 @@
{
//Create temp web layout to house this map
var wl = ObjectFactory.CreateWebLayout(_edSvc.GetEditedResource().CurrentConnection, new Version(1, 0, 0), mdfId);
+
+ //Add a custom zoom command (to assist previews of layers that aren't [0, infinity] scale)
+ AttachZoomToScaleCommand(wl);
+
var resId = "Session:" + sessionId + "//" + Guid.NewGuid() + ".WebLayout";
conn.ResourceService.SaveResourceAs(wl, resId);
More information about the mapguide-commits
mailing list