扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:朱先忠编译 来源:天极开发 2007年11月12日
关键字:
public static LatLong GetAddress(Address address, string DataSourceName, out FindResults Location, out ViewByHeightWidth[] Views) { try { FindServiceSoap locationService = new FindServiceSoap(); locationService.Credentials = new System.Net.NetworkCredential(_mapPointUserName, _mapPointPassword); locationService.PreAuthenticate = true; FindAddressSpecification locationData = new FindAddressSpecification(); locationData.DataSourceName = DataSourceName; locationData.InputAddress = address; Location = locationService.FindAddress(locationData); Views = new ViewByHeightWidth[1]; Views[0] = Location.Results[0].FoundLocation.BestMapView.ByHeightWidth; return Location.Results[0].FoundLocation.LatLong; } catch(Exception ex) { throw new Exception(ex.Message,ex); } } |
public static double GetMapForRoute(out Bitmap[] RouteMaps, out ViewByHeightWidth[] Views, LatLong[] LatitudeLongitude, string DataSourceName, Point MapDimension) { RouteServiceSoap routeService = new RouteServiceSoap(); routeService.Credentials = new System.Net.NetworkCredential(_mapPointUserName,_mapPointPassword); routeService.PreAuthenticate = true; UserInfoRouteHeader routeUserInfo = new UserInfoRouteHeader(); routeUserInfo.DefaultDistanceUnit = DistanceUnit.Kilometer; routeService.UserInfoRouteHeaderValue = routeUserInfo; MapOptions mapOptions = new MapOptions(); mapOptions.Format = new ImageFormat(); mapOptions.Format.Width = MapDimension.X; mapOptions.Format.Height = MapDimension.Y; Route route; route = routeService.CalculateSimpleRoute(LatitudeLongitude, DataSourceName, SegmentPreference.Quickest); int MapDirectionLength = route.Itinerary.Segments[0].Directions.Length + 1; Views = new ViewByHeightWidth[MapDirectionLength]; RouteMaps = new Bitmap[MapDirectionLength]; Pushpin[] pushpins = new Pushpin[MapDirectionLength]; for (int idx = 0; idx <= MapDirectionLength-1; idx++) { pushpins[idx] = new Pushpin(); pushpins[idx].IconDataSource = "MapPoint.Icons"; if(idx != MapDirectionLength-1) { Views[idx] = route.Itinerary.Segments[0].Directions[idx].View.ByHeightWidth; pushpins[idx].IconName = "0"; pushpins[idx].LatLong = route.Itinerary.Segments[0].Directions[idx].LatLong; } else { Views[idx] = route.Itinerary.Segments[1].Directions[0].View.ByHeightWidth; pushpins[idx].IconName = "1"; pushpins[idx].LatLong = route.Itinerary.Segments[1].Directions[0].LatLong; } pushpins[idx].ReturnsHotArea = true; } MapSpecification MapSpec = new MapSpecification(); MapSpec.DataSourceName = DataSourceName; MapSpec.Options = mapOptions; MapSpec.Views = Views; MapSpec.Pushpins = pushpins; MapSpec.Route = route; MapImage[] MapImages; RenderServiceSoap renderService = new RenderServiceSoap(); renderService.Credentials = new System.Net.NetworkCredential(_mapPointUserName,_mapPointPassword); renderService.PreAuthenticate = true; MapImages = renderService.GetMap(MapSpec); for (int idx = 0; idx < MapDirectionLength; idx++) { RouteMaps[idx] = new Bitmap(new System.IO.MemoryStream(MapImages[idx].MimeData.Bits)); } return route.Itinerary.Segments[0].Distance; } |
|
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者