By Daniel Du
You may come across the InitialMapView sample page in php, It expects the values to be passed to the script as query string parameters, and zoom to specified view port when loading the map. Here is an intelligent landing page MapGuide Viewer in .NET, and with more extended functionalities.
What is the function of this sample application?
1. Zoom to specified view port by initial x, y and scale, the URL is expected as below: http://serverName/MgViewerExtention/Default.aspx?X=-87.723233&Y=43.754561&scale=5000
It works by taking a copy of the WebLayout stored in the Library repository and changing the <CenterX/>, <CenterY/> and <Scale/> elements. The updated XML is written into the Session and is used as the target when the page is ultimately loaded.
2. Query, zoom to and highlight by filter string. It accepts layer name, keyFieldID and id value, for following URL, map viewer zooms to the objects corresponding to “Autogenerated_SDF_ID in (1812,1813)” in the layer Parcels, highlighted if “highlight=1”.
3. Filter features shown on map. You may have thousands even millions of features in a data source, but sometime you do not need to show all of them on map. With a filter string in URL, you can filter the features in MapGuide viewer when the viewer shows up. With following URL, I only show the parcels which Autogenerated_SDF_ID great than 1000:
http://localhost/MgViewerExtention/Default.aspx?Layer=Parcels&layerfilter=Autogenerated_SDF_ID > 10000
The sample project can be downloaded here, it is based on AIMS 2013, but it could be easy to apply it to other version of AIMS/MapGuide. If you are interested in how it is implemented in detail, please download and read the code. Hope it helps.
[Updated: October, 26, 2012]
How to install this sample application?
I am often asked how to install/use this sample application, here is the detailed steps:
1. unzip the sample application to a folder of your web server where Map Server Extension is installed. Let’s say: C:\Work\CodeSamples\MgViewerExtention
2. Copy all dlls from “C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2013\www\mapviewernet\bin” to “C:\Work\CodeSamples\MgViewerExtention\MgViewerExtention\bin”
3. Copy “WebConfig.ini” from “C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2013\www” to “C:\Work\CodeSamples\MgViewerExtention\MgViewerExtention”
4. Since I am using web application as visual studio project, you need to rebuild the project. Open the “MgViewerExtention.sln” file in Visual Studio 2010, add references to OSGeo.MapGuide.* from MgViewerExtention\bin folder and set “CopyLocal” to FALSE. Then Build and fix any outstanding problems.
5. Open Internet Information Services(IIS) Manager by typing “inetmgr” in Start –> Run
6. Add a application in IIS. Right click “Default Web Site” and select “Add Application”, input alias as “MgViewerExtension”, please note that the URL to access this web application will be http://localhost/<yourAliasName>, for me it is http://localhost/MgViewer/Extension. It is recommend to select "MapServer2013App” as application pool. You will notice that it is using .net Framework 4.0 for AIMS2013. The physical path refers to the folder which contains the ASPX web page, for me, it is C:\Work\CodeSamples\MgViewerExtention\MgViewerExtention.
7. Give it a run and test, refer to the top of this post for test URLs.
How to Debug and Extend this further?
1. Open the “MgViewerExtention.sln” solution is Visual Studio 2010, set an break points at somewhere.
2. Launch the browser to the MgViewerExtension.
3. Attach to process from Debug menu, attach to “w3wp”, please note the username should be “MapServer2013App” as it may have more than one “w3wp” process.
4. Refresh the webpage, your break point will be hit.
Please refer to this video at MapServer Developer Center, it is for AIMS 2012 x64, but it still applies to AIMS 2013 as well.
Video : Autodesk® Infrastructure Map Server 2012 API Webcast
Recorded version of the Autodesk® Infrastructure Map Server 2012 API webcast
View Online | Download
It should be easy to use it for AIMS 2012 as well, Here are some critical point to be noticed:
1. Using the correct Dlls/References of AIMS2012
2. Change Target Framework to .NET Framework 3.5 in Visual Studio.
3. Change the url of viewer path:
string viewerPathSchema = @"/mapserver2012/mapviewerajax/
ajaxviewer.aspx?Weblayout={1}&SESSION={0}";
4. Rebuild and fix any outstanding problems.
5. Select an application pool with .NET Framework 2.0(ASP.NET 2.0) when creating Applications in IIS:
Hope this helps.