某地図コンポーネントで複数のルートを連結するサンプル
なんのことやらわからないと思いますが、某地図コンポーネントで複数ルートを検索するサンプルです(謎)。備忘録以外のなにものでもありません。
using AxAMRTV20Lib; using System; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.axAMV201.MapServerURL = "**************"; this.axAMV201.MapDataLicenceKey = "**************"; this.axAMV201.MapServerUserID = "**************"; this.axAMV201.MapServerPassword = "**************"; this.axAMV201.MapServerUsed = true; if (!this.axAMV201.CheckMapDataVersion()) { this.axAMV201.CheckMapDataVersion(); } this.axAMV201.AMSBar = this.axAMSBar1.GetOcx(); this.axAMV201.HomeVisible = false; this.axAMV201.MapDataCacheUsed = true; this.axAMV201.MapScaleEx = 250; this.axAMV201.MapScroll = AMV20Lib.MAPAC.スムーススクロールピンクリック可; this.axAMV201.ScaleVisible = true; this.axAMV201.ScrollWidth = 10; this.axAMV201.RefreshDraw(); this.axAMV201.Visible = true; this.axAMV201.Redraw(); } private void button1_Click(object sender, EventArgs e) { decimal distance; try { this.Cursor = Cursors.WaitCursor; distance = this.SearchRoute(this.axAMRTV201, "E139.411369", "N35.451814", "E139.415024", "N35.440752"); distance += this.SearchRoute(this.axAMRTV202, "E139.415024", "N35.440752", "E139.414296", "N35.424013"); distance += this.SearchRoute(this.axAMRTV203, "E139.414296", "N35.424013", "E139.444731", "N35.420474"); distance += this.SearchRoute(this.axAMRTV204, "E139.444731", "N35.420474", "E139.474150", "N35.433429"); } finally { this.Cursor = Cursors.Default; } MessageBox.Show("距離:" + (distance / 1000).ToString()); } private int SearchRoute(AxAMRTV20 route, string fromX, string fromY, string toX, string toY) { this.axAMV201.RemoveRouteLayer(route); route.ClearRoute(); route.RouteServerURL = "**************"; route.RteServerUserID = "**************"; route.RteServerPassword = "**************"; route.RouteServerUsed = true; route.StartRoad = 2; route.GoalRoad = 2; route.UseTallWay = false; route.ProgressVisible = false; route.ComVisible = true; route.get_RoutePoint(0).X = fromX; route.get_RoutePoint(0).Y = fromY; route.get_RoutePoint(0).Enabled = true; route.get_RoutePoint(0).ComVisible = true; route.get_RoutePoint(11).X = toX; route.get_RoutePoint(11).Y = toY; route.get_RoutePoint(11).Enabled = true; route.get_RoutePoint(11).ComVisible = true; route.get_RoutePoint(101).X = toX; route.get_RoutePoint(101).Y = toY; route.get_RoutePoint(101).Enabled = true; route.get_RoutePoint(101).ComVisible = true; route.ShowRoutePoint(11, 1); route.CalcMethod = AMRTV20Lib.CALCM.時間優先; this.axAMV201.AddRouteLayer(route); int time = 0; int distance = 0; int section = 0; var result = route.CalcRoute(ref time, ref distance, ref section); if (result == 0) { return distance; } return 0; } } }