Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Intergate Bing Map with your Mobile Applications

0.00/5 (No votes)
17 Oct 2010 1  
Bring Bing Map, OpenStreetMap to your Mobile Applications

Introduction

Guidebee Digital Map API implements a GIS engine on different platforms (JavaME, JavaSE, Android, Windows Mobile, iPhone, .NET). It supports online, offline, raster and vector map in the same package, and supports find an address and get a direction.

The following picture shows the feature set and supported platform of Guidebee Map API.

FeatureSet1.PNG

Background

Google, Microsoft, Yahoo, etc. all provide map API which are mainly used to develop web-based applications. But these Map APIs do not always work properly on mobile phones because of lack of full featured web browser and sometimes it's needed to integrate digital map with your applications such as GPS tracking application, etc. Guidebee Map API fill such gaps, it supports most mobile platforms. Here we give a simple example on how to use the Map API on Windows mobile. For other platforms, please go to this link and find the sample code and document.

Setup the Licence Info

In order to use the Map API, a valid licence file is needed, either trial licence (free) or commercial licence. Normally, you can get the trial licence from our website.

//set the licence info.
LicenceManager licenceManager = LicenceManager.GetInstance();
//expire Tue May 03 13:20:28 CST 2011
long[] keys = { 0x4e904c2cf42f4d8bL, -0x2ca3c87cde2b375aL, 0x41c89a4816826efdL,
 0x19ed31444f0cce55L, -0x5f64a79a7a0c8b49L, 0x39f03a1bfdf51342L, };
licenceManager.AddLicence("DotNetDigitalMap", keys);        

Create the Map Object

//optional, get the tile url from server.
Mapdigit.Gis.Raster.MapType.UpdateMapTileUrl();
MapLayer.SetAbstractGraphicsFactory(NETGraphicsFactory.GetInstance());
MapConfiguration.SetParameter(MapConfiguration.WorkerThreadNumber, 32);
_mapImage = MapLayer.GetAbstractGraphicsFactory().CreateImage(Width, Height);
_mapTileDownloadManager = new MapTileDownloadManager(this);
_rasterMap = new RasterMap(1024, 1024, MapType, _mapTileDownloadManager);
_rasterMap.SetScreenSize(Width, Height);
_mapTileDownloadManager.Start();  

Setup Map Type and Initial Position

  int MapType = Mapdigit.Gis.Raster.MapType.MicrosoftMap;
   GeoLatLng center = new GeoLatLng(-31.948275, 115.857562);
   _rasterMap.SetCenter(center, 15, MapType);
mainmenu.png

Find Address

//set up the geocoding listener
_rasterMap.SetGeocodingListener(this);
//geo coding listener
 public void Done(string query, MapPoint[] result)
{
    if (result != null)
    {
        _rasterMap.PanTo(result[0].Point);
    }
}
//find the address, geocoding
if (!string.IsNullOrEmpty(txtAddress.Text))
    {
        string name = txtAddress.Text;
        try
        {
            name = Html2Text.Encodeutf8(_encoding.GetBytes(name));
        }
        catch (Exception)
        {
        }
        _rasterMap.GetLocations(name);       
    }

Change Map Type

Guidebee Map API internally supports around 20 different map types, including your customized map type.

int mapType = MapType.MicrosoftMap;
    
    switch (comboBox1.SelectedIndex)
    {
        case 0:
            mapType = MapType.GoogleMap;
            break;
        case 1:
            mapType = MapType.GoogleChina;
            break;
        case 2:
            mapType = MapType.MicrosoftMap;
            break;
        case 3:
            mapType = MapType.MicrosoftChina;
            break;
        case 4:
            mapType = MapType.MicrosoftSatellite;
            break;
        case 5:
            mapType = MapType.MicrosoftHybrid;
            break;
    }
    _rasterMap.SetMapType(mapType);

The following displays Google map, but Google map is not officially supported by us :-).

mainscreen.png

Routing

//set up the routing listener
_rasterMap.SetRoutingListener(this);
//routing listener
 public void Done(string query, MapDirection result)
{
    if (result != null)
    {
        _rasterMap.SetMapDirection(result);
        _rasterMap.Resize(result.Bound);
    }
}
//routing API
if (txtAddress1.Text.Length != 0 && txtAddress2.Text.Length != 0)
    {
       
        string name1 = txtAddress1.Text;
        string name2 = txtAddress2.Text;
        try
        {
            name1 = Html2Text.Encodeutf8(_encoding.GetBytes(name1));
            name2 = Html2Text.Encodeutf8(_encoding.GetBytes(name2));
        }
        catch (Exception)
        {
        }
        _rasterMap.GetDirections("from: " + name1 + " to: " + name2);
    }
routing.png

For more detailed information about how to use the Map API, please refer to the document and sample project.

Points of Interest

The trial version has an expiry date and may have a watermark on the map. Please contact the author for a commercial licence.

History

  • 17th October, 2010: Initial post

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here