/// <summary> /// 添加单个标注 /// </summary> /// <param name="LogPnt"></param> public IMSMark AddMark(marketsInfo market) { if (this.markLayer1 == null) { MessageBox.Show("标注图层为空!"); return(null); } img = new Image(); img.Source = new BitmapImage(new Uri("../images/SiteIcon.png", UriKind.Relative)); img.Height = 48; img.Width = 38; tips = new EditMark(market.MarketName, market.MarketID.ToString(), market.Address, ""); //tips(market); IMSMark mark = new IMSMark(tips, CoordinateType.Logic, markLayer1); mark.EnableAnimation = false; mark.EnableRevisedPos = true; Point pnt = new Point(market.X, market.Y); mark.X = pnt.X; mark.Y = pnt.Y; mark.OffsetX = -19; mark.OffsetY = -48; markLayer1.AddMark(mark); return(mark); }
public void AddNode(string name, double x, double y, string iconSrc) { if (MarkLayer != null) { StackPanel panel = new StackPanel() { Orientation = Orientation.Horizontal }; panel.Children.Add(new Image() { Source = new BitmapImage(new Uri(iconSrc, UriKind.Relative)) }); panel.Children.Add(new TextBlock() { Text = name }); IMSMark mark = new IMSMark(panel, CoordinateType.Logic, MarkLayer) { EnableAnimation = false, EnableDrag = false }; mark.X = x; mark.Y = y; MarkLayer.AddMark(mark); m_stopList.Add(mark); } }
/** * 添加测量标记点 */ private void addMeasurePoint(GraphicsLayer gLayer, IGraphics graphics, List <Point> logPntArr) { if (IsDrawOver) { clearMeasurePnts(null, null, null); } IMSCircle pnt = new IMSCircle(CoordinateType.Logic); pnt.RadiusEx = 4; pnt.CenX = logPntArr[logPntArr.Count - 1].X; pnt.CenY = logPntArr[logPntArr.Count - 1].Y; m_graphicsLayer.AddGraphics(pnt); pnt.Draw(); this.measurePnts.Add(pnt); this.measurePntsTmp.Add(new Point(logPntArr[logPntArr.Count - 1].X, logPntArr[logPntArr.Count - 1].Y)); if (this.m_graphicsLayer.DrawingType == DrawingType.Polyline) { Label currmeasureLabel = new Label(); currmeasureLabel.Content = ""; currmeasureLabel.FontSize = 12; IMSMark currmeasureMark = new IMSMark(currmeasureLabel, CoordinateType.Logic); currmeasureMark.EnableDrag = false; currmeasureMark.EnableAnimation = false; mymarklayer.AddMark(currmeasureMark); measureMarks.Add(currmeasureMark); // (currmeasureMark.MarkControl as Label).Content = getLength(new Point(-1, -1)); ; string tollength = getCurrentLength(-1, -1, new Point(-1, -1)); measureleng += Convert.ToDouble(tollength.Split(':')[1]); currmeasureMark.X = logPntArr[logPntArr.Count - 1].X + 0.0055; currmeasureMark.Y = logPntArr[logPntArr.Count - 1].Y - 0.0055; Label centermeasureLabel = new Label(); centermeasureLabel.Content = ""; centermeasureLabel.FontSize = 12; IMSMark centermeasureMark = new IMSMark(centermeasureLabel, CoordinateType.Logic); centermeasureMark.EnableDrag = false; centermeasureMark.EnableAnimation = false; mymarklayer.AddMark(centermeasureMark); measureCenterMarks.Add(centermeasureMark); (centermeasureMark.MarkControl as Label).RenderTransform = new RotateTransform(); if ((bool)checkBox1.IsChecked) { if (centermeasureMark != null) { // centermeasureMark.Visibility = System.Windows.Visibility.Visible; } } else { if (centermeasureMark != null) { centermeasureMark.Visibility = System.Windows.Visibility.Collapsed; } } } this.m_mapContainer.MouseMove -= new MouseEventHandler(m_graphicsLayer_MouseMove); this.m_mapContainer.MouseMove += new MouseEventHandler(m_graphicsLayer_MouseMove); IsDrawOver = false; }
//添加标注到地图上 void iMSMap1_MapReady(IMSMapEvent e) { MarkLayer m_markLayer = new MarkLayer(); //初始化标注图层 iMSMap1.AddChild(m_markLayer); //添加到地图容器中 IMSMark mark; //定义标注对象 pnt = new Point(114.331901, 30.548992); m_markLayer.EnableZoomAnimation = true; //允许随地图缩放 m_markLayer.EnableMarkHiden = false; //不允许隐藏标注 m_markLayer.EnablePolymericMark = true; //允许标注聚合功能 mark = new IMSMark(new Image() //初始化标注对象 { Source = new BitmapImage(new Uri("/Images/markimg1.png", UriKind.Relative)), Width = 80, Height = 80 }, CoordinateType.Logic, m_markLayer); mark.X = pnt.X; //设置标注坐标 mark.Y = pnt.Y; m_markLayer.AddMark(mark); //添加到标注图层 mark.MouseClickCallback = new MouseOperDelegate(mark_click); // mark.MouseEnterCallback = new MouseOperDelegate(mark_enter); // mark.MouseLeaveCallback = new MouseOperDelegate(mark_leave); Canvas.SetZIndex(DFwin, Canvas.GetZIndex(this.iMSMap1) + 12); DFwin.Margin = new Thickness(iMSMap1.LogicToScreen(pnt.X, pnt.Y).X + 15, iMSMap1.LogicToScreen(pnt.X, pnt.Y).Y + 15, 0, 0); DFwin.Visibility = Visibility.Collapsed; DFwin.AllowDrop = false; iMSMap1.MapViewChange += new ZDIMS.Event.IMSMapEventHandler(iMSMap1_MapViewChange); }
public void Draw() { if (GraphicsLayer != null && RoadCoorArr.Length > 0) { if (m_road == null) { m_road = new IMSPolyline(CoordinateType.Logic); m_road.Shape.Stroke = new SolidColorBrush(Colors.Red); GraphicsLayer.AddGraphics(m_road); } for (int i = 0; i < RoadCoorArr.Length - 1; i += 2) { if (RoadCoorArr[i].Length > 0 && RoadCoorArr[i + 1].Length > 0) { m_road.Points.Add(new Point(Convert.ToDouble(RoadCoorArr[i]), Convert.ToDouble(RoadCoorArr[i + 1]))); } } m_road.Draw(); for (int i = 0; i < m_stopList.Count; i++) { MarkLayer.AddMark(m_stopList[i]); m_stopList[i].RevisedPosition(); } this.GraphicsLayer.MapContainer.PanTo(Convert.ToDouble(RoadCoorArr[0]), Convert.ToDouble(RoadCoorArr[1])); } }
private void addmyMark(string name, double x, double y) { //初始化标注图层,并将其作为子元素添加到地图容器 if (this.markLayer1 == null) { this.markLayer1 = new MarkLayer(); this.iMSMap1.AddChild(this.markLayer1); } //创建并实例化标注控件,对其属性进行设置 Image img = new Image(); BitmapImage b = new BitmapImage(new Uri("/images/walk.png", UriKind.RelativeOrAbsolute)); img.Source = b; img.Width = 25; img.Height = 30; IMSmyMark mark = new IMSmyMark(img); mark.CoordinateType = CoordinateType.Logic; mark.markName = name; mark.X = x; mark.Y = y; mark.EnableRevisedPos = true; mark.MarkClickCallback += new MarkClickDelegate(onClick); //标注点击事件回调 mark.MarkControl.MouseLeave += new MouseEventHandler(img_MouseLeave); //标注鼠标移出事件监听 markLayer1.AddMark(mark); //将标注添加到标注图层中 }
private void OnSubmit(object sender, UploadStringCompletedEventArgs e) { ClearRoad(); roadReslut.Blocks.Clear(); if (e.Error != null) { MessageBox.Show("分析失败,错误原因为:" + e.Error.Message, "提示", MessageBoxButton.OK); return; } try { if (e.Result.IndexOf("COperResult") > -1) { COperResult res = VectorObj.GetObject(e, typeof(COperResult)) as COperResult; MessageBox.Show(res.ErrorInfo, "提示", MessageBoxButton.OK); return; } CPathAnalyzeResult obj = _spatial.OnNetAnalyse(e); if (obj == null || obj.Paths == null) { return; } CNetPath path = obj.Paths[0]; int edgeNum = path.Edges.Length; Paragraph myParagraph = new Paragraph(); myParagraph.Inlines.Add(new Run() { Text = "1.从起点出发" }); Bold bold; IMSMark mark; StackPanel panel; for (int i = 0; i < edgeNum; i++) { CNetEdge edge = path.Edges[i]; if (i != 0) { myParagraph.Inlines.Add(new Run() { Text = (i + 1).ToString() + "." }); } myParagraph.Inlines.Add(new Run() { Text = "经" }); bold = new Bold() { Foreground = new SolidColorBrush(Colors.Red) }; bold.Inlines.Add(edge.FieldValus[2]); myParagraph.Inlines.Add(bold); if (i != edgeNum - 1) { myParagraph.Inlines.Add(new Run() { Text = "到达" }); bold = new Bold() { Foreground = new SolidColorBrush(Colors.Red) }; bold.Inlines.Add(path.Nodes[i + 1].FieldValus[0] + "\n"); myParagraph.Inlines.Add(bold); } else { myParagraph.Inlines.Add(new Run() { Text = "到达终点" }); } if (GraphicsLayer != null) { if (m_road == null) { m_road = new IMSPolyline(CoordinateType.Logic); m_road.Shape.Stroke = new SolidColorBrush(Colors.Red); GraphicsLayer.AddGraphics(m_road); } for (int j = 0; j < edge.Dots.Length; j++) { m_road.Points.Add(new Point(edge.Dots[j].x, edge.Dots[j].y)); } panel = new StackPanel() { Orientation = Orientation.Horizontal }; panel.Children.Add(new Image() { Source = new BitmapImage(new Uri("../images/bus/stop.png", UriKind.Relative)) }); panel.Children.Add(new TextBlock() { Text = edge.FieldValus[2] }); mark = new IMSMark(panel, CoordinateType.Logic, MarkLayer) { EnableAnimation = false, EnableDrag = false }; mark.X = edge.Dots[edge.Dots.Length / 2].x; mark.Y = edge.Dots[edge.Dots.Length / 2].y; MarkLayer.AddMark(mark); m_stopList.Add(mark); } } m_road.Draw(); roadReslut.Blocks.Add(myParagraph); radioButton1.IsChecked = false; radioButton2.IsChecked = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButton.OK); } }