{"id":42,"date":"2009-04-20T13:21:00","date_gmt":"2009-04-20T13:21:00","guid":{"rendered":"http:\/\/blog.newnaw.com\/?p=42"},"modified":"2009-04-20T13:21:00","modified_gmt":"2009-04-20T13:21:00","slug":"arcgis-api-for-silverlight%e5%bc%80%e5%8f%91%e5%85%a5%e9%97%a8%ef%bc%884%ef%bc%89%ef%bc%9a%e7%94%a8%e6%88%b7%e4%b8%8e%e5%9c%b0%e7%90%86%e4%bf%a1%e6%81%af%e4%b9%8b%e9%97%b4%e7%9a%84%e6%a1%a5%e6%a2%81","status":"publish","type":"post","link":"https:\/\/blog.newnaw.com\/?p=42","title":{"rendered":"ArcGIS API for Silverlight\u5f00\u53d1\u5165\u95e8\uff084\uff09\uff1a\u7528\u6237\u4e0e\u5730\u7406\u4fe1\u606f\u4e4b\u95f4\u7684\u6865\u6881&#8211;GraphicsLayer"},"content":{"rendered":"<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u6211\u4eec\u4e0e\u5730\u56fe\u4ea4\u4e92\u7684\u8fc7\u7a0b\u65f6\u523b\u5728\u8fdb\u884c\u7740\uff1a\u4e00\u4e2a\u62c9\u6846\u653e\u5927\u64cd\u4f5c\uff0c\u6216\u8005\u5bf9\u5730\u56fe\u5185\u5bb9\u7684\u67e5\u8be2\u7b49\u3002\u8fd9\u4e9b\u4ea4\u4e92\u8fc7\u7a0b\u4e2d\u7684\u8f93\u5165\u8f93\u51fa\uff0c\u901a\u5e38\u90fd\u662f\u53cd\u6620\u5728\u72ec\u7acb\u4e8e\u5730\u56fe\u6570\u636e\u4e00\u4e2a\u201c\u5c42\u201d\u4e0a\u3002\u6bd4\u5982\u62c9\u6846\u653e\u5927\uff0c\u6211\u4eec\u80fd\u770b\u89c1\u9f20\u6807\u6240\u753b\u7684\u4e00\u4e2a\u77e9\u5f62\uff1b\u53c8\u6bd4\u5982\u5bf9\u5174\u8da3\u70b9\u7684\u67e5\u8be2\uff0c\u7ed3\u679c\u901a\u5e38\u662f\u5c06\u7b26\u5408\u6761\u4ef6\u7684\u5174\u8da3\u70b9\u7684\u5f62\u72b6\u9ad8\u4eae\u663e\u793a\u5728\u90a3\u4e2a\u72ec\u7acb\u7684\u201c\u5c42\u201d\u4e2d\uff0c\u901a\u8fc7\u5b83\u65e2\u53ef\u4ee5\u53cd\u6620\u7528\u6237\u7684\u8f93\u5165\uff0c\u53c8\u53ef\u4ee5\u5c55\u73b0\u5730\u56fe\u7684\u8f93\u51fa\u3002\u8fd9\u4e2a\u201c\u5c42\u201d\u5c31\u662fGraphicsLayer\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u5176\u5b9eADF\u5f00\u53d1\u4e2d\u4e5f\u6709GraphicsLayer\u7684\u6982\u5ff5\uff0c\u540c\u6837\u5728\u5176\u4ed6\u4e24\u4e2a\u5ba2\u6237\u7aefAPI\uff08JavaScript\/Flex\uff09\u4e2d\u4e5f\u80fd\u627e\u5230GraphicsLayer\u7684\u8eab\u5f71\uff0c\u5b83\u4eec\u90fd\u662f\u4e00\u6837\u4e00\u6837\u7684\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u672c\u8282\u6211\u4eec\u4e3b\u8981\u770b\u5982\u4f55\u5728GraphicsLayer\u4e2d\u5c55\u73b0\u5185\u5bb9\u3002\u5f53\u7136\u7b2c\u4e00\u4e2a\u5de5\u4f5c\u5c31\u662f\u6dfb\u52a0ESRI.ArcGIS.dll\u7684\u5f15\u7528\uff0c\u5f15\u5165esri\u7684xml\u547d\u540d\u7a7a\u95f4\uff1b\u63a5\u4e0b\u6765\u5728Map\u4e2d\u6dfb\u52a0\u4e00\u4e2aGraphicsLayer\u56fe\u5c42\uff1a<br \/><code><esri:map x:name=\"Map1\"><br \/> <esri:map.layers><br \/> <!-- \u5176\u4ed6\u56fe\u5c42 --><br \/> <esri:graphicslayer id=\"GLayer\"><br \/> <\/esri:graphicslayer><\/esri:map.layers><br \/> <\/esri:map><\/code><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8981\u4f7fGraphicsLayer\u4e2d\u7684\u5185\u5bb9\u5904\u4e8e\u6700\u9876\u7aef\uff08\u4e0d\u88ab\u5176\u4ed6\u56fe\u5c42\u5185\u5bb9\u8986\u76d6\uff09\uff0c\u5c31\u8981\u5c06\u5b83\u653e\u5728Map\u6807\u7b7e\u91cc\u7684\u6700\u4e0b\u5934\uff0c\u50cf\u4e0a\u9762\u90a3\u6837\u3002\u4ece\u547d\u540d\u6211\u4eec\u4e0d\u96be\u770b\u51fa\uff0cGraphicLayer\u91cc\u9762\u653e\u7684\u5c31\u662fGraphic\u7684\u96c6\u5408\u4e86\u3002Graphic\uff08ESRI.ArcGIS.Graphic\uff09\u662fGraphicsLayer\u4e2d\u7684\u57fa\u672c\u5143\u7d20\uff0c\u5b83\u5305\u62ec\u4e86Geometry(\u5728ESRI.ArcGIS.Geometry\u547d\u540d\u7a7a\u95f4\u4e2d)\uff0cSymbol\uff08\u5728ESRI.ArcGIS.Symbol\u547d\u540d\u7a7a\u95f4\u4e2d\uff09\uff0cAttributes\u7b49\u5c5e\u6027\u3002\u6240\u6709\u663e\u793a\u5728\u5730\u56fe\u4e2d\u7684\u77e2\u91cf\u5143\u7d20\u90fd\u6709\u4e00\u4e2aGeometry\uff0c\u91cc\u9762\u5305\u542b\u4e86\u82e5\u5e72\u5730\u7406\u5750\u6807\uff0c\u7528\u4e8e\u663e\u793a\u5730\u56fe\u4e0a\u5730\u7269\u7684\u5f62\u72b6\uff0c\u5b83\u662fPoint\uff0cPolyline\uff0cPolygon\u7b49\u7684\u603b\u79f0\uff0c\u5728\u8fd9\u91cc\u4ee3\u8868\u4e86Graphic\u7684\u5f62\u72b6\u3002Symbol\u4ee3\u8868\u4e86Graphic\u7684\u5916\u89c2\uff0c\u5b83\u662f\u4e00\u7cfb\u5217\u7b26\u53f7\u7684\u603b\u79f0\uff0c\u6211\u4eec\u901a\u5e38\u8ddfSimpleMarkerSymbol\uff0cSimpleLineSymbol\u548cSimpleFillSymbol\u7b49\u6253\u4ea4\u9053\uff0c\u5b83\u4eec\u5206\u522b\u5bf9\u5e94\u4e86\u4e0a\u97623\u79cd\u4e0d\u540c\u7684Geometry\uff08Point\uff0cPolyline\uff0cPolygon\uff09\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8981\u8ba9\u4e00\u4e2aGraphic\u663e\u793a\u51fa\u6765\uff0c\u603b\u5171\u52063\u6b65\uff1a<br \/>1\u3001\u5b9a\u4e49Graphic\uff1a<br \/>\u5728xaml\u4e2d<br \/><code><esri:graphic><br \/><\/esri:graphic><\/code><br \/>\u5728code-behind\u4e2d<br \/><code>Graphic g= new Graphic()<\/code><br \/>2\u3001\u8bbe\u7f6eGraphic\u7684Geometry\u548cSymbol\u5c5e\u6027\uff1a<br \/>\u5728xaml\u4e2d<br \/><code><esri:graphic><br \/> <esri:graphic.symbol><br \/> <esrisymbols:simplemarkersymbol color=\"Blue\" size=\"12\" style=\"Square\"><br \/> <\/esrisymbols:simplemarkersymbol><\/esri:graphic.symbol><br \/> <esrigeometry:mappoint x=\"108\" y=\"30\"><br \/><\/esrigeometry:mappoint><\/esri:graphic><\/code><br \/>\u5728code-behind\u4e2d<br \/><code>Graphic g = new Graphic()<br \/>            {<br \/>                Geometry = new MapPoint(108, 30),<br \/>                Symbol = new SimpleMarkerSymbol()<br \/>                {<br \/>                    Color = new SolidColorBrush(Colors.Blue),<br \/>                    Size = 12,<br \/>                    Style = SimpleMarkerSymbol.SimpleMarkerStyle.Square<br \/>                }<br \/>            };<\/code><br \/>3\u3001\u628a\u5b9a\u4e49\u597d\u7684Graphic\u6dfb\u52a0\u5230GraphicsLayer\u91cc\uff1a<br \/>\u5728xaml\u4e2d<br \/><code><esri:graphicslayer id=\"GLayer\"><br \/> <esri:graphicslayer.graphics><br \/> <esri:graphic><br \/> <esri:graphic.symbol><br \/> <esrisymbols:simplemarkersymbol color=\"Blue\" size=\"12\" style=\"Square\"><br \/> <\/esrisymbols:simplemarkersymbol><\/esri:graphic.symbol><br \/> <esrigeometry:mappoint x=\"108\" y=\"30\"><br \/> <\/esrigeometry:mappoint><\/esri:graphic><br \/> <\/esri:graphicslayer.graphics><br \/><\/esri:graphicslayer><\/code><br \/>\u5728code-behind\u4e2d<br \/><code>Graphic g = new Graphic()<br \/>            {<br \/>                Geometry = new MapPoint(108, 30),<br \/>                Symbol = new SimpleMarkerSymbol()<br \/>                {<br \/>                    Color = new SolidColorBrush(Colors.Blue),<br \/>                    Size = 12,<br \/>                    Style = SimpleMarkerSymbol.SimpleMarkerStyle.Square<br \/>                }<br \/>            };<br \/>GraphicsLayer glayer = Map1.Layers[\"GLayer\"] as GraphicsLayer;<br \/>glayer.Graphics.Add(g);<\/code><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u770b\u4e00\u4e0b\u6548\u679c\uff1a<br \/><a onblur=\"try {parent.deselectBloggerImageGracefully();} catch(e) {}\" href=\"http:\/\/1.bp.blogspot.com\/_DD8LUY9p6iU\/Sew0jP5-vkI\/AAAAAAAAAG8\/jxXYS_2XfQk\/s1600-h\/04_graphic.png\" target=\"_blank\"><img decoding=\"async\" style=\"display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 298px;\" src=\"http:\/\/1.bp.blogspot.com\/_DD8LUY9p6iU\/Sew0jP5-vkI\/AAAAAAAAAG8\/jxXYS_2XfQk\/s400\/04_graphic.png\" border=\"0\" alt=\"\" id=\"BLOGGER_PHOTO_ID_5326690239442239042\" \/><\/a><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u56fe\u4e2d\u8fd8\u6709\u5176\u4ed6\u7684\u56fe\u5f62\uff0c\u65e0\u975e\u662f\u6539\u53d8\u4e86Graphic\u7684Geometry\u548cSymbol\u5c5e\u6027\u3002\u56fe\u4e0a\u7684\u90a3\u53ea\u7070\u718a\u662f\u4e00\u6bb5\u52a8\u753b\u6587\u4ef6\uff0c\u5229\u7528Silverlight\u7684\u7279\u6027\uff0c\u80fd\u591f\u5b9a\u4e49\u51fa\u8868\u73b0\u529b\u4e30\u5bcc\u7684\u5404\u79cd\u7b26\u53f7\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u5c3d\u7ba1\u80fd\u591f\u5b8c\u5168\u5728xaml\u4e2d\u6765\u5b8c\u6210\u5de5\u4f5c\uff0c\u4f46\u8fd8\u662f\u5efa\u8bae\u5c06\u53ef\u89c6\u5316\u5143\u7d20\u7684\u5b9a\u4e49\u653e\u5728xaml\u4e2d\uff0c\u5c06\u5b9e\u73b0\u7684\u903b\u8f91\u90e8\u5206\u653e\u5728code-behind\u4e2d\u3002\u770b\u4e00\u4e0b\u6dfb\u52a0\u56fe\u4e2d\u90a3\u4e9bGraphic\u7684\u4ee3\u7801\uff1a<br \/><code><grid.resources><br \/> <esrisymbols:simplemarkersymbol x:name=\"RedMarkerSymbol\" color=\"Red\" size=\"12\" style=\"Circle\"><br \/> <!-- \u53ef\u60dc\u76ee\u524dSilverlight\u53ea\u652f\u6301Jpeg\u548cPNG\u683c\u5f0f\u7684\u56fe\u50cf\uff0c\u6240\u4ee5PictureMarkerSymbol\u65e0\u6cd5\u663e\u793aGIF\u683c\u5f0f\u7684\u56fe\u50cf\uff0c\u5426\u5219\u4f1a\u62a5ImagingError\u7684\u9519\u8bef --><br \/> <esrisymbols:picturemarkersymbol x:name=\"PinPictureMarkerSymbol\" source=\"imgs\/pin.png\" offsetx=\"10\" offsety=\"10\"><br \/> <esrisymbols:simplelinesymbol x:name=\"RedLineSymbol\" color=\"Red\" width=\"4\" style=\"Solid\"><br \/> <esrisymbols:cartographiclinesymbol x:name=\"CartoLineSymbol\" color=\"Red\" width=\"10\" dashcap=\"Triangle\" linejoin=\"Round\" dasharray=\"6,2\"><br \/> <esrisymbols:simplefillsymbol x:name=\"RedFillSymbol\" fill=\"#66FF0000\" borderbrush=\"Red\" borderthickness=\"2\"><br \/><\/esrisymbols:simplefillsymbol><\/esrisymbols:cartographiclinesymbol><\/esrisymbols:simplelinesymbol><\/esrisymbols:picturemarkersymbol><\/esrisymbols:simplemarkersymbol><\/grid.resources><\/p>\n<p><mediaelement x:name=\"BearVideo\"><\/mediaelement><\/code><br \/><code>private void AddGraphics()<br \/>        {<br \/>            GraphicsLayer glayer = Map1.Layers[\"GLayer\"] as GraphicsLayer;<br \/>            Graphic[] graphics = new Graphic[8];<br \/>            graphics[0] = new Graphic()<br \/>            {<br \/>                Geometry = new MapPoint(108, 34),<br \/>                Symbol = RedMarkerSymbol<br \/>            };<\/p>\n<p>            graphics[1] = new Graphic()<br \/>            {<br \/>                Geometry = new MapPoint(108, 30),<br \/>                Symbol = new SimpleMarkerSymbol()<br \/>                {<br \/>                    Color = new SolidColorBrush(Colors.Blue),<br \/>                    Size = 12,<br \/>                    Style = SimpleMarkerSymbol.SimpleMarkerStyle.Square<br \/>                }<br \/>            };<\/p>\n<p>            graphics[2] = new Graphic()<br \/>            {<br \/>                Geometry = new MapPoint(108, 25),<br \/>                Symbol = PinPictureMarkerSymbol<br \/>            };<\/p>\n<p>            graphics[3] = new Graphic()<br \/>            {<br \/>                Geometry = new MapPoint(108, 20),<br \/>                Symbol = new TextSymbol()<br \/>                {<br \/>                    FontFamily = new FontFamily(\"\u5fae\u8f6f\u96c5\u9ed1, \u5b8b\u4f53\"),<br \/>                    FontSize = 14,<br \/>                    Foreground = new SolidColorBrush(Colors.Black),<br \/>                    Text = \"\u8fd9\u662ftext symbol\"<br \/>                }<br \/>            };<\/p>\n<p>            graphics[4] = new Graphic();<br \/>            graphics[4].Symbol = RedLineSymbol;<br \/>            ESRI.ArcGIS.Geometry.PointCollection pc = new ESRI.ArcGIS.Geometry.PointCollection()<br \/>            {<br \/>                new MapPoint(95,10),<br \/>\n                new MapPoint(110,-15),<br \/>                new MapPoint(130,10)<br \/>            };<br \/>            ESRI.ArcGIS.Geometry.Polyline pl = new ESRI.ArcGIS.Geometry.Polyline();<br \/>            pl.Paths.Add(pc);<br \/>            graphics[4].Geometry = pl;<\/p>\n<p>            graphics[5] = new Graphic();<br \/>            graphics[5].Symbol = CartoLineSymbol;<br \/>            ESRI.ArcGIS.Geometry.PointCollection pc1 = new ESRI.ArcGIS.Geometry.PointCollection()<br \/>            {<br \/>                new MapPoint(95,0),<br \/>                new MapPoint(110,-25),<br \/>                new MapPoint(130,0)<br \/>            };<br \/>            ESRI.ArcGIS.Geometry.Polyline pl1 = new ESRI.ArcGIS.Geometry.Polyline();<br \/>            pl1.Paths.Add(pc1);<br \/>            graphics[5].Geometry = pl1;<\/p>\n<p>            graphics[6] = new Graphic()<br \/>            {<br \/>                Symbol = RedFillSymbol<br \/>            };<br \/>            ESRI.ArcGIS.Geometry.PointCollection pc2 = new ESRI.ArcGIS.Geometry.PointCollection()<br \/>            {<br \/>                new MapPoint(110,-30),<br \/>                new MapPoint(130,-30),<br \/>                new MapPoint(130,-45),<br \/>                new MapPoint(120,-55),<br \/>                new MapPoint(110,-45),<br \/>                new MapPoint(110,-30)<br \/>            };<br \/>            ESRI.ArcGIS.Geometry.Polygon pg = new ESRI.ArcGIS.Geometry.Polygon();<br \/>            pg.Rings.Add(pc2);<br \/>            graphics[6].Geometry=pg;<\/p>\n<p>            graphics[7] = new Graphic();<br \/>            \/\/MediaElement\u7684Name\u5c5e\u6027\u53ea\u80fd\u5728xaml\u4e2d\u5b9a\u4e49\uff08\u89c1\u5e2e\u52a9\uff09\uff0c\u6240\u4ee5\u51b3\u5b9a\u4e86MediaElement\u4e0d\u80fd\u5b8c\u5168\u5728cs\u4ee3\u7801\u4e2d\u5b9a\u4e49<br \/>            BearVideo.Source = new Uri(\"http:\/\/serverapps.esri.com\/media\/bear.wmv\", UriKind.RelativeOrAbsolute);<br \/>            BearVideo.IsHitTestVisible=false;<br \/>            BearVideo.IsMuted=true;<br \/>            BearVideo.AutoPlay=true;<br \/>            BearVideo.Opacity=0;<br \/>            ESRI.ArcGIS.Geometry.Polygon pg2 = new ESRI.ArcGIS.Geometry.Polygon();<br \/>            ESRI.ArcGIS.Geometry.PointCollection pc3 = new ESRI.ArcGIS.Geometry.PointCollection()<br \/>            {<br \/>                new MapPoint(10,-20),<br \/>                new MapPoint(32,7),<br \/>                new MapPoint(62,-35),<br \/>                new MapPoint(11,-36),<br \/>                new MapPoint(10,-20)<br \/>            };<br \/>            pg2.Rings.Add(pc3);<br \/>            graphics[7].Geometry=pg2;<br \/>            graphics[7].Symbol = new SimpleFillSymbol()<br \/>            {<br \/>                Fill = new VideoBrush()<br \/>                {<br \/>                    SourceName = BearVideo.Name,<br \/>                    Opacity = 0.6,<br \/>                    Stretch = Stretch.UniformToFill<br \/>                }<br \/>            };<\/p>\n<p>            foreach (Graphic g in graphics)<br \/>            {<br \/>                glayer.Graphics.Add(g);<br \/>                g.MouseLeftButtonDown+=new MouseButtonEventHandler(graphic_MouseLeftButtonDown);<br \/>            }<br \/>        }<\/p>\n<p>        private void graphic_MouseLeftButtonDown(object o,MouseButtonEventArgs e)<br \/>        {<br \/>            Graphic g=o as Graphic;<br \/>            MessageBox.Show(string.Format(\"Geometry:{0}nSymbol:{1}\",g.Geometry.GetType().ToString(),g.Symbol.GetType().ToString()));<br \/>        }<\/code><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u53ef\u4ee5\u770b\u5230\uff0c\u5b8c\u5168\u80fd\u591f\u5728\u4e00\u4e2aGraphic\u4e0a\u5b9a\u4e49\u4e00\u4e9b\u4e8b\u4ef6\uff0c\u6765\u8fbe\u5230\u7a0b\u5e8f\u7684\u76ee\u7684\u3002\u5927\u5bb6\u53ef\u4ee5\u8bd5\u7740\u628a\u4e0a\u9762\u7684\u5185\u5bb9\u5728xaml\u4e2d\u6539\u5199\u4e00\u904d\u3002\u770b\u5230\u8fd9\u91cc\u80af\u5b9a\u4f1a\u4ea7\u751f\u4e00\u4e2a\u7591\u95ee\uff1a\u96be\u9053\u6bcf\u4e2aGeometry\u7684\u5b9a\u4e49\u90fd\u8fd9\u4e48\u56f0\u96be\u5417\uff1f\u5176\u5b9eSilverlight API\u5df2\u7ecf\u7ed9\u6211\u4eec\u63d0\u4f9b\u4e86ESRI.ArcGIS.Draw\uff08\u7ee7\u627f\u81eaxaml\u4e2d\u7684Canvas\uff09\u7c7b\uff0c\u5b83\u80fd\u975e\u5e38\u65b9\u4fbf\u7684\u6355\u6349\u5230\u7528\u6237\u7684\u9f20\u6807\u64cd\u4f5c\uff0c\u4ece\u800c\u83b7\u53d6\u5404\u79cdGeometry\u6765\u4f9b\u7a0b\u5e8f\u4f7f\u7528\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u53ef\u4ee5\u628aDraw\u7406\u89e3\u6210\u4e00\u5757\u753b\u677f\uff0c\u8c03\u7528Draw\u7684Active()\u65b9\u6cd5\uff0c\u5c31\u53ef\u4ee5\u5f00\u59cb\u5728\u753b\u677f\u4e0a\u9762\u7ed8\u753b\uff0c\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u8bb0\u5f55\u9f20\u6807\u753b\u51fa\u7684\u6bcf\u4e2aGeometry\uff0c\u8c03\u7528DeActive()\u65b9\u6cd5\uff0c\u505c\u6b62\u7ed8\u753b\u3002Active()\u6709\u4e00\u4e2aDrawMode\u53c2\u6570\uff0c\u5b83\u51b3\u5b9a\u4e86\u6211\u4eec\u5373\u5c06\u5728\u8fd9\u4e2a\u753b\u677f\u4e0a\u753b\u51fa\u7684\u5185\u5bb9\u7c7b\u578b\uff1aPoint\uff0cPolyline\uff0cPolygon\u7b49\u3002\u5728\u753b\u7684\u8fc7\u7a0b\u4e2d\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u5730\u56fe\u4e0a\u53ef\u4ee5\u5b9e\u65f6\u53cd\u6620\u51fa\u6211\u4eec\u7ed8\u753b\u7684\u5185\u5bb9\uff0c\u800c\u8fd9\u4e9b\u5219\u5229\u7528\u4e86Draw\u7684\u9884\u5b9a\u4e49Symbol\uff1aDefaultMarkerSymbol\uff0cDefaultLineSymbol\uff0cDefaultPolygonSymbol\u7b49\u3002\u5bf9\u5e94\u5173\u7cfb\u5982\u4e0b\uff1a<br \/><a onblur=\"try {parent.deselectBloggerImageGracefully();} catch(e) {}\" href=\"http:\/\/1.bp.blogspot.com\/_DD8LUY9p6iU\/Sew-I5lLCiI\/AAAAAAAAAHE\/9eCQLiQnfAw\/s1600-h\/04_drawmode.png\" target=\"_blank\"><img decoding=\"async\" style=\"display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 100px;\" src=\"http:\/\/1.bp.blogspot.com\/_DD8LUY9p6iU\/Sew-I5lLCiI\/AAAAAAAAAHE\/9eCQLiQnfAw\/s400\/04_drawmode.png\" border=\"0\" alt=\"\" id=\"BLOGGER_PHOTO_ID_5326700781889063458\" \/><\/a><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u6bcf\u5f53\u5b8c\u6210\u4e00\u4e2a\u56fe\u5f62\u7684\u7ed8\u5236\uff0c\u5c31\u4f1a\u89e6\u53d1Draw.OnDrawComplete\u4e8b\u4ef6\uff0c\u5229\u7528\u4e8b\u4ef6\u53c2\u6570\u5c31\u53ef\u4ee5\u83b7\u5f97Geometry\uff0c\u4e4b\u540e\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2aGraphic\uff0c\u8bbe\u7f6e\u4e00\u4e2aSymbol\uff08\u4e00\u822c\u4f7f\u7528Draw\u7684\u9884\u5b9a\u4e49Symbol\uff09\uff0c\u628a\u753b\u597d\u7684\u8fd9\u4e2aGraphic\u6dfb\u52a0\u5230\u4e00\u4e2aGraphicsLayer\u4e2d\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"http:\/\/www.newnaw.com\/pub\/sl\/04.html\" target=\"_blank\">\u70b9\u51fb\u8fd9\u91cc<\/a>\uff0c\u67e5\u770b\u4e00\u4e2a\u6bd4\u8f83\u5b8c\u6574\u7684Graphics\u7684\u4f8b\u5b50\u3002<br \/>\u6700\u540e\u6765\u770b\u4e00\u4e0b\u8fd9\u4e2a\u4f8b\u5b50\u7684\u90e8\u5206\u4ee3\u7801\uff1a<br \/><code><grid.resources> <br \/> <esrisymbols:simplemarkersymbol x:name=\"DefaultMarkerSymbol\" color=\"Red\" size=\"12\" style=\"Circle\"><br \/> <esrisymbols:cartographiclinesymbol x:name=\"DefaultLineSymbol\" color=\"Red\" width=\"4\"><br \/> <esrisymbols:simplefillsymbol x:name=\"DefaultFillSymbol\" fill=\"#33FF0000\" borderbrush=\"Red\" borderthickness=\"2\"><br \/> <\/esrisymbols:simplefillsymbol><esrisymbols:simplefillsymbol x:name=\"DefaultPolygonSymbol\" fill=\"#33FF0000\" borderbrush=\"Red\" borderthickness=\"2\"><br \/> <\/esrisymbols:simplefillsymbol><\/esrisymbols:cartographiclinesymbol><\/esrisymbols:simplemarkersymbol><\/grid.resources><\/p>\n<p> <esri:draw x:name=\"Draw1\"><br \/>                    DefaultRectangleSymbol=\"{StaticResource DefaultFillSymbol}\" <br \/>                    DefaultMarkerSymbol=\"{StaticResource DefaultMarkerSymbol}\"<br \/>                    DefaultLineSymbol=\"{StaticResource DefaultLineSymbol}\"<br \/>                    DefaultPolygonSymbol=\"{StaticResource DefaultPolygonSymbol}\"<br \/>                    Loaded=\"Draw1_Loaded\"<br \/>                    OnDrawComplete=\"Draw1_OnDrawComplete\" \/><\/p>\n<p> <canvas verticalalignment=\"Top\" horizontalalignment=\"Left\" margin=\"20,20,0,0\" width=\"430\" height=\"110\"><br \/> <rectangle radiusx=\"10\" radiusy=\"10\" width=\"430\" height=\"110\" fill=\"#98000000\" stroke=\"#FF6495ED\"><br \/> <\/rectangle><rectangle fill=\"#FFFFFFFF\" stroke=\"DarkGray\" radiusx=\"5\" radiusy=\"5\" canvas.left=\"10\" canvas.top=\"10\" width=\"410\" height=\"90\"><\/p>\n<p> <stackpanel orientation=\"Vertical\" canvas.top=\"5\" canvas.left=\"20\"><br \/> <esriwidgets:toolbar x:name=\"ToolBar1\" maxitemheight=\"80\" maxitemwidth=\"80\" width=\"380\" height=\"80\"><br \/>                                     ToolbarIndexChanged=\"ToolBar1_ToolbarIndexChanged\"<br \/>                                     ToolbarItemClicked=\"ToolBar1_ToolbarItemClicked\"><br \/> <esriwidgets:toolbar.items><br \/> <esriwidgets:toolbaritemcollection><br \/> <esriwidgets:toolbaritem text=\"\u6dfb\u52a0\u70b9\"><br \/> <esriwidgets:toolbaritem.content><br \/> <image source=\"imgs\/DrawPoint.png\" stretch=\"UniformToFill\" margin=\"5\"><br \/> <\/image><\/esriwidgets:toolbaritem.content><br \/> <\/esriwidgets:toolbaritem><br \/> <esriwidgets:toolbaritem text=\"\u6dfb\u52a0\u6298\u7ebf\"><br \/> <esriwidgets:toolbaritem.content><br \/> <image source=\"imgs\/DrawPolyline.png\" stretch=\"UniformToFill\" margin=\"5\"><br \/> <\/image><\/esriwidgets:toolbaritem.content><br \/> <\/esriwidgets:toolbaritem><br \/> <esriwidgets:toolbaritem text=\"\u6dfb\u52a0\u591a\u8fb9\u5f62\"><br \/> <esriwidgets:toolbaritem.content><br \/> <image source=\"imgs\/DrawPolygon.png\" stretch=\"UniformT\noFill\" margin=\"5\"><br \/> <\/image><\/esriwidgets:toolbaritem.content><br \/> <\/esriwidgets:toolbaritem><br \/> <esriwidgets:toolbaritem text=\"\u6dfb\u52a0\u77e9\u5f62\"><br \/> <esriwidgets:toolbaritem.content><br \/> <image source=\"imgs\/DrawRectangle.png\" stretch=\"UniformToFill\" margin=\"5\"><br \/> <\/image><\/esriwidgets:toolbaritem.content><br \/> <\/esriwidgets:toolbaritem><br \/> <esriwidgets:toolbaritem text=\"\u6dfb\u52a0\u66f2\u7ebf\"><br \/> <esriwidgets:toolbaritem.content><br \/> <image source=\"imgs\/DrawFreehand.png\" stretch=\"UniformToFill\" margin=\"5\"><br \/> <\/image><\/esriwidgets:toolbaritem.content><br \/> <\/esriwidgets:toolbaritem><br \/> <esriwidgets:toolbaritem text=\"\u505c\u6b62\u6dfb\u52a0\u52a8\u4f5c\"><br \/> <esriwidgets:toolbaritem.content><br \/> <image source=\"imgs\/StopDraw.png\" stretch=\"UniformToFill\" margin=\"5\"><br \/> <\/image><\/esriwidgets:toolbaritem.content><br \/> <\/esriwidgets:toolbaritem><br \/> <esriwidgets:toolbaritem text=\"\u6e05\u7a7a\u7ed8\u5236\u7684\u56fe\u5f62\"><br \/> <esriwidgets:toolbaritem.content><br \/> <image source=\"imgs\/eraser.png\" stretch=\"UniformToFill\" margin=\"5\"><br \/> <\/image><\/esriwidgets:toolbaritem.content><br \/> <\/esriwidgets:toolbaritem><br \/> <\/esriwidgets:toolbaritemcollection><br \/> <\/esriwidgets:toolbar.items><br \/> <\/esriwidgets:toolbar><br \/> <textblock x:name=\"StatusTextBlock\" text=\"\" fontweight=\"Bold\" horizontalalignment=\"Center\"><br \/> <\/textblock><\/stackpanel><br \/> <\/rectangle><\/canvas><\/esri:draw><\/code><br \/><code>private void Draw1_Loaded(object sender, RoutedEventArgs e)<br \/>        {<br \/>            Draw1.Map = Map1;<br \/>        }<\/p>\n<p>        private void Draw1_OnDrawComplete(object sender, ESRI.ArcGIS.DrawEventArgs args)<br \/>        {<br \/>            ESRI.ArcGIS.GraphicsLayer graphicsLayer = Map1.Layers[\"GLayer2\"] as ESRI.ArcGIS.GraphicsLayer;<br \/>            ESRI.ArcGIS.Graphic graphic = new ESRI.ArcGIS.Graphic()<br \/>            {<br \/>                Geometry = args.Geometry,<br \/>                Symbol = _activeSymbol,<br \/>            };<br \/>            graphicsLayer.Graphics.Add(graphic);<br \/>        }<\/p>\n<p>        private void ToolBar1_ToolbarIndexChanged(object sender, ESRI.ArcGIS.Widgets.SelectedToolbarItemArgs e)<br \/>        {<br \/>            StatusTextBlock.Text = e.Item.Text;<br \/>        }<\/p>\n<p>        private void ToolBar1_ToolbarItemClicked(object sender, ESRI.ArcGIS.Widgets.SelectedToolbarItemArgs e)<br \/>        {<br \/>            Draw1.Deactivate();<br \/>            switch (e.Index)<br \/>            {<br \/>                case 0: \/\/ Point<br \/>                    Draw1.Activate(ESRI.ArcGIS.DrawMode.Point);<br \/>                    _activeSymbol = strobeSymbol;<br \/>                    break;<br \/>                case 1: \/\/ Polyline<br \/>                    Draw1.Activate(ESRI.ArcGIS.DrawMode.Polyline);<br \/>                    _activeSymbol = DefaultLineSymbol;<br \/>                    break;<br \/>                case 2: \/\/ Polygon<br \/>                    Draw1.Activate(ESRI.ArcGIS.DrawMode.Polygon);<br \/>                    _activeSymbol = DefaultPolygonSymbol;<br \/>                    break;<br \/>                case 3: \/\/ Rectangle<br \/>                    Draw1.Activate(ESRI.ArcGIS.DrawMode.Rectangle);<br \/>                    _activeSymbol = DefaultFillSymbol;<br \/>                    break;<br \/>                case 4: \/\/ Freehand<br \/>                    Draw1.Activate(ESRI.ArcGIS.DrawMode.Freehand);<br \/>                    _activeSymbol = waveLineSymbol;<br \/>                    break;<br \/>                case 5: \/\/ Stop Graphics<br \/>                    break;<br \/>                case 6: \/\/ Clear Graphics<br \/>                    ESRI.ArcGIS.GraphicsLayer graphicsLayer = Map1.Layers[\"GLayer2\"] as ESRI.ArcGIS.GraphicsLayer;<br \/>                    graphicsLayer.ClearGraphics();<br \/>                    break;<\/p>\n<p>            }<br \/>        }<\/code><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u5927\u5bb6\u53ef\u4ee5\u6ce8\u610f\u4e00\u4e0b\u4f8b\u5b50\u4e2d\u6dfb\u52a0\u7684\u70b9\u7b26\u53f7\u548c\u66f2\u7ebf\u7b26\u53f7\u3002\u53ea\u8981\u6709\u8db3\u591f\u7684\u60f3\u8c61\u529b\uff0c\u5b8c\u5168\u53ef\u4ee5\u5229\u7528Silverlight\u5b9a\u5236\u51fa\u975e\u5e38\u70ab\u7684\u7b26\u53f7\u6548\u679c\u6765\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u597d\u4e86\uff0c\u4e0b\u4e00\u8282\u6211\u4eec\u6765\u4e86\u89e3\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u753b\u51fa\u7684\u56fe\u5f62\u4e0e\u5730\u56fe\u6570\u636e\u4ea4\u4e92\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u6211\u4eec\u4e0e\u5730\u56fe\u4ea4\u4e92\u7684\u8fc7\u7a0b\u65f6\u523b\u5728\u8fdb\u884c\u7740\uff1a\u4e00\u4e2a\u62c9\u6846\u653e\u5927\u64cd\u4f5c\uff0c\u6216\u8005\u5bf9\u5730\u56fe\u5185\u5bb9\u7684\u67e5\u8be2\u7b49\u3002\u8fd9\u4e9b\u4ea4\u4e92\u8fc7\u7a0b\u4e2d\u7684\u8f93\u5165\u8f93\u51fa\uff0c\u901a\u5e38\u90fd\u662f\u53cd\u6620\u5728\u72ec\u7acb\u4e8e\u5730\u56fe\u6570\u636e\u4e00\u4e2a\u201c\u5c42\u201d\u4e0a\u3002\u6bd4\u5982\u62c9\u6846\u653e\u5927\uff0c\u6211\u4eec\u80fd\u770b\u89c1\u9f20\u6807\u6240\u753b\u7684\u4e00\u4e2a\u77e9\u5f62\uff1b\u53c8\u6bd4\u5982\u5bf9\u5174\u8da3\u70b9\u7684\u67e5\u8be2\uff0c\u7ed3\u679c\u901a\u5e38\u662f\u5c06\u7b26\u5408\u6761\u4ef6\u7684\u5174\u8da3\u70b9\u7684\u5f62\u72b6\u9ad8\u4eae\u663e\u793a\u5728\u90a3\u4e2a\u72ec\u7acb\u7684\u201c\u5c42\u201d\u4e2d\uff0c\u901a\u8fc7\u5b83\u65e2\u53ef\u4ee5\u53cd\u6620\u7528\u6237\u7684\u8f93\u5165\uff0c\u53c8\u53ef\u4ee5\u5c55\u73b0\u5730\u56fe\u7684\u8f93\u51fa\u3002\u8fd9\u4e2a\u201c\u5c42\u201d\u5c31\u662fGraphicsLayer\u3002&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u5176\u5b9eADF\u5f00\u53d1\u4e2d\u4e5f\u6709GraphicsLayer\u7684\u6982\u5ff5\uff0c\u540c\u6837\u5728\u5176\u4ed6\u4e24\u4e2a\u5ba2\u6237\u7aefAPI\uff08JavaScript\/Flex\uff09\u4e2d\u4e5f\u80fd\u627e\u5230GraphicsLayer\u7684\u8eab\u5f71\uff0c\u5b83\u4eec\u90fd\u662f\u4e00\u6837\u4e00\u6837\u7684\u3002&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u672c\u8282\u6211\u4eec\u4e3b\u8981\u770b\u5982\u4f55\u5728GraphicsLayer\u4e2d\u5c55\u73b0\u5185\u5bb9\u3002\u5f53\u7136\u7b2c\u4e00\u4e2a\u5de5\u4f5c\u5c31\u662f\u6dfb\u52a0ESRI.ArcGIS.dll\u7684\u5f15\u7528\uff0c\u5f15\u5165esri\u7684xml\u547d\u540d\u7a7a\u95f4\uff1b\u63a5\u4e0b\u6765\u5728Map\u4e2d\u6dfb\u52a0\u4e00\u4e2aGraphicsLayer\u56fe\u5c42\uff1a &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8981\u4f7fGraphicsLayer\u4e2d\u7684\u5185\u5bb9\u5904\u4e8e\u6700\u9876\u7aef\uff08\u4e0d\u88ab\u5176\u4ed6\u56fe\u5c42\u5185\u5bb9\u8986\u76d6\uff09\uff0c\u5c31\u8981\u5c06\u5b83\u653e\u5728Map\u6807\u7b7e\u91cc\u7684\u6700\u4e0b\u5934\uff0c\u50cf\u4e0a\u9762\u90a3\u6837\u3002\u4ece\u547d\u540d\u6211\u4eec\u4e0d\u96be\u770b\u51fa\uff0cGraphicLayer\u91cc\u9762\u653e\u7684\u5c31\u662fGraphic\u7684\u96c6\u5408\u4e86\u3002Graphic\uff08ESRI.ArcGIS.Graphic\uff09\u662fGraphicsLayer\u4e2d\u7684\u57fa\u672c\u5143\u7d20\uff0c\u5b83\u5305\u62ec\u4e86Geometry(\u5728ESRI.ArcGIS.Geometry\u547d\u540d\u7a7a\u95f4\u4e2d)\uff0cSymbol\uff08\u5728ESRI.ArcGIS.Symbol\u547d\u540d\u7a7a\u95f4\u4e2d\uff09\uff0cAttributes\u7b49\u5c5e\u6027\u3002\u6240\u6709\u663e\u793a\u5728\u5730\u56fe\u4e2d\u7684\u77e2\u91cf\u5143\u7d20\u90fd\u6709\u4e00\u4e2aGeometry\uff0c\u91cc\u9762\u5305\u542b\u4e86\u82e5\u5e72\u5730\u7406\u5750\u6807\uff0c\u7528\u4e8e\u663e\u793a\u5730\u56fe\u4e0a\u5730\u7269\u7684\u5f62\u72b6\uff0c\u5b83\u662fPoint\uff0cPolyline\uff0cPolygon\u7b49\u7684\u603b\u79f0\uff0c\u5728\u8fd9\u91cc\u4ee3\u8868\u4e86Graphic\u7684\u5f62\u72b6\u3002Symbol\u4ee3\u8868\u4e86Graphic\u7684\u5916\u89c2\uff0c\u5b83\u662f\u4e00\u7cfb\u5217\u7b26\u53f7\u7684\u603b\u79f0\uff0c\u6211\u4eec\u901a\u5e38\u8ddfSimpleMarkerSymbol\uff0cSimpleLineSymbol\u548cSimpleFillSymbol\u7b49\u6253\u4ea4\u9053\uff0c\u5b83\u4eec\u5206\u522b\u5bf9\u5e94\u4e86\u4e0a\u97623\u79cd\u4e0d\u540c\u7684Geometry\uff08Point\uff0cPolyline\uff0cPolygon\uff09\u3002&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8981\u8ba9\u4e00\u4e2aGraphic\u663e\u793a\u51fa\u6765\uff0c\u603b\u5171\u52063\u6b65\uff1a1\u3001\u5b9a\u4e49Graphic\uff1a\u5728xaml\u4e2d\u5728code-behind\u4e2dGraphic g= new Graphic()2\u3001\u8bbe\u7f6eGraphic\u7684Geometry\u548cSymbol\u5c5e\u6027\uff1a\u5728xaml\u4e2d \u5728code-behind\u4e2dGraphic g = new Graphic() { Geometry = new MapPoint(108, 30), Symbol = new SimpleMarkerSymbol() { Color = new SolidColorBrush(Colors.Blue), Size = 12, Style = SimpleMarkerSymbol.SimpleMarkerStyle.Square } };3\u3001\u628a\u5b9a\u4e49\u597d\u7684Graphic\u6dfb\u52a0\u5230GraphicsLayer\u91cc\uff1a\u5728xaml\u4e2d \u5728code-behind\u4e2dGraphic g = new Graphic() { Geometry = new MapPoint(108, 30), Symbol = new SimpleMarkerSymbol() { Color = new SolidColorBrush(Colors.Blue), Size = 12, Style = SimpleMarkerSymbol.SimpleMarkerStyle.Square } };GraphicsLayer glayer = Map1.Layers[&#8220;GLayer&#8221;] as &hellip; <a href=\"https:\/\/blog.newnaw.com\/?p=42\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">ArcGIS API for Silverlight\u5f00\u53d1\u5165\u95e8\uff084\uff09\uff1a\u7528\u6237\u4e0e\u5730\u7406\u4fe1\u606f\u4e4b\u95f4\u7684\u6865\u6881&#8211;GraphicsLayer<\/span> <span class=\"meta-nav\">&raquo;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[8,24],"_links":{"self":[{"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=\/wp\/v2\/posts\/42"}],"collection":[{"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=42"}],"version-history":[{"count":0,"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=\/wp\/v2\/posts\/42\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=42"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=42"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=42"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}