MapPoint+SmartPhone+C#开发示例

http://tech.ddvip.com   2006年08月02日    社区交流

本文详细介绍MapPoint+SmartPhone+C#开发示例

  在获取位置的详细信息之后,这些数据会被进一步发送给GetMap方法。这个方法使用了"RenderServiceSoap"Web服务。这个服务也需要认证信息。MapPoint提供了"图钉",它是一种用于标识地图上的地址的可视化标记。你可以从默认的图标组中选择一个,并设置一个恰当的名称。此外,它还会建立一个MapSpecification对象,它会保持视图、图钉、图像格式等内容。我们调用RenderService的GetMap方法来检索适当的图像,它是作为流检索到的,并用位图显示出来。

  public static Bitmap GetMap(FindResults Location, ViewByHeightWidth[] Views,string DataSourceName,
Point MapDimensions)
{
 try
 {
  RenderServiceSoap renderService = new RenderServiceSoap();
  Pushpin[] pushpins = new Pushpin[1];
  MapSpecification mapSpec = new MapSpecification();
  renderService.Credentials = new System.Net.NetworkCredential(_mapPointUserName, _mapPointPassword);
  renderService.PreAuthenticate = true;
  pushpins[0] = new Pushpin();
  pushpins[0].IconDataSource = "MapPoint.Icons";
  pushpins[0].IconName = "0";
  pushpins[0].Label = Location.Results[0].FoundLocation.Entity.Name;
  pushpins[0].LatLong = Views[0].CenterPoint;
  pushpins[0].ReturnsHotArea = true;
  mapSpec.DataSourceName = DataSourceName;
  mapSpec.Views = Views;
  mapSpec.Pushpins = pushpins;
  mapSpec.Options = new MapOptions();
  mapSpec.Options.Format = new ImageFormat();
  mapSpec.Options.Format.Width = MapDimensions.X;
  mapSpec.Options.Format.Height = MapDimensions.Y;
  MapImage[] mapImages = renderService.GetMap(mapSpec);
  System.IO.Stream streamImage = new System.IO.MemoryStream(mapImages[0].MimeData.Bits);
  Bitmap bitmap = new Bitmap(streamImage);
  return bitmap;
 }
 catch(Exception ex)
 {
  throw new Exception(ex.Message,ex);
 }
}

来源:天极开发    作者:陶刚    责编:豆豆技术应用

正在加载评论...