/// <summary> /// 设置地图的显示范围 /// </summary> /// <param name="bounds">需要显示的范围</param> private void viewBounds(soRect bounds) { double width = bounds.Width(); double heigth = bounds.Width(); bounds.Left -= width / 2; bounds.Right += width / 2; bounds.Bottom -= heigth / 2; bounds.Top += heigth / 2; this.axSuperMap1.ViewBounds = bounds; this.axSuperMap1.Refresh(); }
/// <summary> /// 设置地图的显示范围 /// </summary> /// <param name="objRd">需要显示的记录集</param> private void viewRecordset(soRecordset objRd) { double left = Double.MaxValue; double right = Double.MinValue; double bottom = Double.MaxValue; double top = Double.MinValue; objRd.MoveFirst(); while (!objRd.IsEOF()) { soRect bounds = objRd.GetGeometry().Bounds; if (left>bounds.Left) { left = bounds.Left; } if (right < bounds.Right) { right = bounds.Right; } if (bottom > bounds.Bottom) { bottom = bounds.Bottom; } if (top < bounds.Top) { top = bounds.Top; } objRd.MoveNext(); } soRect rect = new soRect(); rect.Left = left; rect.Right = right; rect.Bottom = bottom; rect.Top = top; viewBounds(rect); }
/// <summary> /// 查询poi /// </summary> private void searchpoi() { String key = this.textBoxItemSearchKey.TextBox.Text.Trim(); if (key.Length == 0 || key == tipPOIKey) { MessageBox.Show("请输入搜索关键字!", msgCaption); return; } this.listBoxPoiResult.Items.Clear(); this.axSuperMap1.TrackingLayer.ClearEvents(); if (!poiSearch.IsOpen) { MessageBox.Show("找不到POI索引!", msgCaption); return; } // poi查询 PoiResult poiResult = poiSearch.search(key); if (poiResult == null || poiResult.Count == 0) { MessageBox.Show("找不到数据!", msgCaption); return; } soStyle style = new soStyle(); style.PenColor = Util.ColorToUInt32(Color.Blue); style.SymbolSize = 30; soRect rect = new soRect(); //获取查询结果 for (int i = 0; i < Math.Min(poiResult.Count,200); i++) { PoiInfo poiInfo = poiResult.getPoiInfoAt(i); //坐标转换(wgs84 -> 地图坐标) coordSysTranslator.convert(ref poiInfo); // 加了结果列表 this.listBoxPoiResult.Items.Add(poiInfo); // 加入跟踪层高亮显示 soGeoPoint geoPoint = new soGeoPoint(); geoPoint.x = poiInfo.x; geoPoint.y = poiInfo.y; this.axSuperMap1.TrackingLayer.AddEvent((soGeometry)geoPoint, style, poiInfo.name); //计算范围 if (i==0) { //第一个 rect.Left = poiInfo.x; rect.Right = poiInfo.x; rect.Bottom = poiInfo.y; rect.Top = poiInfo.y; } else { //向外扩张 if (rect.Left > poiInfo.x) { rect.Left = poiInfo.x; } if (rect.Right < poiInfo.x) { rect.Right = poiInfo.x; } if (rect.Bottom > poiInfo.y) { rect.Bottom = poiInfo.y; } if (rect.Top < poiInfo.y) { rect.Top = poiInfo.y; } } } //viewAllPoi(this.listBoxPoiResult.Items); showRigthPanel(true, 1); if (poiResult.Count == 1) { axSuperMap1.CenterX = rect.CenterPoint().x; axSuperMap1.CenterY = rect.CenterPoint().y; } else { viewBounds(rect); } axSuperMap1.Refresh(); }