Project Description
A .NET 3.5 web control that you can include in your project. This control extracts data from SQL 2008 geometry columns and draws a map image on your web page. The source download includes a Sample web page and a sample SQL 2008 database. Works in IE, FF, Opera, Chrome & Safari


Important Notice
This project is no longer supported, and is left as a sample and exercise on what's possible with just SQL Server geometry queries.

Requirements
  1. SQL Server 2008, any edition including the free Express Edition will work
  2. Visual Studio 2008. The free "Visual Studio Web Developer Express" works well.

Getting Your Data into SQL Server
  1. Install SQL Server 2008. The free express version will work just fine (http://www.microsoft.com/express/sql/download/). Just make sure you download the "With Tools" or "With Advanced Services" version to get the basic version of SSMS. Once you're set up, create a database for your GIS data
  2. Load your shapefile and attributes into SQL Server using "Shape2Sql.exe" from SqlSpatialTools (http://www.sharpgis.net/page/SQL-Server-2008-Spatial-Tools.aspx)
  3. After your data is loaded, fix up the geometry column by running the following update against your table in SSMS:
update <tablename> set <geometrycolumnname> = <geometrycolumnname>.MakeValid()

Using the MapViewer Control in Your Visual Studio Project
  1. Download the source code
  2. Copy the files with names starting with "MapViewer" to your project
  3. Copy the images directory to your project
  4. Create a Connection to the database with spatial data in it. (See above for getting spatial data into SQL 2008).
  5. Look at "Sample.aspx" and "Sample.aspx.cs" for an example of how to set up the MapViewer Control


Running the Included Sample Project
  1. Install SQL Server as above.
  2. In SSMS, right click on 'Databases' in the Object Explorer. Select 'Restore Database'. Enter 'GIS' in the To Database field. Click on From Device, and then the "..." button to the right. Click 'Add' and then locate the "GIS.BAK" file from the source code download. Click Ok, and then Ok again to restore the backup.
  3. Open the project in Visual Studio, and change the connection "GISLocalConnectionString" in web.config to point to your SQL Server 2008 installation and to use credentials with access to the database restored above.
  4. Run the Sample.ASPX file in the browser/debugger.
  5. As an example, enter 'cuba' in the country name field.


Troubleshooting
  1. If you receive a 404 error for your page in ii6 or later and the log entry has 1260 as the sc-win32-status, then you need to allow ASP.NET server extensions in the Web Service Extensions in your IIS manager.
  2. If you receive a .NET error saying that Microsoft.SQLServer.Types cannot be loaded, then you need to install the Microsoft SQL Server System CLR Types (SQLSysClrTypes.msi) from the Microsoft SQL Server 2008 Feature Pack, October 2008 on the microsoft.com site.


Acknowledgements
My thanks to the Spatial Viewer project, http://www.codeplex.com/SpatialViewer without which the MapViewer project would not have happened.

Last edited Feb 13, 2014 at 10:26 PM by aureolin, version 12