static MapDirectionRenderer() { try { IImage iconImage = MapLayer.GetAbstractGraphicsFactory(). CreateImage(new MemoryStream(ROUTE_IMAGE_ARRAY)); if (iconImage != null) { for (int i = 0; i < ROUTE_ICONS.Length; i++) { int x = i * 9 - 1; if (x < 0) { x = 0; } ROUTE_ICONS[i] = iconImage.SubImage(x, 0, 9, 9, true); } } } catch (Exception) { } }
private static IFont GetFont(string fontName) { Font font = new Font(fontName, 13); IFont newFont = MapLayer.GetAbstractGraphicsFactory().CreateFont(font); return(newFont); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Constrcutor. */ public MapDirectionRenderer() { if (MapConfiguration.RoutePen != null) { RoutePen = MapConfiguration.RoutePen; } else { RoutePen = new Pen(new Color(0x7F00FF00, false), 4); } if (MapConfiguration.StartIcon != null) { StartIcon = MapConfiguration.StartIcon; } else { StartIcon = ROUTE_ICONS[0]; } if (MapConfiguration.EndIcon != null) { EndIcon = MapConfiguration.EndIcon; } else { EndIcon = ROUTE_ICONS[0]; } if (MapConfiguration.MiddleIcon != null) { MiddleIcon = MapConfiguration.MiddleIcon; } else { MiddleIcon = ROUTE_ICONS[1]; } _mapDirectionLayer = new MapDirectionLayer(MapLayer.MAP_TILE_WIDTH, MapLayer.MAP_TILE_WIDTH); _mapTileImage = MapLayer.GetAbstractGraphicsFactory() .CreateImage(MapLayer.MAP_TILE_WIDTH, MapLayer.MAP_TILE_WIDTH); _mapTileGraphics = _mapTileImage.GetGraphics(); }
//public MapTileVectorDataSource(string url) //{ // Uri = url; // _geoStream = new FileStream(url, FileMode.Open); // byte[] bufferGeo = new byte[_geoStream.Length]; // _geoStream.Read(bufferGeo, 0, bufferGeo.Length); // _geoStream.Close(); // MemoryStream baisGeo = new MemoryStream(bufferGeo); // _getSet = new GeoSet(new BinaryReader(baisGeo)); // string filePath = Path.GetDirectoryName(url); // string[] layerNames = _getSet.GetLayerNames(); // _layerStreams = new FileStream[layerNames.Length]; // for (int i = 0; i < layerNames.Length; i++) // { // string layerName = filePath + "\\" + layerNames[i]; // _layerStreams[i] = new FileStream(layerName, FileMode.Open); // MapFeatureLayer layer = new MapFeatureLayer(new BinaryReader(_layerStreams[i])); // layer.FontColor = 0x000000; // GeoSet.MapFeatureLayerInfo layerInfo = _getSet.GetMapMapFeatureLayerInfo(layerNames[i]); // if (layerInfo != null) // { // layer.ZoomLevel = layerInfo.ZoomLevel; // layer.ZoomMin = layerInfo.ZoomMin; // layer.ZoomMax = layerInfo.ZoomMax; // layer.Description = layerInfo.Description; // layer.Visible = layerInfo.Visible; // layer.LayerName = layerInfo.LayerName; // } // _getSet.AddMapFeatureLayer(layer); // } // _vectorMapRenderer = new VectorMapRenderer(_getSet); // Font font = new Font(FontFamily.GenericSansSerif, 13, FontStyle.Regular); // IFont newFont = MapLayer.GetAbstractGraphicsFactory().CreateFont(font); // _vectorMapRenderer.SetFont(newFont); // _getSet.Open(); //} public MapTileVectorDataSource(string url) { Uri = url; _geoStream = new FileStream(url, FileMode.Open); byte[] bufferGeo = new byte[_geoStream.Length]; _geoStream.Read(bufferGeo, 0, bufferGeo.Length); _geoStream.Close(); MemoryStream baisGeo = new MemoryStream(bufferGeo); _getSet = new GeoSet(); string filePath = @"C:\shenjing\map"; string[] layerNames = new string[] { "3.lyr", "1.lyr", "2.lyr" }; _layerStreams = new FileStream[layerNames.Length]; for (int i = 0; i < layerNames.Length; i++) { string layerName = filePath + "\\" + layerNames[i]; _layerStreams[i] = new FileStream(layerName, FileMode.Open); MapFeatureLayer layer = new MapFeatureLayer(new BinaryReader(_layerStreams[i])); layer.FontColor = 0x000000; GeoSet.MapFeatureLayerInfo layerInfo = _getSet.GetMapMapFeatureLayerInfo(layerNames[i]); if (layerInfo != null) { layer.ZoomLevel = layerInfo.ZoomLevel; layer.ZoomMin = layerInfo.ZoomMin; layer.ZoomMax = layerInfo.ZoomMax; layer.Description = layerInfo.Description; layer.Visible = layerInfo.Visible; layer.LayerName = layerInfo.LayerName; } _getSet.AddMapFeatureLayer(layer); } _vectorMapRenderer = new VectorMapRenderer(_getSet); Font font = new Font(FontFamily.GenericSansSerif, 13, FontStyle.Regular); IFont newFont = MapLayer.GetAbstractGraphicsFactory().CreateFont(font); _vectorMapRenderer.SetFont(newFont); _getSet.Open(); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 21JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Construtor. */ public VectorMapCanvas() { GetGraphics2DInstance(); _textImage = MapLayer.GetAbstractGraphicsFactory() .CreateImage(MapLayer.MAP_TILE_WIDTH, IMAGE_PATERN_WIDTH); _textGraphics = _textImage.GetGraphics(); _textGraphics.SetColor(0xC0C0FF); _textGraphics.FillRect(0, 0, _textImage.GetWidth(), _textImage.GetHeight()); _fontTranspency = _textImage.GetRGB()[0]; _imagePattern = MapLayer.GetAbstractGraphicsFactory() .CreateImage(IMAGE_PATERN_WIDTH, IMAGE_PATERN_WIDTH); _imagePatternGraphics = _imagePattern.GetGraphics(); _mapSize.X = 0; _mapSize.Y = 0; _mapSize.MaxX = MapLayer.MAP_TILE_WIDTH; _mapSize.MaxY = MapLayer.MAP_TILE_WIDTH; _mapSize.Width = MapLayer.MAP_TILE_WIDTH; _mapSize.Height = MapLayer.MAP_TILE_WIDTH; }
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"; }