MapXtreme v7.0 Brings Mapping to Visual Studio Applications

By Peter Varhol

MapInfo MapXtreme v7.0, which came out late last year, is a comprehensive mapping software development kit (SDK) integrated with Microsoft Visual Studio. Microsoft developers will use it to build specialized mapping applications that require a fine-grained level of control over features. It incorporates a comprehensive class library enabling developers to write code in the same way they use the .NET Framework.

MapXtreme allows developers to create custom mapping applications that require both high-quality digital maps, and controls and instructions to manipulate those maps. It enables developers to incorporate and display many types of data onto maps, and to easily add a variety of controls, themes, graphs and other features that enable users to more effectively analyze location-based information. Real estate professionals use it to analyze locations for development; technical support representatives use it to look for root causes of service outage patterns; engineers use it to examine highway patterns for future growth.
MapXtreme v7.0 offers a number of built-in controls that make it easy for developers to deliver a high level of flexibility into custom mapping applications. (Click for larger view.)

MapXtreme v7.0 incorporates an array of new features over v6.0, such as grid analysis, linear referencing and dynamic segmentation, improved performance of shapefiles, and an extensible workspace manager for application development. It supports both SQL Server 2008 Spatial and Oracle 11G, as well as SpatialWare for Microsoft SQL Server and IBM Informix. The data provider model makes it possible to take data from a wide variety of data sources, integrate them into a single table, and use this table as a single data source for an application.

This review looks at a variety of MapXtreme features that help in building common applications, specifically for the Web. It includes the basics of creating an application using the MapXtreme project templates, how to use MapXtreme controls, working with data, enabling search features, using geocoding capabilities and building fast, Ajax-enabled user interfaces.

MapXtreme v7.0 requires either Visual Studio 2005 or 2008, along with the .NET Framework 2.0. If you're using Visual Studio 2008, it will offer to begin or upgrade your project to the latest installed Framework, which you may want to do, depending on your company standard. As long as you're using at least 2.0, the Framework version has no discernible effect on performance.

The product installs on Visual Studio, providing the developer with its features from within the development environment. Launching Visual Studio, the developer can choose between a rich client or Web (ASP.NET) project. MapXtreme v7.0 provides templates for either type of project. Selecting File -> Project -> New lets the developer choose a MapXtreme project for a WinForms, or rich client, application. Selecting File -> Website -> New provides a template for a MapXtreme ASP.NET application. The documentation notes that applications developed for the desktop can be moved to the Web and vice versa with minimal effort, but I didn't try to move applications between platforms in my efforts.

Starting with Visual Studio
Launching either type of project opens what appears to be a normal empty project within Visual Studio. It includes access to the object model and class library provided by MapXtreme, as well as specific configuration files needed to build the project.

Before writing a line of code, it's useful to understand some mapping concepts used by MapXtreme. The map is the foundation object of a MapXtreme application; it shows the spatial relationship between geographic and other items such as grids we may wish to place on it. We can put features, labels and legends on a map and use layers to control the order of placement and provide the user with a way of determining what is displayed on a map. We can also apply themes, which are visual ways of summarizing data that are available with the map.
MapXtreme provides the ability to incorporate dynamic legends into mapping applications so that developers can provide detailed descriptions and explanations of mapped information to users. (Click for larger view.)

Finally, we can give the user tools with which to control the map, along with how it is displayed. These tools include zooming, panning and drawing lines between different points on the map. Other capabilities include applying coordinate systems and identifying locations through those coordinates and enabling routing between two or more points.

All applications that get developed using the MapXtreme object model are built atop of the MapInfo.Windows or MapInfo.Web namespace. These namespaces contain controls, tools and other functionalities specific to the rich client and Web platforms, respectively. The map is contained in a MapControl that also provides basic tools for viewing the map, such as panning, zooming and centering.

There are about a dozen additional namespaces, which include the ability to access and manage data, working with coordinate systems, displaying maps, creating legends and themes, persisting data and more. You instantiate objects off of these namespaces and use methods associated with the classes to build mapping applications.
Developers can use MapXtreme .NET classes to incorporate themes into mapping applications, enabling users to visualize data in ways that make sense for their needs. (Click for larger view.)

You can also use classes and methods in the .NET Framework to provide additional functionality. You're already doing that by incorporating windows, scroll bars and standard non-mapping controls in the application, so any mapping application is likely to be a combination of .NET development techniques you already know, plus similar MapXtreme techniques.

Starting a Mapping Application
For the purposes of this review, I decided to work with ASP.NET Web projects, as this is the most likely platform for custom mapping applications within an enterprise. My first exercise involved building an application from parts of applications supplied by the vendor in examples and tutorials. I wrote relatively little new code for this application, as might be the case with a developer new to the environment.

The Web project uses IIS and the ASP.NET service, so you first have to configure and start these components before trying to build a project. An application built using MapXtreme v7.0 runs as an ASP.NET application under the worker process of IIS. Chances are you already have experience writing such Web applications and the overall model is the same with MapXtreme, with the use of additional controls and namespaces.

I started with an existing example and copied and pasted code from other examples, plus writing some of my own code, and within a couple of hours had a reasonable amalgamation of a basic mapping application that might be useful in an enterprise. (I'm better than an entry level programmer, and am knowledgeable in Microsoft programming techniques, but programming isn't my day job.) It was easy enough so that I didn't even have to consult the documentation in order to piece together a small but functional application from the sample and tutorial applications.

Building an application from scratch, however, requires some upfront time to learn and understand the MapXtreme programming model. The MapXtreme Session is the starting point for all MapXtreme applications. It manages the initialization of resources needed for a MapXtreme application. You access the MapXtreme Session by calling the MapInfo.Engine.Session.Current() method. That ensures that each thread has a MapXtreme Session object available.

MapXtreme provides three Web controls - MapControl, LayerControl and LegendControl— and a number of map tools. The Web controls show content, such as a map, a list of maps and label layers and their properties or a legend. The tools interact with the MapControl to change the view of the map or to select specific features on the map.

The MapControl object is the main Web control in a MapXtreme application; it displays the background map and responds to tool interactions on the map. When called, the map is rendered and exported as an image and returned to the browser.

In practice, this means that you start with an ASP.NET form and place the MapControl on the form as a placeholder for the map. As is usually the case with a Visual Studio application, you get to adjust the properties of the control through the properties window. Here is where you can load the map; alternatively, if the map can be chosen by the user at runtime, you can do this in code with a file browser and button control.

The architecture used by a MapXtreme Web application is the Model-View-Controller (MVC) design pattern, in which the application logic represents the Model, the Web page with displays and controls represents the View, and the MapXtreme Server that responds to requests for information represents the Controller.

The mapping controls are built into the Web (and desktop) projects, so to have access to these controls all you have to do is choose a MapXtreme project type. All applicable files and toolbox items will be automatically loaded in the project and ready for use.

Other Features Round Out Mapping Applications
You can enable users to search for features within a map. MapInfo.Data.Find namespace contains the classes to use when searching for map features by address, street intersection or name. MapXtreme attempts to find an exact match in which the result is a character match to the input address, place name or intersection. If it cannot make an exact match, MapXtreme attempts to find close matches based on its matching rules and the settings you've used for the application.

The Find class provides a number of properties you can use to control the search operation. You have four search methods available to use. Two of them enable searching addresses or features and two are for searching street intersections. You can also configure the application to find a close match to a search term. The FindCloseMatch object represents a close match item returned from the Find Search method.

To use this feature, you must first set the UseCloseMatches and CloseMatchesMax properties of the Find object so that the method knows what represents a close match. Both the search methods and FindCloseMatch are returned using the FindResult object.

Once you find locations, you can also do routing between two or more locations, using one of several possible routing algorithms. This feature is available through the use of a separate Web service from Pitney Bowes Business Insight.

Accessing databases and working with data are integral parts of a mapping application and MapXtreme provides a namespace and other tools for accessing a relational database (various versions of Microsoft SQL Server and Oracle are supported). It also offers the Feature object model as another way to access data that use objects instead of SQL.

The most useful data capability is the ability to build data tables for use in an application that are constructed from different databases. You can create a table, for example, with a join from two different SQL DBMSs. For organizations that keep critical data across different databases, the ability to merge location data into an application might be the most useful data access capability of MapXtreme.

You can also use ASP.NET Ajax in a MapXtreme application. This involves the use of JavaScript to update specific data fields without refreshing the entire page. It improves application performance by reducing network traffic and eliminating constant page refreshes. The end result is that your Web application has more of a desktop-like responsiveness. In addition, MapXtreme Web controls, themselves, are JavaScript-enabled and do not trigger a full-page postback with each use.

To use ASP.NET Ajax, you place a Visual Studio ScriptManager control onto the form, and then drag an AJAX UpdatePanel control onto the form in the area you want to apply Ajax. Then you move the appropriate controls, such as Button or Text controls, inside the UpdatePanel. The Windows UpdatePanel control automatically provides the mechanism for communicating with the server for fast updates.

There are many more features than can be described in a short review. Developers can add themes to the map in order to display location or demographic data in thematic ways, and add legends to be able to identify features on maps.

You can also do geocoding - determining the geographic location of a street address, intersection, place or postal code in order to locate it on a map. Geocoding makes use of a Pitney Bowes Business Insight Web service that is a separate product from MapXtreme v7.0. You can also work with raster images and grids to expand the availability of maps and map features.

Finishing Up and Deploying
You deploy a completed application as you would a rich client on the desktop or Web application on IIS. A Web application, of course, is deployed only once on a server running IIS, while a desktop application can be installed on many systems. MapXtreme v7.0 requires that you include a runtime license in every deployment, whether desktop or Web. To do so, you must either provide the license in your package or incorporate a licensing tool for your customers to obtain the license themselves.

MapXtreme v7.0 works with Visual Studio 2005 or 2008 Professional and Standard editions, using the .NET Framework 2.0 or above. It runs on Windows XP SP2 or above, including Windows Server 2008. I ran it on 64-bit Windows 7 Professional edition with no issues. For ASP.NET applications, it supports Internet Explorer 6, 7 and 8, as well as Firefox 2.0, 3.0 and 3.5.

Any developer who is comfortable using Visual Studio should have no problem picking up MapXtreme. While there is a learning curve involved with the class library, the product mitigates that by providing a printable reference chart with the class hierarchy, as well as extensive examples. The best way to learn is to build the examples and run them to see what mapping applications look like; then examine the code for these applications. Finally, by skimming through the documentation, you can pick up terminology and concepts to get you started in building more comprehensive applications. MapXtreme Help is integrated with the Visual Studio help system, so you get comprehensive explanations and short examples simply by pressing the F1 key.

There is more to learn and understand about mapping and map display with MapXtreme v7.0 but both the documentation and class library are accessible and easy to understand and apply (though the manual is a whopping 650 pages, in PDF format). However, a Visual Studio developer with little or no experience in mapping doesn't have to know all that much in order to write professional mapping applications geared toward specific purposes.

Visual Studio developers will be able to accelerate the development of sophisticated map applications, putting highly detailed and relevant geographic information into the hands of end users. Developers will have the flexibility of combining MapXtreme 2008 code methods with .NET Framework calls and custom code to create the exact application required for a business problem. In addition, the ability to create single data objects from multiple data sources means that no enterprise data are out of bounds in providing applications that let end users visualize geographic concepts.

End users of mapping applications using MapXtreme v7.0 will have the combination of a familiar Microsoft user interface, whether desktop or Web, and the controls and other advanced capabilities of the MapXtreme class library. Enterprises needing to integrate geographic data from multiple sources into an application that incorporates grids and other techniques for finding and comparing locations will be able to employ MapXtreme classes right out of the box.

Published Friday, April 9th, 2010

Written by Peter Varhol

If you liked this article subscribe to our bimonthly newsletter...stay informed on the latest geospatial technology

Sign up

© 2017 Directions Media. All Rights Reserved.