/// <summary> /// 当地图类型选择改变时,出发,切换相应的地图 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmbMapTypes_SelectedIndexChanged(object sender, EventArgs e) { Coord coord = this.mapControl.GetCenter(); Coord result = coord; int oldZoom = 0; MapType oldMapType = MapType.Google; if (coord != null) { result = coord; oldZoom = this.mapControl.GetZoom(); oldMapType = this.mapType; } var selectItem = (ComboxItem)this.cmbMapType.SelectedItem; this.mapControl.setMap(selectItem.Tag.ToString()); this.mapType = (MapType)selectItem.Value; if (coord == null) { return; } switch (oldMapType) { case MapType.Baidu: case MapType.BaiduImageTile: result = CoordHelper.WebMercator2lonLat(coord); result = CoordHelper.BdDecrypt(result.lat, result.lon); result = CoordHelper.Gcj2Wgs(result.lon, result.lat); break; case MapType.Google: case MapType.GoogleImage: result = CoordHelper.WebMercator2lonLat(coord); result = CoordHelper.Gcj2Wgs(result.lon, result.lat); break; case MapType.Gaode: case MapType.GaodeImage: case MapType.QQMap: case MapType.QQImage: result = CoordHelper.WebMercator2lonLat(coord); result = CoordHelper.Gcj2Wgs(result.lon, result.lat); break; case MapType.OpenStreetMap: result = CoordHelper.WebMercator2lonLat(coord); break; case MapType.Tiandi: case MapType.TiandiImage: result = coord; break; } switch (this.mapType) { case MapType.Baidu: case MapType.BaiduImageTile: result = CoordHelper.Transform(result.lon, result.lat); result = CoordHelper.BdEncrypt(result.lat, result.lon); result = CoordHelper.WebMoctorJw2Pm(result.lon, result.lat); break; case MapType.Google: case MapType.GoogleImage: result = CoordHelper.Transform(result.lon, result.lat); result = CoordHelper.WebMoctorJw2Pm(result.lon, result.lat); break; case MapType.Gaode: case MapType.GaodeImage: case MapType.QQImage: case MapType.QQMap: result = CoordHelper.Transform(result.lon, result.lat); result = CoordHelper.WebMoctorJw2Pm(result.lon, result.lat); break; case MapType.OpenStreetMap: result = CoordHelper.WebMoctorJw2Pm(result.lon, result.lat); break; case MapType.Tiandi: case MapType.TiandiImage: break; } this.mapControl.SetZoom(oldZoom); this.mapControl.SetCenter(result); tsbClearBounds_Click(null, null); }