private void btnLoad_Click(object sender, EventArgs e) { var openFileDialog1 = new OpenFileDialog { InitialDirectory = "c:\\", Filter = "map files (*.map)|*.map|All files (*.*)|*.*", FilterIndex = 2, RestoreDirectory = true }; if (openFileDialog1.ShowDialog() == DialogResult.OK) { try { _mapTileDownloadManager.Stop(); GC.Collect(); string fileName = openFileDialog1.FileName; var localMapTileFileReader = new MapTileStoredDataSource(fileName); _mapTileDownloadManager = new MapTileDownloadManager(this, localMapTileFileReader); _mapTileDownloadManager.Start(); GeoLatLng center = _rasterMap.GetScreenCenter(); int zoom = _rasterMap.GetZoom(); _rasterMap = new RasterMap(768, 768, _mapType, _mapTileDownloadManager); _rasterMap.SetCenter(center, zoom); _rasterMap.SetMapDrawingListener(this); _rasterMap.SetGeocodingListener(this); } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); } } }
private void btnServer_Click(object sender, EventArgs e) { _mapTileDownloadManager.Stop(); _mapTileDownloadManager = new MapTileDownloadManager(this); _mapTileDownloadManager.Start(); GeoLatLng center = _rasterMap.GetScreenCenter(); int zoom = _rasterMap.GetZoom(); _rasterMap = new RasterMap(768, 768, _mapType, _mapTileDownloadManager); _rasterMap.SetCenter(center, zoom); _rasterMap.SetMapDrawingListener(this); _rasterMap.SetGeocodingListener(this); }
public MainWindow() { InitializeComponent(); MapLayer.SetAbstractGraphicsFactory(NETGraphicsFactory.getInstance()); _mapImage = MapLayer.GetAbstractGraphicsFactory().CreateImage(768, 768); _mapGraphics = _mapImage.GetGraphics(); InitVectorMap(); //_mapTileDownloadManager = new MapTileDownloadManager(this); _mapTileDownloadManager.Start(); _rasterMap = new RasterMap(768, 768, _mapType, _mapTileDownloadManager); _rasterMap.SetMapDrawingListener(this); _rasterMap.SetGeocodingListener(this); _rasterMap.SetRoutingListener(this); // Get the configuration file. System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); // Get the AppSetins section. AppSettingsSection appSettingSection = (AppSettingsSection)config.GetSection("appSettings"); MapType.MAP_TYPE_URLS.Clear(); foreach (var obj in appSettingSection.Settings.AllKeys) { var value = appSettingSection.Settings[obj]; object type = MapType.MAP_TYPE_NAMES[obj]; if (type != null) { string url = value.Value.Replace('#', '&'); MapType.MAP_TYPE_URLS.Add(type, url); cboMapType.Items.Add(obj); } } cboMapType.Text = "MICROSOFTMAP"; }