From 02d755988460cc0b5a1606b48291c5bb5da83da9 Mon Sep 17 00:00:00 2001 From: Langston Smith Date: Fri, 24 May 2019 05:20:47 -0700 Subject: [PATCH] Adding example of "revealed" polygon hole with outline (#1050) * initial additions * fixes based on lukasz review --- .../mapboxandroiddemo/MainActivity.java | 9 + .../src/main/AndroidManifest.xml | 7 + .../assets/downtown_san_jose_hole.geojson | 1757 +++++++++++++++++ .../RevealedPolygonHoleOutlineActivity.java | 205 ++ ...ctivity_polygon_holes_outline_revealed.xml | 19 + .../main/res/values/descriptions_strings.xml | 5 +- .../src/main/res/values/titles_strings.xml | 1 + .../src/main/res/values/urls_strings.xml | 7 +- 8 files changed, 2004 insertions(+), 6 deletions(-) create mode 100644 MapboxAndroidDemo/src/main/assets/downtown_san_jose_hole.geojson create mode 100644 MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/dds/RevealedPolygonHoleOutlineActivity.java create mode 100644 MapboxAndroidDemo/src/main/res/layout/activity_polygon_holes_outline_revealed.xml diff --git a/MapboxAndroidDemo/src/global/java/com/mapbox/mapboxandroiddemo/MainActivity.java b/MapboxAndroidDemo/src/global/java/com/mapbox/mapboxandroiddemo/MainActivity.java index b8a43fdc7..a141ae3e4 100644 --- a/MapboxAndroidDemo/src/global/java/com/mapbox/mapboxandroiddemo/MainActivity.java +++ b/MapboxAndroidDemo/src/global/java/com/mapbox/mapboxandroiddemo/MainActivity.java @@ -57,6 +57,7 @@ import com.mapbox.mapboxandroiddemo.examples.dds.MultipleHeatmapStylingActivity; import com.mapbox.mapboxandroiddemo.examples.dds.PolygonHolesActivity; import com.mapbox.mapboxandroiddemo.examples.dds.PolygonSelectToggleActivity; +import com.mapbox.mapboxandroiddemo.examples.dds.RevealedPolygonHoleOutlineActivity; import com.mapbox.mapboxandroiddemo.examples.dds.SatelliteLandSelectActivity; import com.mapbox.mapboxandroiddemo.examples.dds.StyleCirclesCategoricallyActivity; import com.mapbox.mapboxandroiddemo.examples.dds.StyleLineIdentityPropertyActivity; @@ -1326,6 +1327,14 @@ private void initializeModels() { null, R.string.activity_dds_symbol_collision_detection_url, false, BuildConfig.MIN_SDK_VERSION)); + exampleItemModels.add(new ExampleItemModel( + R.id.nav_dds, + R.string.activity_dds_polygon_revealed_hole_outline_title, + R.string.activity_dds_polygon_revealed_hole_outline_description, + new Intent(MainActivity.this, RevealedPolygonHoleOutlineActivity.class), + null, + R.string.activity_dds_polygon_revealed_hole_outline_url, false, BuildConfig.MIN_SDK_VERSION)); + exampleItemModels.add(new ExampleItemModel( R.id.nav_basics, R.string.activity_basic_simple_mapview_title, diff --git a/MapboxAndroidDemo/src/main/AndroidManifest.xml b/MapboxAndroidDemo/src/main/AndroidManifest.xml index 73741d8e5..638a1dae6 100644 --- a/MapboxAndroidDemo/src/main/AndroidManifest.xml +++ b/MapboxAndroidDemo/src/main/AndroidManifest.xml @@ -85,6 +85,13 @@ android:name="android.support.PARENT_ACTIVITY" android:value="com.mapbox.mapboxandroiddemo.MainActivity" /> + + + diff --git a/MapboxAndroidDemo/src/main/assets/downtown_san_jose_hole.geojson b/MapboxAndroidDemo/src/main/assets/downtown_san_jose_hole.geojson new file mode 100644 index 000000000..03bb59c82 --- /dev/null +++ b/MapboxAndroidDemo/src/main/assets/downtown_san_jose_hole.geojson @@ -0,0 +1,1757 @@ +{ + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -121.854813, + 37.342272 + ], + [ + -121.856129, + 37.343637 + ], + [ + -121.856384, + 37.343904 + ], + [ + -121.856932, + 37.344431 + ], + [ + -121.857147, + 37.344637 + ], + [ + -121.857357, + 37.344839 + ], + [ + -121.857553, + 37.34503 + ], + [ + -121.858532, + 37.346113 + ], + [ + -121.858669, + 37.346254 + ], + [ + -121.859491, + 37.347174 + ], + [ + -121.859823, + 37.347536 + ], + [ + -121.860346, + 37.348116 + ], + [ + -121.860506, + 37.348295 + ], + [ + -121.860632, + 37.34844 + ], + [ + -121.861128, + 37.349001 + ], + [ + -121.861307, + 37.349203 + ], + [ + -121.861462, + 37.349398 + ], + [ + -121.861771, + 37.349783 + ], + [ + -121.861813, + 37.349836 + ], + [ + -121.861837, + 37.349863 + ], + [ + -121.861555, + 37.349993 + ], + [ + -121.861685, + 37.350142 + ], + [ + -121.862497, + 37.351068 + ], + [ + -121.862732, + 37.351332 + ], + [ + -121.863251, + 37.351835 + ], + [ + -121.863428, + 37.351999 + ], + [ + -121.863749, + 37.352293 + ], + [ + -121.864498, + 37.352953 + ], + [ + -121.865896, + 37.354185 + ], + [ + -121.865944, + 37.354223 + ], + [ + -121.865986, + 37.354261 + ], + [ + -121.866138, + 37.354399 + ], + [ + -121.866589, + 37.354792 + ], + [ + -121.867466, + 37.355555 + ], + [ + -121.868147, + 37.356146 + ], + [ + -121.868774, + 37.35673 + ], + [ + -121.868952, + 37.35689 + ], + [ + -121.869179, + 37.357058 + ], + [ + -121.869509, + 37.357309 + ], + [ + -121.869843, + 37.357573 + ], + [ + -121.870354, + 37.357943 + ], + [ + -121.870623, + 37.358145 + ], + [ + -121.871077, + 37.358446 + ], + [ + -121.871223, + 37.358534 + ], + [ + -121.871349, + 37.358622 + ], + [ + -121.871916, + 37.358961 + ], + [ + -121.872355, + 37.359236 + ], + [ + -121.872974, + 37.359594 + ], + [ + -121.873655, + 37.359903 + ], + [ + -121.874445, + 37.36027 + ], + [ + -121.875, + 37.360514 + ], + [ + -121.875664, + 37.360773 + ], + [ + -121.876244, + 37.360964 + ], + [ + -121.876799, + 37.361155 + ], + [ + -121.877287, + 37.361296 + ], + [ + -121.877575, + 37.361372 + ], + [ + -121.878052, + 37.361486 + ], + [ + -121.878994, + 37.361704 + ], + [ + -121.879869, + 37.361872 + ], + [ + -121.880587, + 37.361975 + ], + [ + -121.881199, + 37.362043 + ], + [ + -121.882172, + 37.362158 + ], + [ + -121.88369, + 37.36231 + ], + [ + -121.885323, + 37.362509 + ], + [ + -121.885767, + 37.362555 + ], + [ + -121.885847, + 37.362562 + ], + [ + -121.885908, + 37.36257 + ], + [ + -121.886065, + 37.362585 + ], + [ + -121.886267, + 37.362608 + ], + [ + -121.887257, + 37.362715 + ], + [ + -121.887892, + 37.362791 + ], + [ + -121.889589, + 37.362986 + ], + [ + -121.889978, + 37.363028 + ], + [ + -121.891405, + 37.363157 + ], + [ + -121.891491, + 37.363165 + ], + [ + -121.891592, + 37.363173 + ], + [ + -121.892902, + 37.363287 + ], + [ + -121.893879, + 37.363333 + ], + [ + -121.894278, + 37.363348 + ], + [ + -121.895195, + 37.363428 + ], + [ + -121.896378, + 37.363527 + ], + [ + -121.896854, + 37.363577 + ], + [ + -121.898169, + 37.363688 + ], + [ + -121.898743, + 37.363745 + ], + [ + -121.899841, + 37.363844 + ], + [ + -121.900423, + 37.363928 + ], + [ + -121.900845, + 37.364008 + ], + [ + -121.901484, + 37.364161 + ], + [ + -121.901672, + 37.364214 + ], + [ + -121.901712, + 37.364225 + ], + [ + -121.901903, + 37.36429 + ], + [ + -121.901993, + 37.364115 + ], + [ + -121.902002, + 37.364092 + ], + [ + -121.902027, + 37.364042 + ], + [ + -121.902168, + 37.363764 + ], + [ + -121.902363, + 37.363447 + ], + [ + -121.902733, + 37.36294 + ], + [ + -121.903009, + 37.362604 + ], + [ + -121.903702, + 37.361895 + ], + [ + -121.904314, + 37.361273 + ], + [ + -121.904711, + 37.360895 + ], + [ + -121.905535, + 37.360094 + ], + [ + -121.906767, + 37.358854 + ], + [ + -121.906971, + 37.358652 + ], + [ + -121.907097, + 37.358526 + ], + [ + -121.907187, + 37.358438 + ], + [ + -121.907259, + 37.35837 + ], + [ + -121.907379, + 37.358248 + ], + [ + -121.907711, + 37.357916 + ], + [ + -121.908134, + 37.357492 + ], + [ + -121.909311, + 37.356321 + ], + [ + -121.90955, + 37.356085 + ], + [ + -121.91012, + 37.355516 + ], + [ + -121.910622, + 37.355017 + ], + [ + -121.910961, + 37.354681 + ], + [ + -121.911385, + 37.354242 + ], + [ + -121.911539, + 37.354097 + ], + [ + -121.911871, + 37.353781 + ], + [ + -121.912781, + 37.352934 + ], + [ + -121.913015, + 37.35269 + ], + [ + -121.913313, + 37.352423 + ], + [ + -121.914192, + 37.351725 + ], + [ + -121.915215, + 37.350973 + ], + [ + -121.91626, + 37.350241 + ], + [ + -121.916426, + 37.350119 + ], + [ + -121.917753, + 37.34918 + ], + [ + -121.918179, + 37.348894 + ], + [ + -121.918257, + 37.348837 + ], + [ + -121.918356, + 37.348764 + ], + [ + -121.918451, + 37.348696 + ], + [ + -121.918655, + 37.348551 + ], + [ + -121.918896, + 37.348383 + ], + [ + -121.918985, + 37.348322 + ], + [ + -121.920059, + 37.347616 + ], + [ + -121.920216, + 37.347506 + ], + [ + -121.920412, + 37.347368 + ], + [ + -121.920481, + 37.347319 + ], + [ + -121.920622, + 37.347219 + ], + [ + -121.921043, + 37.346914 + ], + [ + -121.921865, + 37.346312 + ], + [ + -121.922035, + 37.346186 + ], + [ + -121.922102, + 37.346136 + ], + [ + -121.922249, + 37.346029 + ], + [ + -121.922789, + 37.345678 + ], + [ + -121.923023, + 37.345526 + ], + [ + -121.92308, + 37.345484 + ], + [ + -121.923203, + 37.345388 + ], + [ + -121.923817, + 37.344915 + ], + [ + -121.924004, + 37.344755 + ], + [ + -121.924177, + 37.34461 + ], + [ + -121.92437, + 37.344423 + ], + [ + -121.924519, + 37.344275 + ], + [ + -121.925903, + 37.34276 + ], + [ + -121.92594, + 37.342714 + ], + [ + -121.925962, + 37.342688 + ], + [ + -121.92601, + 37.342638 + ], + [ + -121.926056, + 37.342588 + ], + [ + -121.92589, + 37.342535 + ], + [ + -121.925798, + 37.342508 + ], + [ + -121.925716, + 37.342482 + ], + [ + -121.925617, + 37.342451 + ], + [ + -121.925228, + 37.342329 + ], + [ + -121.925039, + 37.34226 + ], + [ + -121.924891, + 37.342203 + ], + [ + -121.92474, + 37.342115 + ], + [ + -121.924646, + 37.342047 + ], + [ + -121.924202, + 37.341654 + ], + [ + -121.92415, + 37.341692 + ], + [ + -121.923437, + 37.341089 + ], + [ + -121.923048, + 37.340754 + ], + [ + -121.922634, + 37.340399 + ], + [ + -121.921911, + 37.339781 + ], + [ + -121.920738, + 37.338827 + ], + [ + -121.919666, + 37.337919 + ], + [ + -121.919271, + 37.33758 + ], + [ + -121.919348, + 37.337545 + ], + [ + -121.919544, + 37.337427 + ], + [ + -121.919765, + 37.337267 + ], + [ + -121.920767, + 37.336481 + ], + [ + -121.921694, + 37.335775 + ], + [ + -121.921947, + 37.335569 + ], + [ + -121.922607, + 37.33507 + ], + [ + -121.923559, + 37.334349 + ], + [ + -121.924074, + 37.33396 + ], + [ + -121.92267, + 37.332808 + ], + [ + -121.921976, + 37.332232 + ], + [ + -121.921368, + 37.33172 + ], + [ + -121.920744, + 37.331198 + ], + [ + -121.92005, + 37.330626 + ], + [ + -121.919949, + 37.330542 + ], + [ + -121.919235, + 37.329947 + ], + [ + -121.919098, + 37.329832 + ], + [ + -121.918659, + 37.329473 + ], + [ + -121.91843, + 37.329287 + ], + [ + -121.918081, + 37.329 + ], + [ + -121.917833, + 37.328794 + ], + [ + -121.917498, + 37.32852 + ], + [ + -121.917023, + 37.328131 + ], + [ + -121.916655, + 37.327833 + ], + [ + -121.916176, + 37.327444 + ], + [ + -121.915892, + 37.327211 + ], + [ + -121.915308, + 37.326738 + ], + [ + -121.915167, + 37.326624 + ], + [ + -121.914835, + 37.326353 + ], + [ + -121.914545, + 37.326132 + ], + [ + -121.91449, + 37.326097 + ], + [ + -121.914345, + 37.325979 + ], + [ + -121.914251, + 37.325933 + ], + [ + -121.914139, + 37.325911 + ], + [ + -121.913805, + 37.325907 + ], + [ + -121.913792, + 37.325457 + ], + [ + -121.913788, + 37.325377 + ], + [ + -121.913776, + 37.32501 + ], + [ + -121.913767, + 37.324488 + ], + [ + -121.913765, + 37.32432 + ], + [ + -121.913761, + 37.324163 + ], + [ + -121.913752, + 37.323549 + ], + [ + -121.91375, + 37.323496 + ], + [ + -121.913746, + 37.323408 + ], + [ + -121.913746, + 37.323156 + ], + [ + -121.913742, + 37.322695 + ], + [ + -121.91374, + 37.322577 + ], + [ + -121.913738, + 37.322462 + ], + [ + -121.913738, + 37.322329 + ], + [ + -121.913736, + 37.322191 + ], + [ + -121.913733, + 37.321898 + ], + [ + -121.913731, + 37.321791 + ], + [ + -121.913729, + 37.321604 + ], + [ + -121.913729, + 37.321344 + ], + [ + -121.913727, + 37.321257 + ], + [ + -121.913727, + 37.321047 + ], + [ + -121.913725, + 37.320898 + ], + [ + -121.913725, + 37.320761 + ], + [ + -121.913733, + 37.318918 + ], + [ + -121.913738, + 37.318781 + ], + [ + -121.91374, + 37.318583 + ], + [ + -121.91374, + 37.31846 + ], + [ + -121.913742, + 37.318342 + ], + [ + -121.913742, + 37.318243 + ], + [ + -121.913744, + 37.318174 + ], + [ + -121.913744, + 37.318064 + ], + [ + -121.913855, + 37.3179 + ], + [ + -121.913889, + 37.317801 + ], + [ + -121.914286, + 37.316992 + ], + [ + -121.91448, + 37.316599 + ], + [ + -121.914597, + 37.31637 + ], + [ + -121.914694, + 37.316183 + ], + [ + -121.914879, + 37.315828 + ], + [ + -121.914953, + 37.315668 + ], + [ + -121.914986, + 37.31558 + ], + [ + -121.915007, + 37.315523 + ], + [ + -121.914825, + 37.315447 + ], + [ + -121.91452, + 37.315317 + ], + [ + -121.914213, + 37.315214 + ], + [ + -121.913912, + 37.31513 + ], + [ + -121.91334, + 37.315004 + ], + [ + -121.913101, + 37.31497 + ], + [ + -121.912722, + 37.314917 + ], + [ + -121.911776, + 37.314852 + ], + [ + -121.911053, + 37.314871 + ], + [ + -121.910942, + 37.314878 + ], + [ + -121.910822, + 37.314882 + ], + [ + -121.91062, + 37.314917 + ], + [ + -121.9105, + 37.314726 + ], + [ + -121.910387, + 37.314745 + ], + [ + -121.909792, + 37.314848 + ], + [ + -121.90951, + 37.314905 + ], + [ + -121.909216, + 37.314981 + ], + [ + -121.908813, + 37.315119 + ], + [ + -121.908663, + 37.315248 + ], + [ + -121.908594, + 37.315306 + ], + [ + -121.908337, + 37.315531 + ], + [ + -121.908285, + 37.31555 + ], + [ + -121.908178, + 37.315596 + ], + [ + -121.907875, + 37.315733 + ], + [ + -121.907841, + 37.315748 + ], + [ + -121.907454, + 37.315928 + ], + [ + -121.907236, + 37.316027 + ], + [ + -121.906956, + 37.316156 + ], + [ + -121.906685, + 37.316278 + ], + [ + -121.906052, + 37.316572 + ], + [ + -121.905781, + 37.316702 + ], + [ + -121.905649, + 37.316767 + ], + [ + -121.90554, + 37.316816 + ], + [ + -121.905415, + 37.316877 + ], + [ + -121.905235, + 37.316965 + ], + [ + -121.904697, + 37.317205 + ], + [ + -121.904232, + 37.317453 + ], + [ + -121.904135, + 37.317518 + ], + [ + -121.903284, + 37.31809 + ], + [ + -121.903069, + 37.318235 + ], + [ + -121.902952, + 37.318327 + ], + [ + -121.902613, + 37.318609 + ], + [ + -121.902487, + 37.318747 + ], + [ + -121.902187, + 37.319078 + ], + [ + -121.901709, + 37.319609 + ], + [ + -121.901234, + 37.320154 + ], + [ + -121.900774, + 37.320681 + ], + [ + -121.900557, + 37.320913 + ], + [ + -121.900414, + 37.321039 + ], + [ + -121.900181, + 37.321253 + ], + [ + -121.899862, + 37.321501 + ], + [ + -121.899555, + 37.321726 + ], + [ + -121.899265, + 37.321905 + ], + [ + -121.89905, + 37.322042 + ], + [ + -121.898739, + 37.322206 + ], + [ + -121.898481, + 37.322336 + ], + [ + -121.898302, + 37.322424 + ], + [ + -121.897963, + 37.322588 + ], + [ + -121.897417, + 37.322805 + ], + [ + -121.897001, + 37.322962 + ], + [ + -121.896336, + 37.323153 + ], + [ + -121.896078, + 37.323214 + ], + [ + -121.895124, + 37.323404 + ], + [ + -121.893768, + 37.323675 + ], + [ + -121.893442, + 37.323736 + ], + [ + -121.892906, + 37.323835 + ], + [ + -121.892471, + 37.323919 + ], + [ + -121.89226, + 37.323957 + ], + [ + -121.892155, + 37.323977 + ], + [ + -121.89212, + 37.323984 + ], + [ + -121.891928, + 37.324022 + ], + [ + -121.891815, + 37.324053 + ], + [ + -121.891602, + 37.324083 + ], + [ + -121.891472, + 37.324106 + ], + [ + -121.891237, + 37.324148 + ], + [ + -121.891159, + 37.324167 + ], + [ + -121.890928, + 37.324209 + ], + [ + -121.890656, + 37.324259 + ], + [ + -121.890392, + 37.324308 + ], + [ + -121.889376, + 37.324499 + ], + [ + -121.889315, + 37.324511 + ], + [ + -121.888227, + 37.324713 + ], + [ + -121.887985, + 37.324759 + ], + [ + -121.887592, + 37.324846 + ], + [ + -121.887196, + 37.324915 + ], + [ + -121.886723, + 37.32501 + ], + [ + -121.886583, + 37.32482 + ], + [ + -121.886408, + 37.324587 + ], + [ + -121.885868, + 37.323862 + ], + [ + -121.884565, + 37.324495 + ], + [ + -121.884338, + 37.324156 + ], + [ + -121.884188, + 37.323984 + ], + [ + -121.883835, + 37.323637 + ], + [ + -121.882267, + 37.324652 + ], + [ + -121.882084, + 37.324789 + ], + [ + -121.882488, + 37.325342 + ], + [ + -121.882666, + 37.325586 + ], + [ + -121.882885, + 37.325876 + ], + [ + -121.882952, + 37.325964 + ], + [ + -121.883015, + 37.326048 + ], + [ + -121.883089, + 37.326155 + ], + [ + -121.883175, + 37.326277 + ], + [ + -121.882698, + 37.32649 + ], + [ + -121.882496, + 37.326288 + ], + [ + -121.882311, + 37.326372 + ], + [ + -121.882536, + 37.326563 + ], + [ + -121.882116, + 37.32675 + ], + [ + -121.882011, + 37.326796 + ], + [ + -121.881817, + 37.326883 + ], + [ + -121.881531, + 37.327009 + ], + [ + -121.881025, + 37.327196 + ], + [ + -121.880833, + 37.327257 + ], + [ + -121.88077, + 37.327276 + ], + [ + -121.880129, + 37.327463 + ], + [ + -121.879564, + 37.327578 + ], + [ + -121.879177, + 37.327635 + ], + [ + -121.878431, + 37.327707 + ], + [ + -121.878008, + 37.327749 + ], + [ + -121.876089, + 37.327925 + ], + [ + -121.875774, + 37.327955 + ], + [ + -121.875463, + 37.327986 + ], + [ + -121.874416, + 37.3281 + ], + [ + -121.873405, + 37.328207 + ], + [ + -121.873173, + 37.32823 + ], + [ + -121.873022, + 37.328249 + ], + [ + -121.872719, + 37.328287 + ], + [ + -121.872122, + 37.328375 + ], + [ + -121.871973, + 37.328402 + ], + [ + -121.871887, + 37.328417 + ], + [ + -121.871584, + 37.328474 + ], + [ + -121.871212, + 37.328585 + ], + [ + -121.870928, + 37.328669 + ], + [ + -121.87056, + 37.328787 + ], + [ + -121.870001, + 37.328981 + ], + [ + -121.86919, + 37.329313 + ], + [ + -121.868761, + 37.329519 + ], + [ + -121.868563, + 37.329611 + ], + [ + -121.868292, + 37.329767 + ], + [ + -121.868105, + 37.329874 + ], + [ + -121.867155, + 37.330416 + ], + [ + -121.866545, + 37.330797 + ], + [ + -121.866064, + 37.331095 + ], + [ + -121.86578, + 37.33127 + ], + [ + -121.865444, + 37.331495 + ], + [ + -121.86529, + 37.331598 + ], + [ + -121.864895, + 37.331865 + ], + [ + -121.864464, + 37.332151 + ], + [ + -121.864355, + 37.332224 + ], + [ + -121.864094, + 37.332388 + ], + [ + -121.863523, + 37.33275 + ], + [ + -121.862999, + 37.333082 + ], + [ + -121.861856, + 37.333776 + ], + [ + -121.861322, + 37.334105 + ], + [ + -121.860695, + 37.33449 + ], + [ + -121.860046, + 37.33489 + ], + [ + -121.858025, + 37.336157 + ], + [ + -121.857615, + 37.336409 + ], + [ + -121.857492, + 37.336481 + ], + [ + -121.857445, + 37.336512 + ], + [ + -121.857395, + 37.336542 + ], + [ + -121.857264, + 37.336622 + ], + [ + -121.857151, + 37.336691 + ], + [ + -121.856834, + 37.336882 + ], + [ + -121.856585, + 37.336687 + ], + [ + -121.85602, + 37.337042 + ], + [ + -121.855808, + 37.337175 + ], + [ + -121.854723, + 37.337851 + ], + [ + -121.854067, + 37.338259 + ], + [ + -121.854155, + 37.33835 + ], + [ + -121.85354, + 37.338747 + ], + [ + -121.853359, + 37.338999 + ], + [ + -121.852907, + 37.339293 + ], + [ + -121.852781, + 37.339365 + ], + [ + -121.852703, + 37.339415 + ], + [ + -121.852608, + 37.339468 + ], + [ + -121.852448, + 37.339575 + ], + [ + -121.852354, + 37.339621 + ], + [ + -121.852324, + 37.339643 + ], + [ + -121.852285, + 37.339663 + ], + [ + -121.852356, + 37.339739 + ], + [ + -121.852541, + 37.339933 + ], + [ + -121.853151, + 37.340563 + ], + [ + -121.853296, + 37.340708 + ], + [ + -121.853987, + 37.341406 + ], + [ + -121.854813, + 37.342272 + ] + ] + ] + }, + "properties": { + "name": "Downtown" + } +} \ No newline at end of file diff --git a/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/dds/RevealedPolygonHoleOutlineActivity.java b/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/dds/RevealedPolygonHoleOutlineActivity.java new file mode 100644 index 000000000..52406320c --- /dev/null +++ b/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/dds/RevealedPolygonHoleOutlineActivity.java @@ -0,0 +1,205 @@ +package com.mapbox.mapboxandroiddemo.examples.dds; + +import android.graphics.Color; +import android.os.AsyncTask; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v7.app.AppCompatActivity; + +import com.mapbox.geojson.Feature; +import com.mapbox.geojson.LineString; +import com.mapbox.geojson.Point; +import com.mapbox.geojson.Polygon; +import com.mapbox.mapboxandroiddemo.R; +import com.mapbox.mapboxsdk.Mapbox; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.geometry.LatLngBounds; +import com.mapbox.mapboxsdk.maps.MapView; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; +import com.mapbox.mapboxsdk.maps.Style; +import com.mapbox.mapboxsdk.style.layers.FillLayer; +import com.mapbox.mapboxsdk.style.layers.LineLayer; +import com.mapbox.mapboxsdk.style.layers.Property; +import com.mapbox.mapboxsdk.style.sources.GeoJsonSource; +import com.mapbox.turf.TurfMeta; + +import java.io.InputStream; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +import timber.log.Timber; + +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOpacity; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineCap; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineJoin; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineWidth; + +public class RevealedPolygonHoleOutlineActivity extends AppCompatActivity implements OnMapReadyCallback { + + private static final String FILL_SOURCE_ID = "SOURCE-ID"; + private static final String LINE_SOURCE_ID = "LINE_SOURCE_ID"; + private static final String FILL_LAYER_ID = "FILL-LAYER-ID"; + private static final String LINE_LAYER_ID = "LINE-LAYER-ID"; + private static final float FILL_OPACITY = .7f; + private static final float LINE_WIDTH = 5f; + private static final int GREY_COLOR = Color.parseColor("#c2c2c2"); + private static final int RED_COLOR = Color.parseColor("#BF544C"); + private MapView mapView; + private MapboxMap mapboxMap; + private static final List OUTER_POLYGON_COORDINATES = new ArrayList() { + { + add(Point.fromLngLat(-121.9921875, 37.27787748952485)); + add(Point.fromLngLat(-121.79580688476562, 37.27787748952485)); + add(Point.fromLngLat(-121.79580688476562, 37.40452830389465)); + add(Point.fromLngLat(-121.9921875, 37.40452830389465)); + add(Point.fromLngLat(-121.9921875, 37.27787748952485)); + } + }; + private static final LatLngBounds RESTRICTED_BOUNDS_AREA = new LatLngBounds.Builder() + .include(new LatLng(37.27787748952485, -121.9921875)) + .include(new LatLng(37.40452830389465, -121.79580688476562)) + .build(); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Mapbox access token is configured here. This needs to be called either in your application + // object or in the same activity which contains the mapview. + Mapbox.getInstance(this, getString(R.string.access_token)); + + // This contains the MapView in XML and needs to be called after the access token is configured. + setContentView(R.layout.activity_polygon_holes_outline_revealed); + + mapView = findViewById(R.id.mapView); + mapView.onCreate(savedInstanceState); + mapView.getMapAsync(this); + } + + @Override + public void onMapReady(final MapboxMap map) { + this.mapboxMap = map; + // Set the boundary area for the map camera + mapboxMap.setLatLngBoundsForCameraTarget(RESTRICTED_BOUNDS_AREA); + + map.setStyle(Style.MAPBOX_STREETS, new Style.OnStyleLoaded() { + @Override + public void onStyleLoaded(@NonNull Style style) { + new LoadGeoJson(RevealedPolygonHoleOutlineActivity.this).execute(); + } + }); + } + + private void addStyling(@NonNull List pointList) { + mapboxMap.getStyle(new Style.OnStyleLoaded() { + @Override + public void onStyleLoaded(@NonNull Style loadedStyle) { + List innerList = new ArrayList<>(); + LineString innerLineString = LineString.fromLngLats(pointList); + innerList.add(innerLineString); + + loadedStyle.addSource(new GeoJsonSource(FILL_SOURCE_ID, + Polygon.fromOuterInner(LineString.fromLngLats(OUTER_POLYGON_COORDINATES), innerList))); + + loadedStyle.addSource(new GeoJsonSource(LINE_SOURCE_ID, innerLineString)); + + loadedStyle.addLayerBelow(new FillLayer(FILL_LAYER_ID, FILL_SOURCE_ID).withProperties( + fillColor(GREY_COLOR), + fillOpacity(FILL_OPACITY)), "road-street"); + + loadedStyle.addLayer(new LineLayer(LINE_LAYER_ID, LINE_SOURCE_ID).withProperties( + lineColor(RED_COLOR), + lineWidth(LINE_WIDTH), + lineCap(Property.LINE_CAP_ROUND), + lineJoin(Property.LINE_JOIN_ROUND) + )); + } + }); + } + + private static class LoadGeoJson extends AsyncTask> { + + private WeakReference weakReference; + + LoadGeoJson(RevealedPolygonHoleOutlineActivity activity) { + this.weakReference = new WeakReference<>(activity); + } + + @Override + protected List doInBackground(Void... voids) { + try { + RevealedPolygonHoleOutlineActivity activity = weakReference.get(); + if (activity != null) { + InputStream inputStream = activity.getAssets().open("downtown_san_jose_hole.geojson"); + Feature holePolygonFeature = Feature.fromJson(convertStreamToString(inputStream)); + return TurfMeta.coordAll((Polygon) holePolygonFeature.geometry(), false); + } + } catch (Exception exception) { + Timber.e("Exception Loading GeoJSON: %s", exception.toString()); + } + return null; + } + + static String convertStreamToString(InputStream is) { + Scanner scanner = new Scanner(is).useDelimiter("\\A"); + return scanner.hasNext() ? scanner.next() : ""; + } + + @Override + protected void onPostExecute(@Nullable List pointList) { + super.onPostExecute(pointList); + RevealedPolygonHoleOutlineActivity activity = weakReference.get(); + if (activity != null && pointList != null) { + activity.addStyling(pointList); + } + } + } + + @Override + protected void onStart() { + super.onStart(); + mapView.onStart(); + } + + @Override + protected void onResume() { + super.onResume(); + mapView.onResume(); + } + + @Override + protected void onPause() { + super.onPause(); + mapView.onPause(); + } + + @Override + protected void onStop() { + super.onStop(); + mapView.onStop(); + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mapView.onDestroy(); + } + + @Override + public void onLowMemory() { + super.onLowMemory(); + mapView.onLowMemory(); + } +} \ No newline at end of file diff --git a/MapboxAndroidDemo/src/main/res/layout/activity_polygon_holes_outline_revealed.xml b/MapboxAndroidDemo/src/main/res/layout/activity_polygon_holes_outline_revealed.xml new file mode 100644 index 000000000..70f9b3d6b --- /dev/null +++ b/MapboxAndroidDemo/src/main/res/layout/activity_polygon_holes_outline_revealed.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/MapboxAndroidDemo/src/main/res/values/descriptions_strings.xml b/MapboxAndroidDemo/src/main/res/values/descriptions_strings.xml index 0cea9a06a..295757756 100644 --- a/MapboxAndroidDemo/src/main/res/values/descriptions_strings.xml +++ b/MapboxAndroidDemo/src/main/res/values/descriptions_strings.xml @@ -58,11 +58,11 @@ Change SymbolLayer icons based on the camera\'s zoom level. Create a default marker with an InfoWindow. Draw a polyline by parsing a GeoJSON file with the Mapbox Maps SDK. + Tap on various polygons to "select" them and toggle their colors. Draw a vector polygon on a map with the Mapbox Maps SDK. Draw a vector polygon with holes on a map using the Mapbox Maps SDK. Allow or deny text and icons to overlap and collide. - - + Outline a polygon hole to highlight a revealed region. Adjust the color, size, and fonts of SymbolLayer text fields. Attach a view to a given position on the map. Use an info window adapter to customize the info window. @@ -120,7 +120,6 @@ Combine two maps for a magic window effect Add a gradient on top of a MapView to show a background fog effect. Use Android system interpolators to animate SymbolLayer icons movement. - Tap on various polygons to "select" them and toggle their colors. Show an accurate and government-approved China map in your app using the Mapbox Maps SDK. Show the device\'s current location or other information in a homescreen widget. Use Turf to calculate coordinates to eventually draw a ring around a center coordinate. diff --git a/MapboxAndroidDemo/src/main/res/values/titles_strings.xml b/MapboxAndroidDemo/src/main/res/values/titles_strings.xml index f6924ab35..46a1518aa 100644 --- a/MapboxAndroidDemo/src/main/res/values/titles_strings.xml +++ b/MapboxAndroidDemo/src/main/res/values/titles_strings.xml @@ -61,6 +61,7 @@ Draw a polygon Draw a polygon with holes Toggle collision detection + Outlined polygon hole Adjust text labels Draw a marker view Custom info window diff --git a/MapboxAndroidDemo/src/main/res/values/urls_strings.xml b/MapboxAndroidDemo/src/main/res/values/urls_strings.xml index a8c5e406b..9d1c4efc0 100644 --- a/MapboxAndroidDemo/src/main/res/values/urls_strings.xml +++ b/MapboxAndroidDemo/src/main/res/values/urls_strings.xml @@ -55,14 +55,16 @@ https://imgur.com/YiBeH0I.png https://i.imgur.com/tfbO1m4.png https://i.imgur.com/sbWU4Ui.png - http://i.imgur.com/X59UoaY.png + https://i.imgur.com/gVIfE3G.png https://i.imgur.com/Bs0X98z.png http://i.imgur.com/v9X28id.png https://i.imgur.com/6hcqbNw.png https://i.imgur.com/nV1YnIv.png + http://i.imgur.com/19GZh8H.jpg https://i.imgur.com/MSoIYmU.png http://i.imgur.com/vbWTLIE.png http://i.imgur.com/mCWbosy.png + http://i.imgur.com/X59UoaY.png http://i.imgur.com/PN3vyNJ.jpg http://i.imgur.com/A0JL21Q.png http://i.imgur.com/A227BEs.jpg @@ -118,8 +120,7 @@ https://i.imgur.com/Nw78ZrV.png https://i.imgur.com/NcSGgD8.png https://i.imgur.com/JfLf69C.png - https://i.imgur.com/gVIfE3G.png - https://i.imgur.com/KwoEynZ.png https://i.imgur.com/H5N9jDn.png https://i.imgur.com/nG8xeXH.png + https://i.imgur.com/KwoEynZ.png