MapObjects2.ImageLayer.OpenCatalog method can build a picture layer, and then add to the Axmapobjects2.axmap map components, in order to achieve the use of bitmaps to display the map background, to achieve a more beautiful map and the full information effect.
When the scale is relatively large, if all tile maps of the current scale are loaded into the layer all at once, the speed becomes a headache problem
Here, we use a picture to load the current window size area to achieve speed optimization.
The code is as follows
<summary>///Add picture layer///</summary>///<param name= "tablename" ></param>///<param name= "L Ayername "></param> public void Addimagelayer (string tablename, String layername) {double left = _map. Extent.left; Double rigth = _map. Extent.right; Double top = _map. Extent.top; Double bottom = _map. Extent.bottom; Double width = 0; Double height = 0; Mapobjects2.point pt = _map. Tomappoint (map_center_x, map_center_y); Switch (level) {Case 1:width = pic_width * RES1; height = pic_height * res1, break, Case 2:width = pic_width * RES2; ight = Pic_height * RES2; Break Case 3:width = pic_width * RES3; Height = pic_height * RES3; Break Case 4:width = pic_width * RES4; Height = pic_height * RES4; Break Case 5:width = pic_width * RES5; Height = pic_height * RES5; Break string connstr = @ "Provider=Microsoft.Jet.OLEDB.4.0;Data source= + System.Windows.Forms.Application.StartupPath +"/ /map.mdb; Persist security Info=false "; ADODB. Connection conn = new ADodb. Connectionclass (); Conn. ConnectionString = ConnStr; Conn. Open (ConnStr, "", "", 0); Adodb.command comm = new Adodb.commandclass (); Comm. ActiveConnection = conn; String sql = ""; if (level!= 1 &&!isfromresource) {sql = ' select * from ' + tablename; sql = "where xmin>=" + (left-width); SQL + = "and xmax<=" + (rigth + width); SQL + + "and ymin>=" + (bottom-height); SQL + = "and ymax<=" + (top + height); else {sql = "select * from" + tablename;} Comm.commandtext = SQL; Mapobjects2.table t = new Mapobjects2.tableclass (); T.command = comm; Mapobjects2.imagelayer Imglyr = new Mapobjects2.imagelayerclass (); try {imglyr.opencatalog (T, @ "", MapObjects2.ImageCatalogConstants.moOpenImagesInDisplay);} catch (Exception ex) {} _ma P.layers.add (IMGLYR); }
In code, RES1-RES5 represents the longitude of a pixel display, i.e. the different representations of longitude at each scale, pic_width and pic_height represent the image width and height of the tile map. _map is the Axmapobjects2.axmap component.
It is worth noting that when the picture is first loaded, the _map. Extend because it has not been initialized based on the loaded picture, the first load is loaded with all the pictures, because when the number of small scale pictures, the speed has no effect.
If you have any questions or suggestions, please feel free to discuss