public frmMain() { InitializeComponent(); MapLayer.SetAbstractGraphicsFactory(NETGraphicsFactory.getInstance()); localMapTileFileReader = new MapTileVectorDataSource(@"D:\nanjing\Nanjing.pst"); GeoSet getSet = localMapTileFileReader.GetGeoSet(); graphics = Graphics.FromImage(mapImage); drawFont = new Font("Arial", 16, FontStyle.Bold); drawBrush = new SolidBrush(Color.Red); pen = new Pen(Color.Red); greenColor = Color.FromArgb(120, Color.Blue); fillBrush = new SolidBrush(greenColor); getSet.GetMapMapFeatureLayer("POI.lyr").FontColor = 0x0000FF; getSet.GetMapMapFeatureLayer("POI.lyr").FontName = "楷体"; getSet.GetMapMapFeatureLayer("LandMark.lyr").FontColor = 0; getSet.GetMapMapFeatureLayer("LandMark.lyr").FontName = "Arial"; getSet.GetMapMapFeatureLayer("Adm_LandMark.lyr").FontColor = 0; getSet.GetMapMapFeatureLayer("Adm_LandMark.lyr").FontName = "Arial"; getSet.GetMapMapFeatureLayer("Road.lyr").FontColor = 16711680; getSet.GetMapMapFeatureLayer("Road.lyr").FontName = "楷体"; getSet.GetMapMapFeatureLayer("RailWay.lyr").FontColor = 0; getSet.GetMapMapFeatureLayer("RailWay.lyr").FontName = "Arial"; getSet.GetMapMapFeatureLayer("Landuse.lyr").FontColor = 0; getSet.GetMapMapFeatureLayer("Landuse.lyr").FontName = "Arial"; getSet.GetMapMapFeatureLayer("Block.lyr").FontColor = 0; getSet.GetMapMapFeatureLayer("Landuse.lyr").FontName = "Arial"; getSet.GetMapMapFeatureLayer("Adm_Area.lyr").FontColor = 16711680; getSet.GetMapMapFeatureLayer("Adm_Area.lyr").FontName = "宋体"; mapTileDownloadManager = new MapTileDownloadManager(this); mapFileIndex = new FileStream("world.ind", FileMode.Open); mapFileData = new FileStream("world.dat", FileMode.Open); MapIndexReader = new BinaryReader(mapFileIndex); MapDataReader = new BinaryReader(mapFileData); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { SelectedMapIndex[i, j] = false; } } SelectedMapIndex[0, 0] = true; DrawMapImages(); cboMapType.SelectedIndex = 12; managerThread = new Thread(new ThreadStart(mapTileDownloadManager.ProcessTaskList)); managerThread.Start(); }
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"; }