private void parcelZoomBtn_Click(object sender, EventArgs e)
 {
     try
     {
         datacontract.geojson secGeom = JsonConvert.DeserializeObject <datacontract.geojson>(perceel.geometry.shape);
         createGrapicAndZoomTo(perceel.geometry.shape, secGeom);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + ": " + ex.StackTrace);
     }
 }
        private void createGrapicAndZoomTo(string capakeyResponse, datacontract.geojson Geom)
        {
            IRgbColor inClr = new RgbColorClass()
            {
                Red = 0, Blue = 100, Green = 0
            };;
            IRgbColor outLine = new RgbColorClass()
            {
                Red = 0, Blue = 200, Green = 0, Transparency = 240
            };

            if (Geom.type == "MultiPolygon")
            {
                datacontract.geojsonMultiPolygon muniPolygons =
                    JsonConvert.DeserializeObject <datacontract.geojsonMultiPolygon>(capakeyResponse);

                IGeometryCollection multiPoly = new GeometryBagClass();

                clearGraphics();
                foreach (datacontract.geojsonPolygon poly in muniPolygons.toPolygonList())
                {
                    IPolygon lbPoly = geopuntHelper.geojson2esriPolygon(poly, (int)dataHandler.CRS.Lambert72);
                    lbPoly.SimplifyPreserveFromTo();
                    IGeometry prjGeom = geopuntHelper.Transform((IGeometry)lbPoly, map.SpatialReference);

                    IElement muniGrapic = geopuntHelper.AddGraphicToMap(map, prjGeom, inClr, outLine, 2, true);
                    graphics.Add(muniGrapic);

                    multiPoly.AddGeometry(prjGeom);
                }
                view.Extent = ((IGeometryBag)multiPoly).Envelope;
                view.Refresh();
            }
            else if (Geom.type == "Polygon")
            {
                datacontract.geojsonPolygon municipalityPolygon =
                    JsonConvert.DeserializeObject <datacontract.geojsonPolygon>(capakeyResponse);
                IPolygon lbPoly = geopuntHelper.geojson2esriPolygon(municipalityPolygon, (int)dataHandler.CRS.Lambert72);
                lbPoly.SimplifyPreserveFromTo();
                IPolygon prjPoly = (IPolygon)geopuntHelper.Transform((IGeometry)lbPoly, map.SpatialReference);
                view.Extent = prjPoly.Envelope;

                clearGraphics();
                IElement muniGrapic = geopuntHelper.AddGraphicToMap(map, (IGeometry)prjPoly, inClr, outLine, 3, true);
                graphics.Add(muniGrapic);
                view.Refresh();
            }
        }
        private void sectieZoomBtn_Click(object sender, EventArgs e)
        {
            string gemeente = gemeenteCbx.Text;
            string niscode  = municipality2nis(gemeente);

            string depName = departementCbx.Text;
            string depCode = department2code(depName);

            string sectie = sectieCbx.Text;

            if (niscode == "" || depCode == "" || sectie == "" ||
                niscode == null || depCode == null || sectie == null)
            {
                return;
            }

            try
            {
                datacontract.section sec = capakey.getSectie(int.Parse(niscode), int.Parse(depCode), sectie,
                                                             dataHandler.CRS.Lambert72, dataHandler.capakeyGeometryType.full);
                datacontract.geojson secGeom = JsonConvert.DeserializeObject <datacontract.geojson>(sec.geometry.shape);

                createGrapicAndZoomTo(sec.geometry.shape, secGeom);
            }
            catch (WebException wex)
            {
                if (wex.Status == WebExceptionStatus.Timeout)
                {
                    MessageBox.Show("De connectie werd afgebroken." +
                                    " Het duurde te lang voor de server een resultaat terug gaf.\n" +
                                    "U kunt via de instellingen de 'timout'-tijd optrekken.", wex.Message);
                }
                else if (wex.Response != null)
                {
                    string resp = new StreamReader(wex.Response.GetResponseStream()).ReadToEnd();
                    MessageBox.Show(resp, wex.Message);
                }
                else
                {
                    MessageBox.Show(wex.Message, "Error");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ": " + ex.StackTrace);
            }
        }