POST
|
I am using a graphicLayer for my school and it is initialized with a button but how do I carry on and draw a buffer? p.s. sorry I'm quite lost, I'm new to this
... View more
04-05-2011
01:43 AM
|
0
|
0
|
252
|
POST
|
i was wondering if i could get some assistance here,currently im able to buffer in the map,but i want it to be done only upon clicking on a button,i tried putting the codes in the button itself but it dosent work,i appreciate if someone could reply to my post. protected void BUTTON_TEST(object sender, RoutedEventArgs e) { GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); e.MapPoint.SpatialReference = MyMap.SpatialReference; Graphic graphic = new ESRI.ArcGIS.Client.Graphic() { Geometry = e.MapPoint, Symbol = LayoutRoot.Resources["DefaultClickSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol }; graphic.SetZIndex(1); graphicsLayer.Graphics.Add(graphic); GeometryService geometryService = new GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); geometryService.BufferCompleted += GeometryService_BufferCompleted; geometryService.Failed += GeometryService_Failed; // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering BufferParameters bufferParams = new BufferParameters() { //Unit = LinearUnit.StatuteMile, Unit = LinearUnit.Kilometer, BufferSpatialReference = new SpatialReference(4326), OutSpatialReference = MyMap.SpatialReference }; bufferParams.Features.Add(graphic); bufferParams.Distances.Add(500); geometryService.BufferAsync(bufferParams); } void GeometryService_BufferCompleted(object sender, GraphicsEventArgs args) { IList<Graphic> results = args.Results; GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; foreach (Graphic graphic in results) { graphic.Symbol = LayoutRoot.Resources["DefaultBufferSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; graphicsLayer.Graphics.Add(graphic); } } private void GeometryService_Failed(object sender, TaskFailedEventArgs e) { MessageBox.Show("Geometry Service error: " + e.Error); }
... View more
04-04-2011
10:57 PM
|
0
|
0
|
510
|
POST
|
Also when I enter this into my codes, I keep getting an error that says "the name graphic does not exist in the current context" string axisX = (graphic.Geometry as MapPoint).X; string axisY = (graphic.Geometry as MapPoint).Y;
... View more
04-04-2011
06:47 PM
|
0
|
0
|
252
|
POST
|
Thanks for the pointers Dominque but i still do not really understand it fully, these are my codes for the button, there are errors when I key it in, any ideas where I went wrong or what am I missing? protected void Buffer2Button(object sender, RoutedEventArgs e) { x = (graphic.Geometry as MapPoint).X; y = (graphic.Geometry as MapPoint).Y; GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer_Buffer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); e.MapPoint.SpatialReference = MyMap.SpatialReference; Graphic graphic = new ESRI.ArcGIS.Client.Graphic() { Geometry = e.MapPoint, Symbol = LayoutRoot.Resources["DefaultBufferSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol }; graphic.SetZIndex(1); graphicsLayer.Graphics.Add(graphic); GeometryService geometryService = new GeometryService ("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); geometryService.BufferCompleted += GeometryService_BufferCompleted; geometryService.Failed += GeometryService_Failed; BufferParameters bufferParams = new BufferParameters() { Unit = LinearUnit.Kilometer, BufferSpatialReference = new SpatialReference(4326), OutSpatialReference = MyMap.SpatialReference }; bufferParams.Features.Add(graphic); bufferParams.Distances.Add(2); geometryService.BufferAsync(bufferParams); }
... View more
04-04-2011
05:57 PM
|
0
|
0
|
252
|
POST
|
Hi, I'm trying to create a buffer around a school and i only want the buffer to come out when i click a button from the pop up menu of the school, I already have the pop up menu and the map, what i need is to know how to capture the x,y coordinates of the school and how to subsequently draw a buffer around the school. Any ideas?
... View more
04-03-2011
07:03 PM
|
0
|
5
|
632
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|