MultiPolygon and RadMap

6 posts, 1 answers
  1. Nick Anagnostopoulos
    Nick Anagnostopoulos avatar
    3 posts
    Member since:
    Jul 2009

    Posted 07 Jun 2010 Link to this post

    I am writing an application similar to the Sales Dashboard example. In the example,  only simple polygons are being displayed, is it possible to use MultiPolygons with the RadMap?
  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 09 Jun 2010 Link to this post

    Hello Nick Anagnostopoulos,

    Yes, this can be done. There are several ways to achieve such behavior. The map shapes operate similar to the standard Silverlight geometries, but use geographical locations as figure points' coordinates. For example, the following code snippets add multi-polygon to the information layer. The first one use MapPolygon and the second one use MapPath for this purposes:

    LocationCollection points = new LocationCollection();
    // Outer polygon
    points.Add(new Location(42, -122));
    points.Add(new Location(42, -121.5));
    points.Add(new Location(41.5, -121.5));
    points.Add(new Location(41.5, -122));
    points.Add(new Location(42, -122));
      
    // Inner polygon
    points.Add(new Location(41.9, -121.9));
    points.Add(new Location(41.9, -121.6));
    points.Add(new Location(41.6, -121.6));
    points.Add(new Location(41.6, -121.9));
    points.Add(new Location(41.9, -121.9));
      
    MapPolygon polygon = new MapPolygon()
    {
        Fill = new SolidColorBrush(Colors.Red),
        Points = points
    };
    this.informationLayer.Items.Add(polygon);

    MapPathFigure figure = new MapPathFigure();
      
    // Outer polygon
    LocationCollection points = new LocationCollection();
    points.Add(new Location(42, -122));
    points.Add(new Location(42, -121.5));
    points.Add(new Location(41.5, -121.5));
    points.Add(new Location(41.5, -122));
    points.Add(new Location(42, -122));
      
    MapPolyLineSegment polyline = new MapPolyLineSegment();
    polyline.Points = points;
      
    figure.StartPoint = points[0];
    figure.Segments.Add(polyline);
      
    // Inner polygon
    points = new LocationCollection();
    points.Add(new Location(41.9, -121.9));
    points.Add(new Location(41.9, -121.6));
    points.Add(new Location(41.6, -121.6));
    points.Add(new Location(41.6, -121.9));
    points.Add(new Location(41.9, -121.9));
      
    polyline = new MapPolyLineSegment();
    polyline.Points = points;
    figure.Segments.Add(polyline);
      
    MapPathGeometry geometry = new MapPathGeometry();
    geometry.FillRule = FillRule.EvenOdd;
    geometry.Figures.Add(figure);
      
    MapPath path = new MapPath()
    {
        Fill = new SolidColorBrush(Colors.Green),
        Data = geometry
    };
      
    this.informationLayer.Items.Add(path);

    The first approach is the easiest, but second one is more flexible.

    Regards,
    Andrey Murzov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Nick Anagnostopoulos
    Nick Anagnostopoulos avatar
    3 posts
    Member since:
    Jul 2009

    Posted 28 Jun 2010 Link to this post

    Is it also possible to to put a label over the top of the shapes? 

    I am displaying zipcodes on the RadMap and i cant figure out how to add a label over the top of the shapes so the user can identify the zipcodes.
  5. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 29 Jun 2010 Link to this post

    Hi Nick Anagnostopoulos,

    You can add any FrameworkElement to the information layer and position it geographically. For example:

    // Create grid with text block
    Grid grid = new Grid();
    grid.Background = new SolidColorBrush(Colors.White);
    TextBlock text = new TextBlock();
    text.Foreground = new SolidColorBrush(Colors.Red);
    text.Text = "94546";
    grid.Children.Add(text);
      
    // Set grid geographical location.
    MapLayer.SetLocation(grid, new Location(42, -122));
      
    // Add grid to information layer
    this.informationLayer.Items.Add(grid);


    Regards,
    Andrey Murzov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Nick Anagnostopoulos
    Nick Anagnostopoulos avatar
    3 posts
    Member since:
    Jul 2009

    Posted 30 Jun 2010 Link to this post

    Andrey, thank you very much for your help. i have been able to add multipolygons to the map, but when adding multipolygons or polygons with multiple interior polygons or "holes", the shapes are skewed.

    Is it possible to create a multipolygon or polygon with more than one interior ring or "hole'?

    Attached is a screenshot of the RadMap displaying the polygons and the spatial results from SQL Management Studio side by side.

    Below is a Multipolygon that is not loading correctly and the code i am using to load Polygons and Multipolygons:

    "MULTIPOLYGON (((-88.032770000991476 41.883998997255631, -88.031555 41.884111999999995, -88.031517 41.883525, -88.029768001561962 41.8835909983199, -88.029808 41.884226999999996, -88.02982 41.88449, -88.029828 41.884696999999996, -88.032349 41.884443999999995, -88.032754001149826 41.884376998523656, -88.0327499998807 41.88424400012191, -88.032770000991476 41.883998997255631)), ((-88.068424003511581 41.914283998758933, -88.068366 41.906946, -88.067249003030966 41.9069809988156, -88.067280004221061 41.907368999688913, -88.066778 41.907419999999995, -88.066783 41.906996, -88.065167003766476 41.9070539994613, -88.065167 41.908439, -88.065168 41.908752, -88.065176004375715 41.910703998197661, -88.064573001443947 41.910743996878089, -88.064676999999989 41.911336999999996, -88.065179 41.911332, -88.06518899999999 41.913727, -88.06531599989394 41.913748997462783, -88.065289000387182 41.914387999609282, -88.068424003511581 41.914283998758933)), ((-88.082019000476265 41.902825998431432, -88.080471998131131 41.902873998966513, -88.080587 41.903465, -88.081834 41.903459, -88.082019000476265 41.902825998431432)), ((-88.090532000653937 41.889516002754668, -88.09046699999999 41.888470999999996, -88.089387 41.888515999999996, -88.087143 41.888636, -88.084167999999991 41.888783, -88.080502 41.888968, -88.080468 41.88801, -88.079759 41.88801, -88.079759002031 41.887266998426242, -88.080468001032656 41.887202999742, -88.080468 41.886832999999996, -88.080468 41.885129, -88.079668 41.885028999999996, -88.07966700333958 41.883728997432151, -88.080486000684772 41.883730000310059, -88.080523 41.881026999999996, -88.080466999720883 41.877728999459279, -88.080541 41.87549, -88.081634 41.874919999999996, -88.082689 41.874244, -88.083637 41.873442, -88.083652 41.873207, -88.085526 41.871688, -88.085788000169558 41.870158001593161, -88.083515999374384 41.870201002626565, -88.083867002685466 41.867729001417558, -88.083867 41.867228999999995, -88.083265 41.867201, -88.083261999999991 41.866456, -88.082698999999991 41.866454, -88.08140499999999 41.866533, -88.080901 41.866496, -88.078904999999992 41.86656, -88.078905999999989 41.863259, -88.078909 41.862235, -88.07891199883538 41.860365000149791, -88.078997 41.860231, -88.0791080004438 41.859738001977988, -88.078992 41.859207999999995, -88.076361999999989 41.859251, -88.076353 41.858349, -88.076205999985149 41.855000997275823, -88.076303 41.853497, -88.076437 41.852982, -88.077334999999991 41.851904999999995, -88.07738599999999 41.851344, -88.080658000986773 41.851304000613304, -88.080649000781349 41.850853999628121, -88.080738 41.850685999999996, -88.081001 41.850601999999995, -88.082241001715289 41.850582999189328, -88.082242 41.850384999999996, -88.081763 41.850384999999996, -88.081755999568841 41.849522999116431, -88.082233996520856 41.8495170004205, -88.082236999999992 41.849022, -88.08224899999999 41.846773999999996, -88.081610003354115 41.84677399949836, -88.081645999999992 41.846038, -88.082253000667635 41.846041000605396, -88.082261 41.844497, -88.08063 41.844456, -88.077396999999991 41.844443, -88.077402997533781 41.838332000764737, -88.077917 41.838231, -88.079765996600088 41.838229002563587, -88.079762997216648 41.837825003321115, -88.081065999281691 41.837825000236407, -88.080817 41.833666, -88.080816 41.832029, -88.080064999999991 41.831886, -88.078715 41.831897, -88.07871999999999 41.830979, -88.077462 41.830914, -88.077438 41.830098, -88.076064 41.830051999999995, -88.075390995815965 41.8300289979407, -88.075555 41.826395, -88.075741999999991 41.826043999999996, -88.076066 41.825818999999996, -88.076613 41.825694, -88.076873999999989 41.825742, -88.077066 41.825461, -88.078035 41.825553, -88.078122 41.826096, -88.078843999480085 41.826144002700389, -88.078848 41.825737, -88.078633000670735 41.825668000604182, -88.07891 41.825407, -88.079535003440967 41.824239002306754, -88.079342 41.823783999999996, -88.078631 41.823248, -88.078068 41.823096, -88.077818999999991 41.822894999999995, -88.077292 41.822486999999995, -88.077119 41.821469, -88.071373004432033 41.821583997906309, -88.071895 41.820153999999995, -88.071923995243282 41.8194849980961, -88.071613 41.818659, -88.0708860015186 41.817781998422632, -88.071214 41.817581, -88.072 41.81672, -88.072961997570715 41.815519000700213, -88.071912 41.815446, -88.071139000391781 41.815209998634849, -88.071115999999989 41.81502, -88.070811999999989 41.814986999999995, -88.070537999414384 41.814838996613041, -88.070550999079 41.814566998923887, -88.070458 41.814515, -88.07024 41.814602, -88.069822 41.814603, -88.069807 41.81492, -88.069644 41.815051, -88.069420999999991 41.815093999999995, -88.068862 41.815013, -88.068553 41.814766999999996, -88.06836899999999 41.814741999999995, -88.068287001185183 41.8147819997066, -88.06850199812429 41.81477599936786, -88.06832399999999 41.814814, -88.068197998284546 41.814985000080355, -88.068219000812135 41.814887000280223, -88.067979 41.815445, -88.052728 41.815509999999996, -88.036959999506067 41.815694998847682, -88.036965999999993 41.818124, -88.037773 41.818160999999996, -88.039118 41.819286999999996, -88.039426999999989 41.819213, -88.047095 41.824985999999996, -88.048239999999993 41.825235, -88.053108999999992 41.82534, -88.053105 41.825505, -88.053286998323046 41.825605002322241, -88.053091 41.825658, -88.052996 41.825365, -88.046859 41.82561, -88.046261001651018 41.825279997846529, -88.047658 41.826333999999996, -88.048532999999992 41.826983999999996, -88.049119997187162 41.826957002111769, -88.0489699982444 41.82720600205058, -88.049083996370243 41.827354003031658, -88.0486769998889 41.828246002477428, -88.048780002073613 41.828239001009983, -88.04875899999999 41.828413, -88.048473 41.828485, -88.048129 41.828976999999995, -88.048007997674119 41.829722999294404, -88.048048998436457 41.830966999531618, -88.047737 41.831589, -88.04669 41.83471, -88.046318 41.835422, -88.04581 41.836993, -88.045627 41.837309, -88.042976 41.839594, -88.041628004015692 41.841408997247477, -88.041642 41.841908, -88.0419 41.842454, -88.042346999999992 41.843869, -88.042811 41.844842, -88.042901 41.845233, -88.042971999999992 41.845690999999995, -88.043001002949509 41.847497999507759, -88.042948000561438 41.847585997971095, -88.043015 41.847699, -88.043048997047748 41.848966999896923, -88.042946 41.849337, -88.041522 41.851233, -88.040523999999991 41.85293, -88.040183 41.853291999999996, -88.040131997686444 41.85347600009802, -88.04018099999999 41.85367, -88.040442 41.853977, -88.041868999999991 41.855356, -88.041862999999992 41.856587, -88.042169 41.856587, -88.043338999999989 41.858867, -88.043367999412027 41.859508000705176, -88.041499 41.859494999999995, -88.039253 41.859553999999996, -88.038906 41.859564999999996, -88.03843599999999 41.859581, -88.036878 41.859634, -88.034456999999989 41.859645, -88.033065999999991 41.859662, -88.031507999453083 41.859692000219376, -88.031538997843285 41.860402999599359, -88.027045997637472 41.860650001414875, -88.027123 41.86215, -88.02718 41.864021, -88.03296499999999 41.864028999999995, -88.037966 41.864028999999995, -88.037945 41.865462, -88.038316999999992 41.866823, -88.038538 41.866332, -88.038585 41.865573999999995, -88.039713001545252 41.865538998487651, -88.039219001268279 41.866712000503455, -88.04055300036859 41.866699999471557, -88.040517999999992 41.867756, -88.04021 41.870438, -88.037142 41.870501, -88.035883 41.872285999999995, -88.0345119973781 41.874085997358222, -88.038857996278182 41.873921000166504, -88.036321 41.874767999999996, -88.035226 41.875620999999995, -88.034711999722475 41.876254999181832, -88.034765997514612 41.876302999957829, -88.034627 41.876538, -88.034528 41.876565, -88.03438999676365 41.877762997989372, -88.034539999999993 41.879082, -88.034691 41.879715, -88.034688 41.880269, -88.035062 41.880891, -88.036108 41.882006, -88.036546002509013 41.883280996695653, -88.035384 41.88362, -88.034225000401 41.883798997362788, -88.034391 41.884057, -88.036509 41.8838, -88.036554 41.883933999999996, -88.036581 41.884495, -88.03810399999999 41.884865999999995, -88.039262999999991 41.885521, -88.039701999999991 41.885467999999996, -88.040185999999991 41.885033, -88.040413 41.884989999999995, -88.040957999999989 41.885273, -88.043117999999993 41.886112, -88.044254001639231 41.886345999788446, -88.044169004988177 41.886522001757143, -88.045092 41.886790999999995, -88.045874 41.887129, -88.046117 41.887414, -88.046297 41.887372, -88.046723 41.887620999999996, -88.046928 41.887612, -88.04712099999999 41.887834999999995, -88.047412 41.887817999999996, -88.04794 41.888041, -88.048422 41.88807, -88.048802 41.887986, -88.049155 41.888134, -88.049607999999992 41.888194999999996, -88.049742 41.888149999999996, -88.049836 41.887851999999995, -88.049998 41.887732, -88.05073999999999 41.888256999999996, -88.050919999999991 41.888698999999995, -88.050914002975588 41.8890160008387, -88.050657999568571 41.88979699908333, -88.05065700069126 41.890150001885395, -88.050261999999989 41.890938999999996, -88.04997000174636 41.891271998739164, -88.0500580035201 41.891663999506889, -88.049972999246947 41.891931999963376, -88.05030099999999 41.892264999999995, -88.050952 41.892604999999996, -88.050974000211554 41.892718000689513, -88.050891 41.892972, -88.050603999999993 41.893325, -88.049837 41.893571, -88.049787 41.893876999999996, -88.049734 41.894023, -88.049363 41.894369, -88.048920999999993 41.895340999999995, -88.048591001209715 41.895752000472079, -88.0487089993417 41.895837002086523, -88.048514 41.897304999999996, -88.048253997427182 41.897312000371578, -88.048525 41.897391999999996, -88.048582998102532 41.899827001841423, -88.048186995949024 41.903863003345123, -88.049670997372459 41.9038219988214, -88.0496039969454 41.903031998572182, -88.051370999999989 41.903034, -88.051412 41.903772, -88.056871 41.903618, -88.05762 41.903597, -88.058081 41.903582, -88.058764997962982 41.903561003209717, -88.058734999632222 41.90219200288567, -88.059161996816357 41.902196002749356, -88.059157 41.901997, -88.058067999999992 41.901966, -88.058058994311779 41.900817003245265, -88.060193997082763 41.900782998696236, -88.06017700267914 41.897986000462346, -88.061786 41.89796, -88.063481997202388 41.897931997147872, -88.063469002276236 41.898346998547929, -88.0659999991306 41.898279998673694, -88.065971000115141 41.895543997784856, -88.068428998607459 41.89573900080989, -88.06843000020416 41.895622000979493, -88.070118999999991 41.895761, -88.070116 41.896077, -88.070247999999992 41.898005, -88.072532999999993 41.898078999999996, -88.074096 41.898083, -88.074072997339641 41.900450999829218, -88.072508995719843 41.900444000067075, -88.0725129974811 41.903126999409544, -88.071702995600859 41.903152001073259, -88.071673998790573 41.906849998528543, -88.069992001685648 41.906884000137687, -88.070011 41.907391, -88.070021 41.910554, -88.071668 41.910503999999996, -88.071669 41.912859999999995, -88.073318 41.912813, -88.073319 41.914930999999996, -88.07332 41.915504, -88.0749210008937 41.9154520001993, -88.074923 41.912766, -88.074931003671438 41.910410999298072, -88.076539 41.910357, -88.076539 41.912717, -88.076538000081072 41.914829001751158, -88.0756190012062 41.914874001958744, -88.075611999999992 41.915431999999996, -88.079784002004 41.915304001861919, -88.079784000273591 41.9144220001962, -88.0814410011784 41.914334002368562, -88.08144 41.913956, -88.081019 41.913962999999995, -88.08102199999999 41.913621, -88.080956998385389 41.913284001574425, -88.081438999466826 41.913257001998986, -88.081437 41.912653, -88.081443999999991 41.911733, -88.080863 41.9119, -88.080815001714981 41.911351001288132, -88.081447004681721 41.9113210009082, -88.081451 41.908085, -88.081454999999991 41.907712, -88.081465 41.906617999999995, -88.07976699999999 41.906659999999995, -88.078154 41.906693, -88.074930999999992 41.906773, -88.07487599577297 41.903051999036592, -88.075604997099092 41.903028999058641, -88.075617999999992 41.902297, -88.075663999999989 41.899423, -88.074646 41.899308999999995, -88.074670995783478 41.898084999082968, -88.075678 41.898084999999995, -88.075870998488384 41.897420999363092, -88.07588299999999 41.896299, -88.074449998063 41.896060998352837, -88.076254999999989 41.896043, -88.079404 41.896301, -88.082214997503826 41.896531000873708, -88.082217 41.895966, -88.082231999999991 41.894625, -88.082214000274817 41.892144001355895, -88.087863 41.892114, -88.088636999999991 41.891964, -88.089786001674256 41.891891001062817, -88.089738001052069 41.889575002194135, -88.090532000653937 41.889516002754668), (-88.07562199653249 41.897077999982137, -88.075431996095816 41.89735899942503, -88.075532 41.897417999999995, -88.075555999231909 41.897755998990945, -88.07548 41.898018, -88.07493 41.898033999999996, -88.07478099498995 41.897909997140729, -88.074809 41.897776, -88.07487399858978 41.897326998603845, -88.074422 41.89733, -88.074018999999993 41.897228999999996, -88.073982998888653 41.896556996861413, -88.07405399999999 41.896308999999995, -88.075234999999992 41.896322999999995, -88.075586 41.896425, -88.07562199653249 41.897077999982137), (-88.065314001105534 41.892717997341734, -88.063435 41.892734999999995, -88.0634210009114 41.891693996781413, -88.064709 41.891676, -88.065287 41.891667999999996, -88.065314001105534 41.892717997341734)))"

    Public Function WKTToMapShape(ByVal poly As String, ByVal color As System.Windows.Media.Brush, ByVal border As System.Windows.Media.Brush) As List(Of Object)
            Dim wktType = poly.Substring(0, poly.IndexOf(" ("))
            Dim PolygonList As New List(Of Object)
            Select Case wktType.ToUpper

                Case "POLYGON"

                    Dim WKT = poly
                    WKT = WKT.Replace(")), ((", ")):((")
                    WKT = WKT.Replace("), (", ");(")
                    WKT = Replace(WKT, "POLYGON ((", "((")
                    Dim figure As New MapPathFigure
                    Dim geometry As New MapPathGeometry
                    Dim path As New MapPath
                    Dim PointArray() As String
                    Dim points As New LocationCollection
                    Dim i As Integer = 0

                    If WKT.Contains(");(") = True Then
                        Dim rings = Split(WKT, ";")
                        For Each ring In rings
                            Dim r = ring
                            r = r.Replace("(", "")
                            r = r.Replace(")", "")

                            PointArray = Split(r, ",")
                            points = New LocationCollection
                            For Each pnt In PointArray
                                Dim Coords() = Split(Trim(pnt), " ")
                                Dim longitude = CType(Coords(0), Double)
                                Dim latitude = CType(Coords(1), Double)
                                points.Add(New Location(latitude, longitude))
                            Next
                            Dim polyline As New MapPolyLineSegment
                            polyline.Points = points
                            If i = 0 Then
                                figure.StartPoint = points(0)
                                i = i + 1
                            End If
                            figure.Segments.Add(polyline)
                        Next
                        geometry = New MapPathGeometry
                        geometry.FillRule = FillRule.EvenOdd
                        geometry.Figures.Add(figure)
                        path = New MapPath With {.Fill = color, .Stroke = border, .StrokeThickness = 2, .Data = geometry}
                        PolygonList.Add(path)
                    Else 'If Polygon does not have interior rings
                        Dim r = WKT
                        r = r.Replace("(", "")
                        r = r.Replace(")", "")

                        PointArray = Split(r, ",")
                        points = New LocationCollection
                        For Each pnt In PointArray
                            Dim Coords() = Split(Trim(pnt), " ")
                            Dim longitude = CType(Coords(0), Double)
                            Dim latitude = CType(Coords(1), Double)
                            points.Add(New Location(latitude, longitude))
                        Next
                        Dim polyline As New MapPolyLineSegment
                        polyline.Points = points

                        figure.StartPoint = points(0)

                        figure.Segments.Add(polyline)

                        geometry = New MapPathGeometry
                        geometry.FillRule = FillRule.EvenOdd
                        geometry.Figures.Add(figure)
                        path = New MapPath With {.Fill = color, .Stroke = border, .StrokeThickness = 2, .Data = geometry}
                        PolygonList.Add(path)
                    End If

                Case "MULTIPOLYGON"
                    'Manipulate String to make it easier to split apart and indentify
                    Dim WKT = poly

                    
                    WKT = WKT.Replace(")), ((", ")):((")
                    WKT = WKT.Replace("), (", ");(")
                    WKT = Replace(WKT, "MULTIPOLYGON (((", "((")
                    WKT = Replace(WKT, ")))", "))")
                    'Create an array of each polygon
                    Dim PolyArray() As String = Split(WKT, ":")

                    For Each ply In PolyArray
                        Dim figure As New MapPathFigure
                        Dim geometry As New MapPathGeometry
                        Dim path As New MapPath
                        Dim i As Integer = 0

                        'If polygon has interior rings
                        If ply.Contains(");(") = True Then
                            Dim rings = Split(ply, ";")

                            For Each ring In rings
                                Dim r = ring
                                r = r.Replace("(", "")
                                r = r.Replace(")", "")
                                Dim PointArray() As String = Split(r, ",")
                                Dim points As New LocationCollection
                                For Each pnt In PointArray
                                    Dim Coords() = Split(Trim(pnt), " ")
                                    Dim longitude = CType(Coords(0), Double)
                                    Dim latitude = CType(Coords(1), Double)
                                    points.Add(New Location(latitude, longitude))
                                Next
                                Dim polyline As New MapPolyLineSegment
                                polyline.Points = points
                                If i = 0 Then
                                    figure.StartPoint = points(0)
                                    i = i + 1
                                End If
                                figure.Segments.Add(polyline)

                            Next

                            geometry = New MapPathGeometry
                            geometry.FillRule = FillRule.Nonzero
                            geometry.Figures.Add(figure)
                            path = New MapPath With {.Fill = color, .Stroke = border, .StrokeThickness = 2, .Data = geometry}
                            'path = New MapPath With {.Fill = color, .Data = geometry}
                            PolygonList.Add(path)
                        Else 'If Polygon does not have interior rings
                            Dim r = ply
                            r = r.Replace("(", "")
                            r = r.Replace(")", "")
                            Dim PointArray() As String = Split(r, ",")
                            Dim points As New LocationCollection
                            For Each pnt In PointArray
                                Dim Coords() = Split(Trim(pnt), " ")
                                Dim longitude = CType(Coords(0), Double)
                                Dim latitude = CType(Coords(1), Double)
                                points.Add(New Location(latitude, longitude))
                            Next
                            Dim polyline As New MapPolyLineSegment
                            polyline.Points = points
                            figure.StartPoint = points(0)
                            figure.Segments.Add(polyline)
                            geometry = New MapPathGeometry
                            geometry.FillRule = FillRule.EvenOdd
                            geometry.Figures.Add(figure)
                            path = New MapPath With {.Fill = color, .Stroke = border, .StrokeThickness = 1, .Data = geometry}
                            PolygonList.Add(path)
                        End If
                    Next
                Case Else
                    Throw New NotImplementedException
            End Select
            Return PolygonList
        End Function


  7. Answer
    Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 30 Jun 2010 Link to this post

    Hello Nick Anagnostopoulos,

    Yes, it's possible to create a multipolygon or polygon with more than one interior ring.
    If the polygon has interior rings, then the logic of the figures creation should create each polygon as separate figure. The sample code is the following:
    geometry = New MapPathGeometry
    geometry.FillRule = FillRule.EvenOdd

    For
    Each ring In rings
        figure = New MapPathFigure
        Dim r = ring
        r = r.Replace("(", "")
        r = r.Replace(")", "")
        Dim PointArray() As String = Split(r, ",")
        Dim points As New LocationCollection

        
    For Each pnt In PointArray
            Dim Coords() = Split(Trim(pnt), " ")
            Dim longitude = CType(Coords(0), Double)
            Dim latitude = CType(Coords(1), Double)
            points.Add(New Location(latitude, longitude))
        Next

        
    Dim polyline As New MapPolyLineSegment
        polyline.Points = points
        figure.StartPoint = points(0)
        figure.Segments.Add(polyline)

        
    geometry.Figures.Add(figure)
    Next

    path =
    New MapPath With {.Fill = color, .Stroke = border, .StrokeThickness = 2, .Data = geometry}
    PolygonList.Add(path)

    All the best,
    Andrey Murzov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
UI for WPF is Visual Studio 2017 Ready