Introduction

GeoBase is a high-performance Geospatial mapping engine designed for rapid development and low total cost of deployment. Services provided by GeoBase include:

  • Street Mapping
  • Reverse geocoding
  • GeoFencing
  • Address Lookup (Geocoding)
  • Routing & Route Optimization
  • Navigation
  • Date Import Tools

This tutorial will describe how to add mapping services to your GeoBase application. At the end of this tutorial you will be able to:

  • Add a MapCtrl to your Windows Application.
  • Pan, zoom, and center a map.

Prerequisites

This tutorial assumes familiarity with Microsoft's Visual Studio. You will need a copy of Visual Studio 2005 or later and the GeoBase SDK with a valid license. Only a moderately-specified desktop computer is required.

In addition to the above, it's assumed that you can:

  • Create a new Visual Studio project.
  • Add a project reference to 'geobase.net.dll'

These tasks were covered in the 'Creating a GeoBase Project' tutorial.

Setup

Launch Visual Studio and create a new C# Windows Application. Choose an appropriate name and location for your project. Add a project reference to 'geobase.net.dll'.

Note: If you are using Visual Studio 2010 or later, be sure that the target framework is set to the full .NET framework and not a Client Profile. To check this, right click on the project in the Solution Explorer and choose Properites. On the Application tab of the project properties, check that the selected target framework is not a Client Profile.

Adding a Map Control

To add a MapCtrl to your form, first open the form designer.

 

Next, open the Toolbox (View > Toolbox) and right click on the Toolbox. Select 'Choose Items'.

Find and select the MapCtrl component. Make sure that the MapCtrl's checkbox is checked. Then click 'OK'.

Tip: Use the 'Filter' text box to search for 'map'.

If you can't find the MapCtrl in the component list, browse to 'C:\Program Files\Telogis\Geobase\bin' and select 'geobase.net.dll'. MapCtrl should then become visible in the component list.

Select the MapCtrl and drag it to your form. A new map will be created.

If you now run your project, you will be presented with a map. Note that you can pan the map by moving the mouse to one of the map edges and clicking when the cursor changes to an arrow.  You can zoom the map by defining a rectangular area with the mouse or using the mouse scroll wheel.

In the next section, we'll manually set the starting zoom and center of the map.

Centering and Zooming the Map

Double click the form in the Form Designer. You should be taken to the 'Form1_Load' method. This method will automatically be called when our application's form is loaded. Modify this method to match the code snippet below:

private void Form1_Load(object sender, EventArgs e)
{  
  mapCtrl.Center = new LatLon(33.647, -117.734);
  mapCtrl.Zoom = 3;
}

The first line of code centers the map on a new location specified by a latitude-longitude coordinate. The second line of code zooms the map.

When run, your application should now appear similar to the following image.

That's it!

For more tutorials and examples, browse the 'GeoBase Tutorials' and 'Common Concepts' section of the GeoBase reference documentation that is included with the GeoBase SDK. You can also view the documentation and tutorials online.

If you have any queries, please don't hesitate to contact us. We trust that you will enjoy the simplicity and ease-of-use afforded by the GeoBase .NET component.

Published, Jul 8th 2016, 02:17

Tagged under: dotnet geobase maps