From bb089a4eb177c4b87be173eff2b011785451cdb1 Mon Sep 17 00:00:00 2001 From: ZhanGSKen Date: Mon, 24 Feb 2025 08:06:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E5=90=88SDK=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 32 +- gradle.properties | 2 + positions/.DS_Store | Bin 0 -> 6148 bytes positions/app_update_description.txt | 1 - positions/build.gradle | 61 ++- positions/build.properties | 4 +- positions/proguard-rules.pro | 36 +- positions/src/.DS_Store | Bin 0 -> 6148 bytes positions/src/main/.DS_Store | Bin 0 -> 6148 bytes positions/src/main/AndroidManifest.xml | 92 +---- positions/src/main/java/.DS_Store | Bin 0 -> 6148 bytes .../studio/positions/MainActivity.java | 6 +- ...ain2Activity.java => GridMapActivity.java} | 4 +- .../positions/activities/MapViewActivity.java | 83 ---- .../studio/positions/demo/AbsMapActivity.java | 54 --- .../demo/basic/IndoorMapActivity.java | 214 ---------- .../demo/basic/MapStyleDemoActivity.java | 195 --------- .../demo/basic/OverseaMapActivity.java | 91 ---- .../demo/basic/SetMapTypeActivity.java | 56 --- .../basic/SupportMapFragmentActivity.java | 50 --- .../demo/basic/UiSettingsActivity.java | 86 ---- .../demo/camera/MapAnchorZoomActivity.java | 54 --- .../demo/camera/MapBoundActivity.java | 54 --- .../demo/camera/MapCameraCenterActivity.java | 54 --- .../positions/demo/circle/ArcActivity.java | 126 ------ .../demo/circle/CircleOptionsActivity.java | 35 -- .../demo/circle/DrawCircleActivity.java | 24 -- .../demo/gesture/GestureSettingsActivity.java | 80 ---- .../gesture/MapGestureListenActivity.java | 133 ------ .../demo/gesture/MapListenActivity.java | 30 -- .../demo/gesture/MapLongClickActivity.java | 63 --- .../AggregationOverlayActivity.java | 197 --------- .../heatoverlay/ArcLineLayerActivity.java | 182 -------- .../heatoverlay/DrawHeatOverlayActivity.java | 131 ------ .../demo/heatoverlay/GLModelActivity.java | 166 -------- .../HeatMapVectorOverlayActivity.java | 171 -------- .../ScatterPlotOverlayActivity.java | 180 -------- .../heatoverlay/TrailOverlayActivity.java | 147 ------- .../heatoverlay/VectorHeatMapActivity.java | 182 -------- .../demo/location/LocationLayerActivity.java | 252 ------------ .../demo/location/LocationPointActivity.java | 216 ---------- .../demo/marker/CustomRenderActivity.java | 281 ------------- .../demo/marker/GroundOverlayActivity.java | 129 ------ .../positions/demo/marker/MarkerActivity.java | 74 ---- .../demo/marker/MarkerAnimation.java | 235 ----------- .../demo/marker/MarkerClickActivity.java | 25 -- .../demo/marker/MarkerClusterActivity.java | 387 ------------------ .../demo/marker/MarkerCollisions.java | 116 ------ .../demo/marker/MarkerDragActivity.java | 58 --- .../demo/marker/MarkerInfoWindowActivity.java | 254 ------------ .../demo/marker/MarkerOptionsActivity.java | 54 --- .../demo/marker/SimpleMarkerActivity.java | 107 ----- .../positions/demo/poi/PoiClickActivity.java | 64 --- .../demo/polygon/DrawPolygonActivity.java | 38 -- .../demo/polygon/PolylonOptionsActivity.java | 73 ---- .../demo/polygon/TileOverlayActivity.java | 178 -------- .../demo/polyline/DrawLineActivity.java | 194 --------- .../demo/polyline/LineTextActivity.java | 132 ------ .../polyline/MutablePolylineActivity.java | 291 ------------- .../polyline/PolylineOptionsActivity.java | 87 ---- .../demo/search/DistrictActivity.java | 174 -------- .../demo/search/DrivingRouteActivity.java | 75 ---- .../demo/search/GeoCoderActivity.java | 186 --------- .../demo/search/SearchBasicActivity.java | 305 -------------- .../demo/search/TransitRouteActivity.java | 93 ----- .../demo/search/TruckingRouteActivity.java | 77 ---- .../demo/search/WalkingRouteActivity.java | 76 ---- .../demo/smooth/SmoothMoveActivity.java | 257 ------------ .../transaction/AnimateCameraActivity.java | 66 --- .../demo/transaction/MoveCameraActivity.java | 66 --- .../demo/transaction/RotateMapActivity.java | 28 -- .../demo/transaction/ScollMapActivity.java | 87 ---- .../transaction/ZoomCalulateActivity.java | 73 ---- .../demo/transaction/ZoomMapActivity.java | 47 --- .../demo/utils/CoordinateActivity.java | 57 --- .../demo/utils/SnapshotActivity.java | 135 ------ positions/src/main/java/com/.DS_Store | Bin 0 -> 6148 bytes positions/src/main/java/com/tencent/.DS_Store | Bin 0 -> 6148 bytes .../src/main/java/com/tencent/map/.DS_Store | Bin 0 -> 6148 bytes .../java/com/tencent/map/vector/.DS_Store | Bin 0 -> 6148 bytes .../com/tencent/map/vector/demo/.DS_Store | Bin 0 -> 6148 bytes .../tencent/map/vector}/demo/AbsActivity.java | 4 +- .../map/vector}/demo/AbsListActivity.java | 5 +- .../map/vector/demo/AbsMapActivity.java | 53 +++ .../map/vector/demo/DemoMainActivity.java} | 12 +- .../vector}/demo/basic/IndoorFloorView.java | 2 +- .../vector/demo/basic/IndoorMapActivity.java | 198 +++++++++ .../demo/basic/MapRenderLayerActivity.java | 2 +- .../demo/basic/MapStyleDemoActivity.java | 195 +++++++++ .../vector}/demo/basic/MapViewActivity.java | 4 +- .../demo/basic/OfflineMapActivity.java | 2 +- .../vector/demo/basic/OverseaMapActivity.java | 91 ++++ .../demo/basic/RecyclerListActivity.java | 2 +- .../vector/demo/basic/SetMapTypeActivity.java | 51 +++ .../basic/SupportMapFragmentActivity.java | 50 +++ .../vector/demo/basic/UiSettingsActivity.java | 86 ++++ .../demo/camera/MapAnchorZoomActivity.java | 54 +++ .../vector/demo/camera/MapBoundActivity.java | 54 +++ .../demo/camera/MapCameraCenterActivity.java | 54 +++ .../map/vector/demo/circle/ArcActivity.java | 126 ++++++ .../demo/circle/CircleOptionsActivity.java | 35 ++ .../demo/circle/DrawCircleActivity.java | 24 ++ .../demo/gesture/GestureSettingsActivity.java | 80 ++++ .../gesture/MapGestureListenActivity.java | 82 ++++ .../demo/gesture/MapListenActivity.java | 30 ++ .../demo/gesture/MapLongClickActivity.java | 63 +++ .../AggregationOverlayActivity.java | 197 +++++++++ .../heatoverlay/ArcLineLayerActivity.java | 182 ++++++++ .../heatoverlay/DrawHeatOverlayActivity.java | 126 ++++++ .../DrawOldVersionHeatOverlayActivity.java | 4 +- .../demo/heatoverlay/GLModelActivity.java | 166 ++++++++ .../HeatMapVectorOverlayActivity.java | 171 ++++++++ .../ScatterPlotOverlayActivity.java | 180 ++++++++ .../heatoverlay/TrailOverlayActivity.java | 147 +++++++ .../heatoverlay/VectorHeatMapActivity.java | 182 ++++++++ .../demo/location/LocationLayerActivity.java | 251 ++++++++++++ .../demo/location/LocationPointActivity.java | 190 +++++++++ .../vector}/demo/marker/AoiLayerActivity.java | 2 +- .../demo/marker/CustomRenderActivity.java | 281 +++++++++++++ .../demo/marker/GroundOverlayActivity.java | 129 ++++++ .../vector/demo/marker/MarkerActivity.java | 74 ++++ .../vector/demo/marker/MarkerAnimation.java | 235 +++++++++++ .../demo/marker/MarkerClickActivity.java | 25 ++ .../demo/marker/MarkerClusterActivity.java | 387 ++++++++++++++++++ .../vector/demo/marker/MarkerCollisions.java | 116 ++++++ .../demo/marker/MarkerDragActivity.java | 45 ++ .../demo/marker/MarkerInfoWindowActivity.java | 254 ++++++++++++ .../demo/marker/MarkerOptionsActivity.java | 54 +++ .../vector}/demo/marker/PetalDrawable.java | 2 +- .../demo/marker/SimpleMarkerActivity.java | 107 +++++ .../map/vector/demo/poi/PoiClickActivity.java | 59 +++ .../demo/polygon/DrawPolygonActivity.java | 38 ++ .../demo/polygon/PolylonOptionsActivity.java | 73 ++++ .../demo/polygon/TileOverlayActivity.java | 178 ++++++++ .../demo/polyline/DrawLineActivity.java | 194 +++++++++ .../demo/polyline/LineTextActivity.java | 132 ++++++ .../polyline/MutablePolylineActivity.java | 291 +++++++++++++ .../polyline/PolylineOptionsActivity.java | 87 ++++ .../search/CoordianteTransferActivity.java | 4 +- .../vector/demo/search/DistrictActivity.java | 174 ++++++++ .../demo/search/DrivingRouteActivity.java | 75 ++++ .../vector/demo/search/GeoCoderActivity.java | 186 +++++++++ .../demo/search/SearchBasicActivity.java | 305 ++++++++++++++ .../demo/search/TransitRouteActivity.java | 93 +++++ .../demo/search/TruckingRouteActivity.java | 77 ++++ .../demo/search/WalkingRouteActivity.java | 76 ++++ .../demo/smooth/SmoothMoveActivity.java | 251 ++++++++++++ .../transaction/AnimateCameraActivity.java | 61 +++ .../demo/transaction/MoveCameraActivity.java | 61 +++ .../demo/transaction/RotateMapActivity.java | 28 ++ .../demo/transaction/ScollMapActivity.java | 82 ++++ .../transaction/ZoomCalulateActivity.java | 73 ++++ .../demo/transaction/ZoomMapActivity.java | 47 +++ .../vector}/demo/utils/BitMapActivity.java | 4 +- .../vector/demo/utils/CoordinateActivity.java | 57 +++ .../vector/demo/utils/SnapshotActivity.java | 135 ++++++ .../src/main/res/drawable/ic_launcher.xml | 11 - .../main/res/drawable/ic_launcher_disable.xml | 11 - .../res/drawable/ic_launcher_foreground.xml | 10 - .../ic_launcher_foreground_disable.xml | 10 - .../src/main/res/drawable/shape_gradient.xml | 10 - positions/src/main/res/drawable/taxi.png | Bin 0 -> 4150 bytes ...ty_main_demo.xml => activity_demomain.xml} | 0 ...ctivity_main2.xml => activity_gridmap.xml} | 0 .../src/main/res/layout/activity_indoor.xml | 4 +- .../src/main/res/layout/activity_location.xml | 23 -- .../src/main/res/layout/activity_mapview.xml | 14 - positions/src/main/res/menu/toolbar_main.xml | 7 +- positions/src/main/res/values/attrs.xml | 12 - positions/src/main/res/values/colors.xml | 7 +- positions/src/main/res/values/strings.xml | 5 +- positions/src/main/res/values/styles.xml | 1 - .../src/main/res/xml/studio_provider.xml | 25 -- 173 files changed, 7804 insertions(+), 8176 deletions(-) create mode 100644 positions/.DS_Store create mode 100644 positions/src/.DS_Store create mode 100644 positions/src/main/.DS_Store create mode 100644 positions/src/main/java/.DS_Store rename positions/src/main/java/cc/winboll/studio/positions/activities/{Main2Activity.java => GridMapActivity.java} (91%) delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/activities/MapViewActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/AbsMapActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/basic/IndoorMapActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/basic/MapStyleDemoActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/basic/OverseaMapActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/basic/SetMapTypeActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/basic/SupportMapFragmentActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/basic/UiSettingsActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/camera/MapAnchorZoomActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/camera/MapBoundActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/camera/MapCameraCenterActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/circle/ArcActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/circle/CircleOptionsActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/circle/DrawCircleActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/gesture/GestureSettingsActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/gesture/MapGestureListenActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/gesture/MapListenActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/gesture/MapLongClickActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/AggregationOverlayActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/ArcLineLayerActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/DrawHeatOverlayActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/GLModelActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/HeatMapVectorOverlayActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/ScatterPlotOverlayActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/TrailOverlayActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/VectorHeatMapActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/location/LocationLayerActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/location/LocationPointActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/marker/CustomRenderActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/marker/GroundOverlayActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerAnimation.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerClickActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerClusterActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerCollisions.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerDragActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerInfoWindowActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerOptionsActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/marker/SimpleMarkerActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/poi/PoiClickActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/polygon/DrawPolygonActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/polygon/PolylonOptionsActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/polygon/TileOverlayActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/polyline/DrawLineActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/polyline/LineTextActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/polyline/MutablePolylineActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/polyline/PolylineOptionsActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/search/DistrictActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/search/DrivingRouteActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/search/GeoCoderActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/search/SearchBasicActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/search/TransitRouteActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/search/TruckingRouteActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/search/WalkingRouteActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/smooth/SmoothMoveActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/transaction/AnimateCameraActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/transaction/MoveCameraActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/transaction/RotateMapActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/transaction/ScollMapActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/transaction/ZoomCalulateActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/transaction/ZoomMapActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/utils/CoordinateActivity.java delete mode 100644 positions/src/main/java/cc/winboll/studio/positions/demo/utils/SnapshotActivity.java create mode 100644 positions/src/main/java/com/.DS_Store create mode 100644 positions/src/main/java/com/tencent/.DS_Store create mode 100644 positions/src/main/java/com/tencent/map/.DS_Store create mode 100644 positions/src/main/java/com/tencent/map/vector/.DS_Store create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/.DS_Store rename positions/src/main/java/{cc/winboll/studio/positions => com/tencent/map/vector}/demo/AbsActivity.java (94%) rename positions/src/main/java/{cc/winboll/studio/positions => com/tencent/map/vector}/demo/AbsListActivity.java (96%) create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/AbsMapActivity.java rename positions/src/main/java/{cc/winboll/studio/positions/demo/MainActivity.java => com/tencent/map/vector/demo/DemoMainActivity.java} (96%) rename positions/src/main/java/{cc/winboll/studio/positions => com/tencent/map/vector}/demo/basic/IndoorFloorView.java (99%) create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/basic/IndoorMapActivity.java rename positions/src/main/java/{cc/winboll/studio/positions => com/tencent/map/vector}/demo/basic/MapRenderLayerActivity.java (95%) create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/basic/MapStyleDemoActivity.java rename positions/src/main/java/{cc/winboll/studio/positions => com/tencent/map/vector}/demo/basic/MapViewActivity.java (93%) rename positions/src/main/java/{cc/winboll/studio/positions => com/tencent/map/vector}/demo/basic/OfflineMapActivity.java (99%) create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/basic/OverseaMapActivity.java rename positions/src/main/java/{cc/winboll/studio/positions => com/tencent/map/vector}/demo/basic/RecyclerListActivity.java (95%) create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/basic/SetMapTypeActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/basic/SupportMapFragmentActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/basic/UiSettingsActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/camera/MapAnchorZoomActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/camera/MapBoundActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/camera/MapCameraCenterActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/circle/ArcActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/circle/CircleOptionsActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/circle/DrawCircleActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/gesture/GestureSettingsActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/gesture/MapGestureListenActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/gesture/MapListenActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/gesture/MapLongClickActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/AggregationOverlayActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/ArcLineLayerActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/DrawHeatOverlayActivity.java rename positions/src/main/java/{cc/winboll/studio/positions => com/tencent/map/vector}/demo/heatoverlay/DrawOldVersionHeatOverlayActivity.java (97%) create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/GLModelActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/HeatMapVectorOverlayActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/ScatterPlotOverlayActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/TrailOverlayActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/VectorHeatMapActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/location/LocationLayerActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/location/LocationPointActivity.java rename positions/src/main/java/{cc/winboll/studio/positions => com/tencent/map/vector}/demo/marker/AoiLayerActivity.java (98%) create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/marker/CustomRenderActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/marker/GroundOverlayActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerAnimation.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerClickActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerClusterActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerCollisions.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerDragActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerInfoWindowActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerOptionsActivity.java rename positions/src/main/java/{cc/winboll/studio/positions => com/tencent/map/vector}/demo/marker/PetalDrawable.java (95%) create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/marker/SimpleMarkerActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/poi/PoiClickActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/polygon/DrawPolygonActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/polygon/PolylonOptionsActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/polygon/TileOverlayActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/polyline/DrawLineActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/polyline/LineTextActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/polyline/MutablePolylineActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/polyline/PolylineOptionsActivity.java rename positions/src/main/java/{cc/winboll/studio/positions => com/tencent/map/vector}/demo/search/CoordianteTransferActivity.java (96%) create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/search/DistrictActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/search/DrivingRouteActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/search/GeoCoderActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/search/SearchBasicActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/search/TransitRouteActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/search/TruckingRouteActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/search/WalkingRouteActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/smooth/SmoothMoveActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/transaction/AnimateCameraActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/transaction/MoveCameraActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/transaction/RotateMapActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/transaction/ScollMapActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/transaction/ZoomCalulateActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/transaction/ZoomMapActivity.java rename positions/src/main/java/{cc/winboll/studio/positions => com/tencent/map/vector}/demo/utils/BitMapActivity.java (91%) create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/utils/CoordinateActivity.java create mode 100644 positions/src/main/java/com/tencent/map/vector/demo/utils/SnapshotActivity.java delete mode 100644 positions/src/main/res/drawable/ic_launcher.xml delete mode 100644 positions/src/main/res/drawable/ic_launcher_disable.xml delete mode 100644 positions/src/main/res/drawable/ic_launcher_foreground.xml delete mode 100644 positions/src/main/res/drawable/ic_launcher_foreground_disable.xml delete mode 100644 positions/src/main/res/drawable/shape_gradient.xml create mode 100644 positions/src/main/res/drawable/taxi.png rename positions/src/main/res/layout/{activity_main_demo.xml => activity_demomain.xml} (100%) rename positions/src/main/res/layout/{activity_main2.xml => activity_gridmap.xml} (100%) delete mode 100644 positions/src/main/res/layout/activity_location.xml delete mode 100644 positions/src/main/res/layout/activity_mapview.xml delete mode 100644 positions/src/main/res/values/attrs.xml delete mode 100644 positions/src/main/res/xml/studio_provider.xml diff --git a/build.gradle b/build.gradle index 757a4b2..8626680 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,21 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { - google() + maven { url 'https://maven.aliyun.com/repository/public/' } + maven { url 'https://maven.aliyun.com/repository/google/' } + maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' } + maven { url 'https://dl.bintray.com/ppartisan/maven/' } + maven { url "https://clojars.org/repo/" } + maven { url "https://jitpack.io" } mavenCentral() + google() + mavenLocal() + // Nexus Maven 库地址 + // "WinBoll Release" + maven { url "https://nexus.winboll.cc/repository/maven-public/" } + // "WinBoll Snapshot" + maven { url "https://nexus.winboll.cc/repository/maven-snapshots/" } + } dependencies { classpath 'com.android.tools.build:gradle:7.2.1' @@ -13,11 +26,12 @@ buildscript { allprojects { repositories { - // Nexus Maven 库地址 - // "WinBoll Release" - maven { url "https://nexus.winboll.cc/repository/maven-public/" } - // "WinBoll Snapshot" - maven { url "https://nexus.winboll.cc/repository/maven-snapshots/" } + maven { + url "https://mirrors.tencent.com/repository/maven/tencent_public/" + } + maven { + url "https://mirrors.tencent.com/repository/maven/tencent_public_snapshots" + } maven { url 'https://maven.aliyun.com/repository/public/' } maven { url 'https://maven.aliyun.com/repository/google/' } @@ -28,6 +42,12 @@ allprojects { mavenCentral() google() mavenLocal() + // Nexus Maven 库地址 + // "WinBoll Release" + maven { url "https://nexus.winboll.cc/repository/maven-public/" } + // "WinBoll Snapshot" + maven { url "https://nexus.winboll.cc/repository/maven-snapshots/" } + } ext { // 定义全局变量,常用于版本管理 diff --git a/gradle.properties b/gradle.properties index 88d5f12..d12a593 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,3 +22,5 @@ android.enableJetifier=true android.disableAutomaticComponentCreation=true +android.injected.testOnly=false + diff --git a/positions/.DS_Store b/positions/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..9a874b5768f336915163bb88cd434575b859f936 GIT binary patch literal 6148 zcmeH~Jr2S!425ml0g0s}V-^m;4I%_5-~tF3k&vj^b9A16778<}(6eNJu~Vz<8=6`~ zboab&MFtUB!i}=AFfm2m$tVxGT*u4pe81nUlA49C} z?O@64YO)2RT{MRe%{!}2F))pG(Sih~)xkgosK7*lF7m<7{{#Hn{6A@7N(HFEpDCdI z{fZf}$aT{c$0#twsd@EqzhXOa&WDEMI1HnfCa6s7&Yo8^+Vg;}!TM!kPMk^St z>SKu2y&Wuht|nVB+C_8t(0sDm6a&*}7cEF&S{)2jfC_X9JVid){eOi2Hve}mOsN1B zcrXQYIJ_KYyj0$;cduvl*R0yQ!9hQc@Z%={iCx7zxEuD1Ex?*=K~!M;5pWq8sKB2p F@C6gX5~u(G literal 0 HcmV?d00001 diff --git a/positions/src/main/.DS_Store b/positions/src/main/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d38176301af6a9db8e9ffa5dc7916732489a254b GIT binary patch literal 6148 zcmeH~JqiLr422WjLa^D=avBfd4F=H@cme+^5iCUOIl3=D2(H#5@&d^>$xK-G6+0Ud z(dF&95a~r^0yoOs!oU=HCnwp-U3SOo;k>_G&Ut2(v@`Ht2K%{9Pys4H1*iZOpaMUn zfZf}$$u!7F1*iZOcq(AuhXOa&WDEMI1HnfCutV7mYo8^+Vg;}!TM!kPMk^St>SKu2 zy&Wuht|nVB+C_8t(0sDm6a&*}7cEF&S{)2jfC>y07)RdQ{lA8Pn*RqaOsN1B_%j8x zTWwZLyj0$;Z?9+dZB}jF;GiEzc=-uHVps7D?uPwh3$P|z5EU4I1Y8CND)3bW9?Vn{ Ar2qf` literal 0 HcmV?d00001 diff --git a/positions/src/main/AndroidManifest.xml b/positions/src/main/AndroidManifest.xml index 90fc902..454b7d4 100644 --- a/positions/src/main/AndroidManifest.xml +++ b/positions/src/main/AndroidManifest.xml @@ -1,20 +1,14 @@ - - + - - - - - - - - + + + + - - + @@ -23,83 +17,30 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - + android:value="SCYBZ-EC5Y4-XMHUI-FX2PU-ZYMMS-IBB7P" /> diff --git a/positions/src/main/java/.DS_Store b/positions/src/main/java/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..35a54bf0595027f28217af82c3d32981e121b5e7 GIT binary patch literal 6148 zcmeH~Jr2S!425mVP>H1@V-^m;4I%_5-~tF3K^+i#j?VMXLSaS~dY0@jc51bKLsN^0 z?w;4J$RHv;+$b9h6I0}!Tx68{^>MkK$MI$*w?)zl@IfZ~xlK?3DnJFO02QDDGg2TA z@_sd=XX2w!0V*&L1?>A!;KrJ4LH~3h_y_tMAK>5S|49o|DnJGPOaWc) zkNX{7D$mxB*R%R5tF~@%&@V@L`w2i|NAVi&hW%m-uqIm&6&Qa6Tm}Xz@KXg|*oF~o literal 0 HcmV?d00001 diff --git a/positions/src/main/java/cc/winboll/studio/positions/MainActivity.java b/positions/src/main/java/cc/winboll/studio/positions/MainActivity.java index 1fc14b1..99ba61d 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/MainActivity.java +++ b/positions/src/main/java/cc/winboll/studio/positions/MainActivity.java @@ -25,7 +25,7 @@ import cc.winboll.studio.libapputils.app.WinBollActivityManager; import cc.winboll.studio.libapputils.bean.APPInfo; import cc.winboll.studio.libapputils.view.YesNoAlertDialog; import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.activities.MapViewActivity; +import com.tencent.map.vector.demo.DemoMainActivity; import cc.winboll.studio.positions.activities.SettingsActivity; import cc.winboll.studio.positions.adapters.MyPagerAdapter; import cc.winboll.studio.positions.beans.MainServiceBean; @@ -321,8 +321,8 @@ final public class MainActivity extends AppCompatActivity implements IWinBollAct Intent intent = new Intent(this, SettingsActivity.class); startActivity(intent); //WinBollActivityManager.getInstance(this).startWinBollActivity(this, CallActivity.class); - } else if (item.getItemId() == R.id.item_location) { - Intent intent = new Intent(this, MapViewActivity.class); + } else if (item.getItemId() == R.id.item_demomain) { + Intent intent = new Intent(this, com.tencent.map.vector.demo.DemoMainActivity.class); startActivity(intent); //WinBollActivityManager.getInstance(this).startWinBollActivity(this, CallActivity.class); } diff --git a/positions/src/main/java/cc/winboll/studio/positions/activities/Main2Activity.java b/positions/src/main/java/cc/winboll/studio/positions/activities/GridMapActivity.java similarity index 91% rename from positions/src/main/java/cc/winboll/studio/positions/activities/Main2Activity.java rename to positions/src/main/java/cc/winboll/studio/positions/activities/GridMapActivity.java index d4556a2..704d2d9 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/activities/Main2Activity.java +++ b/positions/src/main/java/cc/winboll/studio/positions/activities/GridMapActivity.java @@ -14,14 +14,14 @@ import cc.winboll.studio.positions.views.GridMapView; import android.view.View.OnClickListener; import android.view.View; -public class Main2Activity extends AppCompatActivity { +public class GridMapActivity extends AppCompatActivity { GridMapView gridMap; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main2); + setContentView(R.layout.activity_gridmap); // 初始化视图 GridMapView mapView = (GridMapView) findViewById(R.id.map_view); diff --git a/positions/src/main/java/cc/winboll/studio/positions/activities/MapViewActivity.java b/positions/src/main/java/cc/winboll/studio/positions/activities/MapViewActivity.java deleted file mode 100644 index 692159c..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/activities/MapViewActivity.java +++ /dev/null @@ -1,83 +0,0 @@ -package cc.winboll.studio.positions.activities; - -/** - * @Author ZhanGSKen@AliYun.Com - * @Date 2025/02/24 03:07:45 - */ -import cc.winboll.studio.positions.R; -import androidx.appcompat.app.AppCompatActivity; - -import android.content.Intent; -import android.os.Bundle; -import android.util.Log; -import android.view.View; - -import cc.winboll.studio.positions.demo.heatoverlay.ScatterPlotOverlayActivity; -import com.tencent.tencentmap.mapsdk.maps.MapView; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.TencentMapOptions; -import com.tencent.tencentmap.mapsdk.maps.TextureMapView; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; - -public class MapViewActivity extends AppCompatActivity { - - /** - * 由于SDK并没有提供用于MapView管理地图生命周期的Activity - * 因此需要用户继承Activity后管理地图的生命周期,防止内存泄露 - */ - - private TextureMapView mapView; - protected TencentMap tencentMap; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_map_view); - - mapView = findViewById(R.id.mapview); - mapView.setOpaque(false); - //创建tencentMap地图对象,可以完成对地图的几乎所有操作 - tencentMap = mapView.getMap(); - - } - - - /** - * mapview的生命周期管理 - */ - @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 onDestroy() { - super.onDestroy(); - mapView.onDestroy(); - } - - @Override - protected void onRestart() { - super.onRestart(); - mapView.onRestart(); - } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/AbsMapActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/AbsMapActivity.java deleted file mode 100644 index 30db981..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/AbsMapActivity.java +++ /dev/null @@ -1,54 +0,0 @@ -package cc.winboll.studio.positions.demo; - -import cc.winboll.studio.positions.R; -import android.os.Bundle; -import androidx.annotation.Nullable; -import androidx.fragment.app.FragmentManager; -import android.view.Menu; -import android.view.MenuItem; - -import com.tencent.tencentmap.mapsdk.maps.SupportMapFragment; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; - -public abstract class AbsMapActivity extends AbsActivity { - -// private TencentMap mTencentMap; -// -// protected int getLayoutId() { -// return R.layout.activity_map_container; -// } -// -// @Override -// protected final void onCreate(@Nullable Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// setContentView(getLayoutId()); -// -// FragmentManager manager = getSupportFragmentManager(); -// SupportMapFragment fragment = (SupportMapFragment) manager.findFragmentById(R.id.fragment_map); -// if (fragment != null) { -// mTencentMap = fragment.getMap(); -// } -// -// onCreate(savedInstanceState, mTencentMap); -// } -// -// protected boolean checkMapInvalid() { -// return mTencentMap == null || mTencentMap.isDestroyed(); -// } -// -// protected void onCreate(@Nullable Bundle savedInstanceState, TencentMap tencentMap) { -// -// } -// -// @Override -// public boolean onPrepareOptionsMenu(Menu menu) { -// supportInvalidateOptionsMenu(); -// return super.onPrepareOptionsMenu(menu); -// } -// -// @Override -// public boolean onOptionsItemSelected(MenuItem item) { -// supportInvalidateOptionsMenu(); -// return super.onOptionsItemSelected(item); -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/IndoorMapActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/basic/IndoorMapActivity.java deleted file mode 100644 index 3a1dfc3..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/IndoorMapActivity.java +++ /dev/null @@ -1,214 +0,0 @@ -package cc.winboll.studio.positions.demo.basic; - -import android.os.Bundle; -import android.os.Handler; -import android.text.TextUtils; -import android.util.Log; - -import androidx.appcompat.app.AppCompatActivity; - -import cc.winboll.studio.positions.R; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.MapView; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.UiSettings; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.IndoorBuilding; -import com.tencent.tencentmap.mapsdk.maps.model.IndoorInfo; -import com.tencent.tencentmap.mapsdk.maps.model.IndoorLevel; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.MapPoi; -import com.tencent.tencentmap.mapsdk.maps.model.Marker; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; -import com.tencent.tencentmap.mapsdk.vector.utils.clustering.ClusterItem; -import com.tencent.tencentmap.mapsdk.vector.utils.clustering.ClusterManager; -import com.tencent.tencentmap.mapsdk.vector.utils.clustering.algo.NonHierarchicalDistanceBasedAlgorithm; -import com.tencent.tencentmap.mapsdk.vector.utils.clustering.view.DefaultClusterRenderer; - -import java.util.ArrayList; -import java.util.List; - -public class IndoorMapActivity extends AppCompatActivity implements TencentMap.OnIndoorStateChangeListener { - - @Override - public boolean onIndoorBuildingFocused() { - return false; - } - - @Override - public boolean onIndoorLevelActivated(IndoorBuilding p1) { - return false; - } - - @Override - public boolean onIndoorBuildingDeactivated() { - return false; - } - - -// private static final String TAG = "IndoorMapActivity"; -// private MapView mapView; -// private TencentMap tencentMap; -// private IndoorFloorView indoorFloorView; -// private UiSettings uiSettings; -// private Handler handler = new Handler(); -// private String floorName; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// setContentView(R.layout.activity_indoor); -// mapView = findViewById(R.id.mapView); -// indoorFloorView = findViewById(R.id.indoor_floor); -// if (tencentMap == null) { -// tencentMap = mapView.getMap(); -// } -// //欧美汇室内地图,需Key开通室内地图权限 -// CameraUpdate camera = -// CameraUpdateFactory.newCameraPosition(new CameraPosition( -// new LatLng(39.979382, 116.314106), -// 18, -// 0f, -// 0f)); -// tencentMap.moveCamera(camera); -// final ArrayList markerClusters = new ArrayList<>(); -// -// uiSettings = tencentMap.getUiSettings(); -// tencentMap.setIndoorEnabled(true); -// //设置室内蒙层颜色 sdk版本4.3.5新增接口 -// tencentMap.setIndoorMaskColor(R.color.color_C71585); -// //设置室内图状态变化监听 -// tencentMap.setOnIndoorStateChangeListener(this); -// tencentMap.setMapType(TencentMap.MAP_TYPE_DARK); -// //设置是否隐藏楼层控件 -// uiSettings.setIndoorLevelPickerEnabled(false); -// indoorFloorView.setOnIndoorFloorListener(new MyIndoorViewAdapter()); -// ClusterManager markerClusterClusterManager = new ClusterManager(this, tencentMap); -// NonHierarchicalDistanceBasedAlgorithm nba = new NonHierarchicalDistanceBasedAlgorithm<>(this); -// nba.setMaxDistanceAtZoom(15); -// markerClusterClusterManager.setAlgorithm(nba); -// DefaultClusterRenderer renderer = new DefaultClusterRenderer<>(this, tencentMap, markerClusterClusterManager); -// renderer.setMinClusterSize(2); -// renderer.setBuckets(new int[]{5, 10, 20}); -// markerClusterClusterManager.setRenderer(renderer); -// //添加室内图marker -// tencentMap.setOnMapPoiClickListener(new TencentMap.OnMapPoiClickListener() { -// @Override -// public void onClicked(MapPoi mapPoi) { -// LatLng position = mapPoi.getPosition(); -// MarkerOptions markerOptions = new MarkerOptions().position(position).title(mapPoi.name).infoWindowEnable(true); -// if (!TextUtils.isEmpty("F3")) { -// markerOptions.indoorInfo(new IndoorInfo("11000023805", "F3")); -// -// } -// Marker marker = tencentMap.addMarker(markerOptions); -// LatLng position1 = mapPoi.getPosition(); -// markerClusters.add(new MarkerCluster(position1.getLatitude(), position1.getLongitude())); -// -// } -// }); -// tencentMap.setOnCameraChangeListener(markerClusterClusterManager); -// -// } -// -// @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 onDestroy() { -// super.onDestroy(); -// mapView.onDestroy(); -// } -// -// @Override -// public boolean onIndoorBuildingFocused() { -// Log.d(TAG, "onIndoorBuildingFocused: 室内图场景激活回调"); -// return false; -// } -// -// @Override -// public boolean onIndoorLevelActivated(final IndoorBuilding indoorBuilding) { -// if (indoorBuilding != null) { -// handler.post(new Runnable() { -// @Override -// public void run() { -// indoorFloorView.setVisible(true); -// if (mIndoorBuilding == null || !mIndoorBuilding.getBuidlingId().equals(indoorBuilding.getBuidlingId())) { -// List levels = indoorBuilding.getLevels(); -// String[] activedIndoorFloorNames1 = tencentMap.getActivedIndoorFloorNames(); -// indoorFloorView.setItems(activedIndoorFloorNames1); -// for (int i = 0; i < levels.size(); i++) { -// floorName = levels.get(i).getName(); -// indoorFloorView.setSeletion(floorName); -// } -// } -// mIndoorBuilding = indoorBuilding; -// } -// }); -// } else { -// indoorFloorView.setVisible(false); -// } -// return false; -// } -// -// @Override -// public boolean onIndoorBuildingDeactivated() { -// Log.d(TAG, "onIndoorBuildingDeactivated: 当前室内图处于无效状态"); -// return false; -// } -// -// IndoorBuilding mIndoorBuilding = null; -// -// private class MyIndoorViewAdapter implements IndoorFloorView.OnIndoorFloorListener { -// -// @Override -// public void onSelected(int selectedIndex) { -// if (mIndoorBuilding != null) { -// -// List levels = mIndoorBuilding.getLevels(); -// String activedIndoorFloorName = tencentMap.getActivedIndoorFloorNames()[selectedIndex]; -// String name = levels.get(selectedIndex).getName(); -// name = activedIndoorFloorName; -// String buidlingId = mIndoorBuilding.getBuidlingId(); -// tencentMap.setIndoorFloor(buidlingId, name); -// } -// } -// } -//} -// -//class MarkerCluster implements ClusterItem { -// -// private final LatLng latLng; -// -// public MarkerCluster(double lat, double longitude) { -// latLng = new LatLng(lat, longitude); -// } -// -// @Override -// public LatLng getPosition() { -// -// return latLng; -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/MapStyleDemoActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/basic/MapStyleDemoActivity.java deleted file mode 100644 index 94bed56..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/MapStyleDemoActivity.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cc.winboll.studio.positions.demo.basic; - -//import android.annotation.SuppressLint; -//import android.graphics.PorterDuff; -//import android.os.Bundle; -//import android.util.Log; -//import android.view.View; -//import android.widget.AdapterView; -//import android.widget.ArrayAdapter; -//import android.widget.CompoundButton; -//import android.widget.RadioGroup; -//import android.widget.Spinner; -//import android.widget.Switch; -//import android.widget.TextView; -// -// -//import androidx.fragment.app.FragmentActivity; -// -//import cc.winboll.studio.positions.R; -//import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; -//import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -//import com.tencent.tencentmap.mapsdk.maps.MapView; -//import com.tencent.tencentmap.mapsdk.maps.TencentMap; -//import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -//import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -// -///** -// * Demonstrates the different base layers of a map. -// */ -//@SuppressLint("NewApi") -//public class MapStyleDemoActivity extends FragmentActivity implements TencentMap.OnCameraChangeListener { -// private MapView mMapView; -// private TextView mTextView; -// private TencentMap mTencentMap; -// private Switch mSwitch; -// private Spinner mSpinner; -// -// private String[] styles = new String[]{"style1", "style2", "style3", "style4", "style5", -// "normal", "traffic_navi", "traffic_navi_night", "satellite", "night", "navi", "night", "eagle_day", "eagle_night"}; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// setContentView(R.layout.activity_map_style); -// mMapView = findViewById(R.id.map_view); -// mTextView = findViewById(R.id.tv_level); -// mSwitch=findViewById(R.id.switch_open); -// mTencentMap = mMapView.getMap(); -// CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(39.901268, 116.403854), 11f, 0f, 0f)); -// mTencentMap.moveCamera(cameraUpdate); -// //mTencentMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(39.901268, 116.403854))); //移动地图 -// mTencentMap.setOnCameraChangeListener(this); -// mSpinner = findViewById(R.id.sp_style); -// ArrayAdapter adapter = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_spinner_dropdown_item, styles); -// mSpinner.setAdapter(adapter); -// mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { -// @Override -// public void onItemSelected(AdapterView parent, View view, int position, long id) { -// if (position < 5) { -// mTencentMap.setMapStyle(position + 1); -// } -// switch (position) { -// case 5: -// mTencentMap.setMapStyle(TencentMap.MAP_TYPE_NORMAL); -// break; -// case 6: -// mTencentMap.setMapStyle(TencentMap.MAP_TYPE_TRAFFIC_NAVI); -// break; -// case 7: -// mTencentMap.setMapStyle(TencentMap.MAP_TYPE_TRAFFIC_NIGHT); -// break; -// case 8: -// mTencentMap.setMapStyle(TencentMap.MAP_TYPE_SATELLITE); -// break; -// case 9: -// mTencentMap.setMapStyle(TencentMap.MAP_TYPE_NIGHT); -// break; -// case 10: -// mTencentMap.setMapStyle(TencentMap.MAP_TYPE_NAVI); -// break; -// case 11: -// mTencentMap.setMapStyle(13 + 1000); -// break; -// case 12: -// mTencentMap.setMapStyle(14 + 1000); -// break; -// case 13: -// mTencentMap.setMapStyle(15 + 1000); -// break; -// } -// } -// -// @Override -// public void onNothingSelected(AdapterView parent) { -// -// } -// }); -// -// RadioGroup rg = findViewById(R.id.rg_map_type); -// rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { -// @Override -// public void onCheckedChanged(RadioGroup group, int checkedId) { -// switch (checkedId) { -// case R.id.rb_normal_type: -// if (mTencentMap != null) { -// mTencentMap.setMapType(TencentMap.MAP_TYPE_NORMAL); -// } -// break; -// case R.id.rb_dark_type: -// if (mTencentMap != null) { -// mTencentMap.setMapType(TencentMap.MAP_TYPE_DARK); -// } -// break; -// case R.id.rb_sagellite_type: -// if (mTencentMap != null) { -// mTencentMap.setMapType(TencentMap.MAP_TYPE_SATELLITE); -// } -// break; -// } -// } -// }); -// mTencentMap.getUiSettings().setCompassEnabled(true); -// mTencentMap.getUiSettings().setMyLocationButtonEnabled(true); -// mSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { -// @Override -// public void onCheckedChanged(CompoundButton compoundButton, boolean b) { -// PorterDuff.Mode buttonTintMode = compoundButton.getButtonTintMode(); -// if(b){ -// mTencentMap.setBuildingEnable(true); -// }else{ -// mTencentMap.setBuildingEnable(false); -// } -// } -// }); -// } -// -// @Override -// protected void onResume() { -// super.onResume(); -// mMapView.onResume(); -// } -// -// @Override -// protected void onPause() { -// super.onPause(); -// mMapView.onPause(); -// } -// -// @Override -// protected void onDestroy() { -// super.onDestroy(); -// mMapView.onDestroy(); -// } -// -// -// @Override -// protected void onStart() { -// super.onStart(); -// mMapView.onStart(); -// } -// -// @Override -// protected void onStop() { -// super.onStop(); -// mMapView.onStop(); -// } -// -// @Override -// public void onCameraChange(CameraPosition cameraPosition) { -// Log.i("TAG","地图滑动了"); -// mTextView.setText("当前缩放级别为:" + cameraPosition.zoom); -// } -// -// @Override -// public void onCameraChangeFinished(CameraPosition cameraPosition) { -// Log.i("TAG","地图滑动了"); -// mTextView.setText("当前缩放级别为:" + cameraPosition.zoom); -// } -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/OverseaMapActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/basic/OverseaMapActivity.java deleted file mode 100644 index d947126..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/OverseaMapActivity.java +++ /dev/null @@ -1,91 +0,0 @@ -package cc.winboll.studio.positions.demo.basic; - -//import android.content.res.AssetManager; -//import android.graphics.Bitmap; -//import android.graphics.BitmapFactory; -//import android.os.Bundle; -// -//import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; -//import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -//import com.tencent.tencentmap.mapsdk.maps.TencentMapContext; -//import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -//import com.tencent.tencentmap.mapsdk.maps.model.Language; -//import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -//import com.tencent.tencentmap.mapsdk.maps.model.OverSeaTileProvider; -// -//import java.io.InputStream; -//import java.net.MalformedURLException; -//import java.net.URL; -//import java.util.Locale; -// -//public class OverseaMapActivity extends SupportMapFragmentActivity { -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// //纽约时代广场海外地图,需Key开通海外位置服务权限 -// CameraUpdate cameraSigma = -// CameraUpdateFactory.newCameraPosition(new CameraPosition( -// new LatLng(40.75797, -73.985542), -// 11, -// 0f, -// 0f)); -// //移动地图 -// tencentMap.moveCamera(cameraSigma); -// //设置自定义海外图源 -// tencentMap.setOverSeaTileProvider(new CustomOverSeaTileProvider(tencentMap.getMapContext())); -// } -// -// class CustomOverSeaTileProvider extends OverSeaTileProvider { -// boolean mIsZhLanguage; -// boolean mIsNight; -// -// /** -// * 创建海外图源供应 -// */ -// public CustomOverSeaTileProvider(TencentMapContext context){ -// //设置名称和版本号 -// super("custom", 1, context); -// } -// -// @Override -// public URL getTileUrl(int x, int y, int zoom) { -// String url = "https://xxxx.com/x=%d&y=%d&z=%d&s=%s&l=&s"; -// String formatUrl = String.format(Locale.ENGLISH, url, x, y, zoom, mIsNight ? "dark" : "day", mIsZhLanguage ? "zh" : "en"); -// try { -// return new URL(formatUrl); -// } catch (MalformedURLException e) { -// e.printStackTrace(); -// } -// return null; -// } -// -// @Override -// public boolean onDayNightChange(boolean dayNight) { -// mIsNight = dayNight; -// return true; -// } -// -// public boolean onLanguageChange(Language language) { -// mIsZhLanguage = (language == Language.zh); -// return true; -// } -// -// @Override -// public Bitmap getLogo(boolean isNight) { -// AssetManager assetManager = getAssets(); -// Bitmap iBitmap = null; -// InputStream is = null; -// try { -// is = assetManager.open("logo.png"); -// iBitmap = BitmapFactory.decodeStream(is); -// } catch (Exception e) { -// return null; -// } catch (OutOfMemoryError ignored) { -// } finally { -// // IO.safeClose(is); -// } -// return iBitmap; -// } -// } -//} -// diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/SetMapTypeActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/basic/SetMapTypeActivity.java deleted file mode 100644 index adc1d62..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/SetMapTypeActivity.java +++ /dev/null @@ -1,56 +0,0 @@ -package cc.winboll.studio.positions.demo.basic; - -import android.os.Bundle; -import android.view.View; -import android.widget.RadioGroup; - -import cc.winboll.studio.positions.R; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; - - -public class SetMapTypeActivity extends SupportMapFragmentActivity implements RadioGroup.OnCheckedChangeListener { - - @Override - public void onCheckedChanged(RadioGroup p1, int p2) { - } - -// private RadioGroup radioGroup; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// initView(); -// } -// -// private void initView() { -// radioGroup = findViewById(R.id.lay_map_type); -// radioGroup.setVisibility(View.VISIBLE); -// radioGroup.setOnCheckedChangeListener(this); -// } -// -// @Override -// public void onCheckedChanged(RadioGroup radioGroup, int i) { -// switch (i) { -// case R.id.btn_normal: //普通地图-默认地图类型 -// tencentMap.setMapType(TencentMap.MAP_TYPE_NORMAL); -// break; -// case R.id.btn_satellite: //卫星地图 -// tencentMap.setMapType(TencentMap.MAP_TYPE_SATELLITE); -// break; -// case R.id.btn_dark: //暗色地图 -// tencentMap.setMapType(TencentMap.MAP_TYPE_DARK); -// break; -// case R.id.btn_traffic: -// tencentMap.setTrafficEnabled(true); -// break; -// case R.id.style_map: -// /*TencentMapOptions mapOptions = new TencentMapOptions(); -// //将本地资源打包到apk的asset目录中 -// mapOptions.setCustomAssetsPath("myMapStyle"); -// //参数1对应的是“我的样式”中的序号 -// tencentMap.setMapStyle(1); -// MapView mMapView = new MapView(SetMapTypeActivity.this, mapOptions);*/ -// break; -// } -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/SupportMapFragmentActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/basic/SupportMapFragmentActivity.java deleted file mode 100644 index 313a82d..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/SupportMapFragmentActivity.java +++ /dev/null @@ -1,50 +0,0 @@ -package cc.winboll.studio.positions.demo.basic; - -import androidx.appcompat.app.AppCompatActivity; - -import android.os.Bundle; - -import androidx.fragment.app.FragmentManager; - -import cc.winboll.studio.positions.R; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.SupportMapFragment; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.UiSettings; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; - -public class SupportMapFragmentActivity extends AppCompatActivity { -// -// /** -// * SDK提供了SupportMapFragment这个类来加载地图,这个类的方便之处就在于不用手动管理内存 -// */ -// -// private FragmentManager fm; -// protected TencentMap tencentMap; -// private SupportMapFragment supportMapFragment; -// protected UiSettings mapUiSettings; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// setContentView(R.layout.activity_support_map_fragment); -// -// //创建tencentMap地图对象,可以完成对地图的几乎所有操作 -// fm = getSupportFragmentManager(); -// supportMapFragment = (SupportMapFragment) fm.findFragmentById(R.id.map_frag); -// tencentMap = supportMapFragment.getMap(); -// mapUiSettings = tencentMap.getUiSettings(); -// //对地图操作类进行操作 -// CameraUpdate cameraSigma = -// CameraUpdateFactory.newCameraPosition(new CameraPosition( -// new LatLng(39.984066, 116.307548), -// 15, -// 0f, -// 0f)); -// //移动地图 -// tencentMap.moveCamera(cameraSigma); -// -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/UiSettingsActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/basic/UiSettingsActivity.java deleted file mode 100644 index 416ecfd..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/UiSettingsActivity.java +++ /dev/null @@ -1,86 +0,0 @@ -package cc.winboll.studio.positions.demo.basic; - -import android.os.Bundle; -import android.view.View; -import android.widget.CompoundButton; -import android.widget.Switch; - -import cc.winboll.studio.positions.R; -import com.tencent.tencentmap.mapsdk.maps.TencentMapOptions; - -public class UiSettingsActivity extends SupportMapFragmentActivity { - - -// private Switch logoControl; -// private Switch compassControl; -// private Switch scaleViewControl; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// -// super.onCreate(savedInstanceState); -// initView(); -// } -// private void initView(){ -// -// logoControl = findViewById(R.id.switch_logo); -// compassControl = findViewById(R.id.switch_compass); -// scaleViewControl = findViewById(R.id.switch_scale_view); -// logoControl.setVisibility(View.VISIBLE); -// logoControl.setText("logo位置"); -// compassControl.setVisibility(View.VISIBLE); -// compassControl.setText("指南针"); -// scaleViewControl.setVisibility(View.VISIBLE); -// scaleViewControl.setText("比例尺"); -// -// //打开缩放 -// mapUiSettings.setZoomControlsEnabled(true); -// //打开位置标志 -// mapUiSettings.setMyLocationButtonEnabled(true); -// -// -// logoControl.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { -// @Override -// public void onCheckedChanged(CompoundButton compoundButton, boolean b) { -// if (b){ -// //logo左下角 -// mapUiSettings.setLogoPosition(TencentMapOptions.LOGO_POSITION_BOTTOM_LEFT); -// }else{ -// //logo右上角 -// mapUiSettings.setLogoPosition(TencentMapOptions.LOGO_POSITION_TOP_RIGHT); -// } -// -// } -// }); -// -// compassControl.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { -// @Override -// public void onCheckedChanged(CompoundButton compoundButton, boolean b) { -// if (b){ -// //显示指南针 -// mapUiSettings.setCompassEnabled(true); -// }else{ -// //隐藏指南针 -// mapUiSettings.setCompassEnabled(false); -// } -// } -// }); -// -// scaleViewControl.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { -// @Override -// public void onCheckedChanged(CompoundButton compoundButton, boolean b) { -// if (b){ -// //打开比例尺 -// mapUiSettings.setScaleViewEnabled(true); -// }else{ -// //关闭比例尺 -// mapUiSettings.setScaleViewEnabled(false); -// } -// } -// }); -// -// -// -// -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/camera/MapAnchorZoomActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/camera/MapAnchorZoomActivity.java deleted file mode 100644 index 35c21bc..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/camera/MapAnchorZoomActivity.java +++ /dev/null @@ -1,54 +0,0 @@ -package cc.winboll.studio.positions.demo.camera; - -import android.os.Bundle; - -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.Projection; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds; -import com.tencent.tencentmap.mapsdk.maps.model.Marker; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; -import com.tencent.tencentmap.mapsdk.maps.model.RestrictBoundsFitMode; -import com.tencent.tencentmap.mapsdk.maps.model.VisibleRegion; - -public class MapAnchorZoomActivity extends SupportMapFragmentActivity { -// private Marker marker; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// -// LatLng latLng = new LatLng(39.984108,116.307557); -// -// CameraUpdate cameraSigma = -// CameraUpdateFactory.newCameraPosition(new CameraPosition( -// latLng, -// 15, -// 0f, -// 0f)); -// //移动地图 -// tencentMap.moveCamera(cameraSigma); -// Projection projection = tencentMap.getProjection(); -// -// VisibleRegion region = projection.getVisibleRegion(); -// -// tencentMap.setRestrictBounds(new LatLngBounds(region.farRight, region.nearLeft), RestrictBoundsFitMode.FIT_HEIGHT); -// tencentMap.setRestrictBounds(new LatLngBounds(region.farRight, region.nearLeft), RestrictBoundsFitMode.FIT_WIDTH); -// setMarker(latLng); -// } -// /** -// * 设置标注 -// */ -// private void setMarker(LatLng latLng){ -// -// MarkerOptions options = new MarkerOptions().position(latLng); -// -// //设置infowindow -// options.title("锚点"); -// marker = tencentMap.addMarker(options); -// marker.setInfoWindowEnable(true); -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/camera/MapBoundActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/camera/MapBoundActivity.java deleted file mode 100644 index 11ad369..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/camera/MapBoundActivity.java +++ /dev/null @@ -1,54 +0,0 @@ -package cc.winboll.studio.positions.demo.camera; - -//import android.os.Bundle; -//import android.view.View; -//import android.widget.CheckBox; -//import android.widget.CompoundButton; -//import android.widget.RadioGroup; -// -//import cc.winboll.studio.positions.R; -//import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -//import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -//import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds; -//import com.tencent.tencentmap.mapsdk.maps.model.RestrictBoundsFitMode; -// -//public class MapBoundActivity extends SupportMapFragmentActivity { -// private RadioGroup radioGroup; -// private CheckBox fitHeight; -// private CheckBox fitWidth; -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// final LatLng northeastLatLng = new LatLng(39.984066, 116.307548); -// final LatLng southwestLatLng = new LatLng(39.974066, 116.297548); -// radioGroup = findViewById(R.id.lay_map_bound); -// radioGroup.setVisibility(View.VISIBLE); -// fitWidth = findViewById(R.id.btn_fit_width); -// fitWidth.setText("适应宽度"); -// fitHeight = findViewById(R.id.btn_fit_height); -// fitHeight.setText("适应高度"); -// fitHeight.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { -// @Override -// public void onCheckedChanged(CompoundButton compoundButton, boolean b) { -// if (b){ -// tencentMap.setRestrictBounds(new LatLngBounds(northeastLatLng, southwestLatLng), RestrictBoundsFitMode.FIT_HEIGHT); -// }else{ -// -// } -// } -// }); -// -// fitWidth.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { -// @Override -// public void onCheckedChanged(CompoundButton compoundButton, boolean b) { -// if (b){ -// tencentMap.setRestrictBounds(new LatLngBounds(northeastLatLng, southwestLatLng), RestrictBoundsFitMode.FIT_WIDTH); -// }else{ -// -// } -// } -// }); -// } -// -// -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/camera/MapCameraCenterActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/camera/MapCameraCenterActivity.java deleted file mode 100644 index 328d607..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/camera/MapCameraCenterActivity.java +++ /dev/null @@ -1,54 +0,0 @@ -package cc.winboll.studio.positions.demo.camera; - -import android.os.Bundle; -import android.view.View; -import android.widget.TextView; -import android.widget.Toast; - -import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; - -//public class MapCameraCenterActivity extends SupportMapFragmentActivity implements TencentMap.OnCameraChangeListener, TencentMap.OnMapClickListener { -// private TextView textView; -// private String info; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// -// textView = findViewById(R.id.tv_info); -// textView.setVisibility(View.VISIBLE); -// tencentMap.setOnCameraChangeListener(this); -// tencentMap.setOnMapClickListener(this); -// } -// -// -// /** -// * 地图视图改变回调 -// * @param cameraPosition -// */ -// @Override -// public void onCameraChange(CameraPosition cameraPosition) { -// //获取当前地图视图信息 -// info = "经纬度:"+cameraPosition.target.latitude+","+cameraPosition.target.longitude+";zoom:"+cameraPosition.zoom; -// textView.setText(info); -// } -// -// @Override -// public void onCameraChangeFinished(CameraPosition cameraPosition) { -// //获取当前地图视图信息 -// info = "经纬度:"+cameraPosition.target.latitude+","+cameraPosition.target.longitude+";zoom:"+cameraPosition.zoom; -// Toast.makeText(MapCameraCenterActivity.this,info,Toast.LENGTH_SHORT).show(); -// textView.setText(info); -// -// } -// -// @Override -// public void onMapClick(LatLng latLng) { -// tencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(latLng,15f, 0, 0))); -// } -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/circle/ArcActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/circle/ArcActivity.java deleted file mode 100644 index 6d175f1..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/circle/ArcActivity.java +++ /dev/null @@ -1,126 +0,0 @@ -package cc.winboll.studio.positions.demo.circle; - -//import androidx.annotation.NonNull; -//import androidx.appcompat.app.AppCompatActivity; -// -//import android.graphics.Color; -//import android.os.Bundle; -//import android.view.Menu; -//import android.view.MenuItem; -//import android.view.View; -// -//import cc.winboll.studio.positions.R; -//import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; -//import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -//import com.tencent.tencentmap.mapsdk.maps.MapView; -//import com.tencent.tencentmap.mapsdk.maps.TencentMap; -//import com.tencent.tencentmap.mapsdk.maps.model.Arc; -//import com.tencent.tencentmap.mapsdk.maps.model.ArcOptions; -//import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; -//import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -//import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -//import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -//import com.tencent.tencentmap.mapsdk.maps.model.Marker; -//import com.tencent.tencentmap.mapsdk.maps.model.MarkerCollisionItem; -//import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; -// -//public class ArcActivity extends AppCompatActivity { -// -// private MapView mapView; -// private TencentMap tencentMap; -// private boolean mMarkerAdded; -// private Arc arc; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// setContentView(R.layout.activity_arc); -// init(); -// } -// -// private void init() { -// mapView = findViewById(R.id.mapView); -// tencentMap = mapView.getMap(); -// CameraUpdate cameraSigma = -// CameraUpdateFactory.newCameraPosition(new CameraPosition( -// new LatLng(32.059352, 118.796623), -// 5, -// 0f, -// 0f)); -// //移动地图 -// tencentMap.moveCamera(cameraSigma); -// } -// -// @Override -// public boolean onCreateOptionsMenu(Menu menu) { -// getMenuInflater().inflate(R.menu.markercol, menu); -// return super.onCreateOptionsMenu(menu); -// } -// -// @Override -// public boolean onPrepareOptionsMenu(Menu menu) { -// menu.findItem(R.id.menu_open_collisionsmap).setVisible(!mMarkerAdded); -// menu.findItem(R.id.menu_close_collisionsmap).setVisible(mMarkerAdded); -// return super.onPrepareOptionsMenu(menu); -// } -// -// @Override -// public boolean onOptionsItemSelected(@NonNull MenuItem item) { -// switch (item.getItemId()) { -// case R.id.menu_open_collisionsmap: -// mMarkerAdded = true; -// LatLng startLat = new LatLng(39.89491, 116.322056); -// LatLng endtLat = new LatLng(22.547, 114.085947); -// LatLng passLat = new LatLng(32.059352, 118.796623); -// ArcOptions arcOptions = new ArcOptions(); -// arcOptions.points(startLat, endtLat); -// arcOptions.pass(passLat); -// //设置起点到终点,与起点外切线逆时针旋转的夹角角度 -// arcOptions.angle(30); -// //设置线宽,默认5 -// arcOptions.width(2); -// //设置线颜色,默认黑色 -// arcOptions.color(Color.BLUE); -// arc = tencentMap.addArc(arcOptions); -// break; -// case R.id.menu_close_collisionsmap: -// mMarkerAdded = false; -// arc.remove(); -// break; -// } -// -// supportInvalidateOptionsMenu(); -// return super.onOptionsItemSelected(item); -// } -// -// @Override -// protected void onResume() { -// super.onResume(); -// mapView.onResume(); -// } -// -// @Override -// protected void onPause() { -// super.onPause(); -// mapView.onPause(); -// } -// -// @Override -// protected void onDestroy() { -// super.onDestroy(); -// mapView.onDestroy(); -// } -// -// -// @Override -// protected void onStart() { -// super.onStart(); -// mapView.onStart(); -// } -// -// @Override -// protected void onStop() { -// super.onStop(); -// mapView.onStop(); -// } -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/circle/CircleOptionsActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/circle/CircleOptionsActivity.java deleted file mode 100644 index b5fd615..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/circle/CircleOptionsActivity.java +++ /dev/null @@ -1,35 +0,0 @@ -package cc.winboll.studio.positions.demo.circle; - -import android.os.Bundle; - -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.tencentmap.mapsdk.maps.model.Circle; -import com.tencent.tencentmap.mapsdk.maps.model.CircleOptions; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; - -public class CircleOptionsActivity extends SupportMapFragmentActivity { -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// Circle circle = tencentMap.addCircle(circleOptions); -// Circle newCircle = tencentMap.addCircle(newCircleOptions); -// newCircle.setCenter(new LatLng(39.98408, 116.30701)); //重新设置圆心 -// newCircle.setOptions(newCircleOptions); //重新设置圆形属性 -// } -// -// /** -// * 圆形选项 -// */ -// private CircleOptions circleOptions = new CircleOptions() //圆形选项 -// .center(new LatLng(39.9849, 116.3977)) //圆心位置 -// .clickable(true) //支持点击 -// .fillColor((128 << 24) + (100 << 16) + (50 << 8) + 120) //设置填充颜色RGBA -// .radius(110d) //设置半径 -// .visible(true) //设置是否可见 -// .zIndex(1) //设置堆叠顺序,越大优先级越高 -// .strokeWidth(1) //描边宽度 -// .strokeColor((128 << 24) + (128 << 16) + (128 << 8) + 128); //描边颜色 -// -// -// private CircleOptions newCircleOptions = new CircleOptions().center(new LatLng(39.121, 116.454)).radius(90d).fillColor(0xff00ff00); -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/circle/DrawCircleActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/circle/DrawCircleActivity.java deleted file mode 100644 index 0c2ba39..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/circle/DrawCircleActivity.java +++ /dev/null @@ -1,24 +0,0 @@ -package cc.winboll.studio.positions.demo.circle; - -import android.os.Bundle; - -import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.tencentmap.mapsdk.maps.model.Circle; -import com.tencent.tencentmap.mapsdk.maps.model.CircleOptions; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; - -public class DrawCircleActivity extends SupportMapFragmentActivity { -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// LatLng latLng = new LatLng(39.984059,116.307771); -// Circle circle = tencentMap.addCircle(new CircleOptions(). -// center(latLng). -// radius(100d). -// fillColor(getResources().getColor(R.color.style)). -// strokeColor(getResources().getColor(R.color.colorPrimary)). -// strokeWidth(1)); -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/gesture/GestureSettingsActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/gesture/GestureSettingsActivity.java deleted file mode 100644 index e4e5c4c..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/gesture/GestureSettingsActivity.java +++ /dev/null @@ -1,80 +0,0 @@ -package cc.winboll.studio.positions.demo.gesture; - -//import android.os.Bundle; -//import android.view.View; -//import android.widget.CheckBox; -//import android.widget.CompoundButton; -//import android.widget.RadioGroup; -// -//import cc.winboll.studio.positions.R; -//import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -// -//public class GestureSettingsActivity extends SupportMapFragmentActivity { -// -// private CheckBox scrollBox; -// private CheckBox zoomBox; -// private CheckBox rotateBox; -// private CheckBox tiltBox; -// private RadioGroup radioGroup; -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// radioGroup = findViewById(R.id.lay_checkbox); -// radioGroup.setVisibility(View.VISIBLE); -// initView(); -// } -// -// private void initView(){ -// scrollBox = findViewById(R.id.btn_scroll); -// zoomBox = findViewById(R.id.btn_zoom); -// rotateBox = findViewById(R.id.btn_rotate); -// tiltBox = findViewById(R.id.btn_slope); -// -// -// scrollBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { -// @Override -// public void onCheckedChanged(CompoundButton compoundButton, boolean b) { -// if (b){ -// mapUiSettings.setScrollGesturesEnabled(true); -// }else{ -// mapUiSettings.setScrollGesturesEnabled(false); -// } -// } -// }); -// -// -// zoomBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { -// @Override -// public void onCheckedChanged(CompoundButton compoundButton, boolean b) { -// if (b){ -// mapUiSettings.setZoomGesturesEnabled(true); -// }else{ -// mapUiSettings.setZoomGesturesEnabled(false); -// } -// } -// }); -// -// rotateBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { -// @Override -// public void onCheckedChanged(CompoundButton compoundButton, boolean b) { -// if (b){ -// mapUiSettings.setRotateGesturesEnabled(true); -// }else{ -// mapUiSettings.setRotateGesturesEnabled(false); -// } -// } -// }); -// -// tiltBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { -// @Override -// public void onCheckedChanged(CompoundButton compoundButton, boolean b) { -// if (b){ -// mapUiSettings.setTiltGesturesEnabled(true); -// }else{ -// mapUiSettings.setTiltGesturesEnabled(false); -// } -// } -// }); -// } -// -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/gesture/MapGestureListenActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/gesture/MapGestureListenActivity.java deleted file mode 100644 index 73369c8..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/gesture/MapGestureListenActivity.java +++ /dev/null @@ -1,133 +0,0 @@ -package cc.winboll.studio.positions.demo.gesture; - -import android.os.Bundle; -import android.view.View; -import android.widget.TextView; - -import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.TencentMapGestureListener; -import com.tencent.tencentmap.mapsdk.maps.model.TencentMapGestureListener.TwoFingerMoveAgainstStatus; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition.Trigger; - -public class MapGestureListenActivity extends SupportMapFragmentActivity implements TencentMapGestureListener { - - @Override - public boolean onDoubleTap(float p1, float p2) { - return false; - } - - @Override - public boolean onSingleTap(float p1, float p2) { - return false; - } - - @Override - public boolean onFling(float p1, float p2) { - return false; - } - - @Override - public boolean onScroll(float p1, float p2) { - return false; - } - - @Override - public boolean onLongPress(float p1, float p2) { - return false; - } - - @Override - public boolean onDown(float p1, float p2) { - return false; - } - - @Override - public boolean onUp(float p1, float p2) { - return false; - } - - @Override - public boolean onTwoFingerMoveAgainst(TencentMapGestureListener.TwoFingerMoveAgainstStatus p1, CameraPosition p2) { - return false; - } - - @Override - public void onMapStable() { - } - - @Override - public void onMapStableBy(CameraPosition.Trigger p1) { - } - - -// private TextView textView; -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// textView = findViewById(R.id.tv_info); -// textView.setVisibility(View.VISIBLE); -// tencentMap.setTencentMapGestureListener(this); -// } -// -// @Override -// public boolean onDoubleTap(float v, float v1) { -// textView.setText("单指双击"); -// return true; -// } -// -// @Override -// public boolean onSingleTap(float v, float v1) { -// textView.setText("单指单击"); -// return true; -// } -// -// @Override -// public boolean onFling(float v, float v1) { -// textView.setText("单指惯性滑动"); -// return true; -// } -// -// @Override -// public boolean onScroll(float v, float v1) { -// textView.setText("单指滑动"); -// return true; -// } -// -// @Override -// public boolean onLongPress(float v, float v1) { -// textView.setText("长按"); -// return true; -// } -// -// @Override -// public boolean onDown(float v, float v1) { -// textView.setText("单指按下"); -// return true; -// } -// -// @Override -// public boolean onUp(float v, float v1) { -// textView.setText("单指抬起"); -// return true; -// } -// -// @Override -// public boolean onTwoFingerMoveAgainst(TwoFingerMoveAgainstStatus twoFingerMoveAgainstStatus, CameraPosition cameraPosition) { -// textView.setText("双指捏合"); -// return false; -// } -// -// @Override -// public void onMapStable() { -// textView.setText("地图稳定"); -// return; -// } -// -// @Override -// public void onMapStableBy(CameraPosition.Trigger trigger) { -// textView.setText("地图稳定 by " + trigger.name()); -// return; -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/gesture/MapListenActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/gesture/MapListenActivity.java deleted file mode 100644 index 0775dac..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/gesture/MapListenActivity.java +++ /dev/null @@ -1,30 +0,0 @@ -package cc.winboll.studio.positions.demo.gesture; - -import android.os.Bundle; -import android.view.View; -import android.widget.TextView; -import android.widget.Toast; - -import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; - -//public class MapListenActivity extends SupportMapFragmentActivity implements TencentMap.OnMapClickListener { -// private TextView textView; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// textView = findViewById(R.id.tv_info); -// textView.setVisibility(View.VISIBLE); -// tencentMap.setOnMapClickListener(this); -// } -// -// @Override -// public void onMapClick(LatLng latLng) { -// String info = "经纬度:" + latLng.latitude + "," + latLng.longitude; -// Toast.makeText(MapListenActivity.this, info, Toast.LENGTH_SHORT).show(); -// textView.setText(info); -// } -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/gesture/MapLongClickActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/gesture/MapLongClickActivity.java deleted file mode 100644 index 1569972..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/gesture/MapLongClickActivity.java +++ /dev/null @@ -1,63 +0,0 @@ -package cc.winboll.studio.positions.demo.gesture; - -//import android.graphics.Bitmap; -//import android.graphics.BitmapFactory; -//import android.graphics.Matrix; -//import android.os.Bundle; -//import android.view.View; -//import android.widget.TextView; -// -//import cc.winboll.studio.positions.R; -//import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -//import com.tencent.tencentmap.mapsdk.maps.TencentMap; -//import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; -//import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -//import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -//import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; -// -//public class MapLongClickActivity extends SupportMapFragmentActivity implements TencentMap.OnMapLongClickListener { -// private TextView textView; -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// textView = findViewById(R.id.tv_info); -// textView.setVisibility(View.VISIBLE); -// tencentMap.setOnMapLongClickListener(this); -// } -// -// @Override -// public void onMapLongClick(LatLng latLng) { -// String info = "经纬度:"+latLng.latitude+","+latLng.longitude; -// textView.setText(info); -// setMarker(latLng); -// } -// -// /** -// * 长按添加标注 -// */ -// private void setMarker(LatLng latLng){ -// -// BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.marker)); -// MarkerOptions options = new MarkerOptions().position(latLng).icon(bitmapDescriptor); -// tencentMap.clear(); -// tencentMap.addMarker(options); -// -// } -// -// -// private Bitmap getBitMap(int resourceId){ -// Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId); -// int width = bitmap.getWidth(); -// int height = bitmap.getHeight(); -// int newWidth = 100; -// int newHeight = 100; -// float widthScale = ((float)newWidth)/width; -// float heightScale = ((float)newHeight)/height; -// Matrix matrix = new Matrix(); -// matrix.postScale(widthScale, heightScale); -// bitmap = Bitmap.createBitmap(bitmap,0,0,width,height,matrix,true); -// return bitmap; -// } -// -// -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/AggregationOverlayActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/AggregationOverlayActivity.java deleted file mode 100644 index 77dd712..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/AggregationOverlayActivity.java +++ /dev/null @@ -1,197 +0,0 @@ -package cc.winboll.studio.positions.demo.heatoverlay; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; - -import android.graphics.Color; -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; -import android.widget.CompoundButton; -import android.widget.Switch; - -import com.tencent.map.sdk.utilities.visualization.aggregation.AggregationOverlay; -import com.tencent.map.sdk.utilities.visualization.aggregation.AggregationOverlayProvider; -import com.tencent.map.sdk.utilities.visualization.aggregation.HoneyCombVectorOverlayProvider; -import com.tencent.map.sdk.utilities.visualization.datamodels.WeightedLatLng; -import cc.winboll.studio.positions.R; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.MapView; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; - -public class AggregationOverlayActivity extends AppCompatActivity { -// private MapView mMapView; -// private TencentMap mTencentMap; -// private AggregationOverlay aggregationOverlay; -// private AggregationOverlayProvider aggregationOverlayProvider; -// private Switch btnSwitch3D; -// -// boolean mIsSelected; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// setContentView(R.layout.activity_aggregation_overlay_design); -// init(); -// } -// -// @Override -// public boolean onCreateOptionsMenu(Menu menu) { -// getMenuInflater().inflate(R.menu.vectorheatmap, menu); -// return true; -// } -// -// @Override -// public boolean onPrepareOptionsMenu(Menu menu) { -// menu.findItem(R.id.menu_open_vectorheatmap).setVisible(!mIsSelected); -// menu.findItem(R.id.menu_close_vectorheatmap).setVisible(mIsSelected); -// return super.onPrepareOptionsMenu(menu); -// } -// -// @Override -// public boolean onOptionsItemSelected(@NonNull MenuItem item) { -// switch (item.getItemId()) { -// case R.id.menu_open_vectorheatmap: -// addAggregation(); -// break; -// case R.id.menu_close_vectorheatmap: -// mIsSelected = false; -// if (aggregationOverlay != null) { -// aggregationOverlay.remove(); -// aggregationOverlay = null; -// } -// break; -// } -// -// supportInvalidateOptionsMenu(); -// return super.onOptionsItemSelected(item); -// } -// -// @Override -// protected void onResume() { -// super.onResume(); -// mMapView.onResume(); -// } -// -// @Override -// protected void onPause() { -// super.onPause(); -// mMapView.onPause(); -// } -// -// @Override -// protected void onDestroy() { -// super.onDestroy(); -// mMapView.onDestroy(); -// } -// -// -// @Override -// protected void onStart() { -// super.onStart(); -// mMapView.onStart(); -// } -// -// @Override -// protected void onStop() { -// super.onStop(); -// mMapView.onStop(); -// } -// -// private void init() { -// mMapView = findViewById(R.id.mapView); -// mTencentMap = mMapView.getMap(); -// mTencentMap.setMapStyle(3); -// mTencentMap.moveCamera(CameraUpdateFactory.zoomTo(10f)); -// btnSwitch3D = (Switch) findViewById(R.id.btn_switch_3D); -// bindListener(); -// } -// -// -// private void bindListener() { -// -// CompoundButton.OnCheckedChangeListener onCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() { -// -// @Override -// public void onCheckedChanged(CompoundButton compoundButton, boolean b) { -// switch (compoundButton.getId()) { -// case R.id.btn_switch_3D: -// if (aggregationOverlay != null) { -// if (compoundButton.isChecked()) { -// aggregationOverlayProvider.enable3D(true); -// aggregationOverlayProvider.enable3D(true).setAnimateDuration(3000); -// } else { -// aggregationOverlayProvider.enable3D(false); -// } -// mTencentMap.updateVectorOverlay(aggregationOverlay, aggregationOverlayProvider); -// } -// break; -// default: -// break; -// } -// } -// }; -// -// -// btnSwitch3D.setOnCheckedChangeListener(onCheckedChangeListener); -// -// } -// -// protected void addAggregation() { -// mIsSelected = true; -// if (aggregationOverlay != null) { -// return; -// } -// // mTencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(39.961629, 116.355343), 12, 0, 0))); -// mTencentMap.setBuildingEnable(false); -// mTencentMap.setPoisEnabled(false); -// BufferedReader br = null; -// try { -// ArrayList nodes = new ArrayList(); -// br = new BufferedReader(new InputStreamReader(getResources().getAssets().open("data2k"))); -// String line = null; -// while ((line = br.readLine()) != null) { -// String[] lines = line.split("\t"); -// if (lines.length == 3) { -// double value = Double.parseDouble(lines[2]); -// LatLng latLng = new LatLng((Double.parseDouble(lines[1])), (Double.parseDouble(lines[0]))); -// nodes.add(new WeightedLatLng(latLng, value)); -// } -// } -// -// int[] colors = { -// Color.argb(255, 0x01, 0x2C, 0x4B), -// Color.argb(255, 0x17, 0x3E, 0x59), -// Color.argb(255, 0x3A, 0x73, 0x78), -// Color.argb(255, 0x98, 0xCD, 0x9A), -// Color.argb(255, 0xF6, 0xFB, 0xB6) -// }; -// double[] startPoints = {0.f, 0.1f, 0.15f, 0.3f, 0.5f}; -// -// -// aggregationOverlayProvider = new HoneyCombVectorOverlayProvider() -// .nodes(nodes.toArray(new WeightedLatLng[0])) -// .setHeightRange(0, 4000); -// aggregationOverlayProvider.colors(colors, startPoints); -// aggregationOverlay = mTencentMap.addVectorOverlay(aggregationOverlayProvider); -// -// -// } catch (Exception e) { -// e.printStackTrace(); -// } finally { -// if (br != null) { -// try { -// br.close(); -// } catch (IOException e) { -// e.printStackTrace(); -// } -// } -// } -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/ArcLineLayerActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/ArcLineLayerActivity.java deleted file mode 100644 index bc63935..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/ArcLineLayerActivity.java +++ /dev/null @@ -1,182 +0,0 @@ -package cc.winboll.studio.positions.demo.heatoverlay; - -//import androidx.annotation.NonNull; -//import androidx.appcompat.app.AppCompatActivity; -// -//import android.graphics.Color; -//import android.os.Bundle; -//import android.view.Menu; -//import android.view.MenuItem; -//import android.view.View; -//import android.widget.Button; -//import android.widget.CompoundButton; -//import android.widget.Switch; -// -//import com.tencent.map.sdk.utilities.visualization.datamodels.FromToLatLng; -//import com.tencent.map.sdk.utilities.visualization.od.ArcLineOverlay; -//import com.tencent.map.sdk.utilities.visualization.od.ArcLineOverlayProvider; -//import cc.winboll.studio.positions.R; -//import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -//import com.tencent.tencentmap.mapsdk.maps.MapView; -//import com.tencent.tencentmap.mapsdk.maps.TencentMap; -//import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -//import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -//import com.tencent.tencentmap.mapsdk.maps.model.VectorOverlay; -// -//import java.io.BufferedReader; -//import java.io.InputStreamReader; -//import java.util.ArrayList; -// -//public class ArcLineLayerActivity extends AppCompatActivity { -// private MapView mMapView; -// private TencentMap mTencentMap; -// private VectorOverlay vectorOverlay; -// private ArcLineOverlayProvider options; -// private Switch btnSwitch3D; -// boolean mIsSelected; -// private Switch btnani3D; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// setContentView(R.layout.activity_arc_line_layer_design); -// init(); -// } -// -// @Override -// public boolean onCreateOptionsMenu(Menu menu) { -// getMenuInflater().inflate(R.menu.vectorheatmap, menu); -// return true; -// } -// -// @Override -// public boolean onPrepareOptionsMenu(Menu menu) { -// menu.findItem(R.id.menu_open_vectorheatmap).setVisible(!mIsSelected); -// menu.findItem(R.id.menu_close_vectorheatmap).setVisible(mIsSelected); -// return super.onPrepareOptionsMenu(menu); -// } -// -// @Override -// public boolean onOptionsItemSelected(@NonNull MenuItem item) { -// switch (item.getItemId()) { -// case R.id.menu_open_vectorheatmap: -// btnSwitch3D.setVisibility(View.VISIBLE); -// addArcLineLayer(); -// break; -// case R.id.menu_close_vectorheatmap: -// mIsSelected = false; -// if (vectorOverlay != null) { -// vectorOverlay.remove(); -// vectorOverlay = null; -// } -// break; -// } -// -// supportInvalidateOptionsMenu(); -// return super.onOptionsItemSelected(item); -// } -// -// @Override -// protected void onResume() { -// super.onResume(); -// mMapView.onResume(); -// } -// -// @Override -// protected void onPause() { -// super.onPause(); -// mMapView.onPause(); -// } -// -// @Override -// protected void onDestroy() { -// super.onDestroy(); -// mMapView.onDestroy(); -// } -// -// -// @Override -// protected void onStart() { -// super.onStart(); -// mMapView.onStart(); -// } -// -// @Override -// protected void onStop() { -// super.onStop(); -// mMapView.onStop(); -// } -// -// private void init() { -// mMapView = findViewById(R.id.mapView); -// mTencentMap = mMapView.getMap(); -// mTencentMap.moveCamera(CameraUpdateFactory.zoomTo(5f)); -// btnSwitch3D = (Switch) findViewById(R.id.btn_switch_3D); -// bindListener(); -// -// } -// -// private void bindListener() { -// CompoundButton.OnCheckedChangeListener onCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() { -// -// @Override -// public void onCheckedChanged(CompoundButton compoundButton, boolean b) { -// switch (compoundButton.getId()) { -// case R.id.btn_switch_3D: -// if (vectorOverlay != null) { -// if (compoundButton.isChecked()) { -// options.enable3D(true); -// } else { -// options.enable3D(false); -// } -// -// mTencentMap.updateVectorOverlay(vectorOverlay, options); -// } -// break; -// -// default: -// break; -// } -// } -// }; -// -// btnSwitch3D.setOnCheckedChangeListener(onCheckedChangeListener); -// } -// -// private void addArcLineLayer() { -// mIsSelected = true; -// if (vectorOverlay == null) { -// // mTencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(39.9229731, 116.422880668), 8, 0f, 0f))); -// mTencentMap.setMapStyle(3); -// -// int color = Color.argb(255, 0, 255, 170); -// BufferedReader br = null; -// final ArrayList nodes = new ArrayList(); -// try { -// br = new BufferedReader(new InputStreamReader(getResources().getAssets().open("arc.dat"))); -// String line = null; -// while ((line = br.readLine()) != null) { -// String[] lines = line.split(" "); -// if (lines.length == 5) { -// double arc = Double.parseDouble(lines[4]); -// LatLng startLatLng = new LatLng((Double.parseDouble(lines[0])), (Double.parseDouble(lines[1]))); -// LatLng endLatLng = new LatLng((Double.parseDouble(lines[2])), (Double.parseDouble(lines[3]))); -// nodes.add(new FromToLatLng(startLatLng, endLatLng)); -// //nodes.add(new FromToLatLng(startLatLng, endLatLng, arc)); -// } -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } -// int[] colors = { -// Color.argb(255, 0, 0xd4, 0xff), -// Color.argb((int) (255 * 0.3), 0, 0xd4, 0xff), -// Color.argb(255, 0, 0xd4, 0xff) -// }; -// options = new ArcLineOverlayProvider().data(nodes).opacity(2f).width(4).gradient(colors).setAnimateDuration(3000).setHighlightDuration(200).animateColor(Color.argb(255, 0xff, 0xff, 0xff)); -// vectorOverlay = mTencentMap.addVectorOverlay(options); -// mTencentMap.setPoisEnabled(false); -// -// } -// } -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/DrawHeatOverlayActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/DrawHeatOverlayActivity.java deleted file mode 100644 index e0c5041..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/DrawHeatOverlayActivity.java +++ /dev/null @@ -1,131 +0,0 @@ -package cc.winboll.studio.positions.demo.heatoverlay; - -import android.graphics.Color; -import android.os.Bundle; -import android.view.View; -import android.widget.Button; - -import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.map.sdk.utilities.heatmap.Gradient; -import com.tencent.map.sdk.utilities.heatmap.HeatMapTileProvider; -import com.tencent.map.sdk.utilities.heatmap.WeightedLatLng; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.TileOverlay; -import com.tencent.tencentmap.mapsdk.maps.model.TileOverlayOptions; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; - -public class DrawHeatOverlayActivity extends SupportMapFragmentActivity implements HeatMapTileProvider.OnHeatMapReadyListener { - - @Override - public void onHeatMapReady() { - } - - -// private TileOverlay mHeatmapTileOverlay; -// private HeatMapTileProvider mProvider; -// //热力图半径 -// private static final int ALT_HEATMAP_RADIUS = HeatMapTileProvider.DEFAULT_RADIUS; -// //热力图透明度 -// private static final double ALT_HEATMAP_OPACITY = HeatMapTileProvider.DEFAULT_OPACITY; -// //热力图渐变方案 -// public static final Gradient ALT_HEATMAP_GRADIENT = HeatMapTileProvider.DEFAULT_GRADIENT; -// -// private static final int[] CUSTOM_GRADIENT_COLORS = { -// Color.argb(0,0, 225, 225), -// Color.rgb(102, 125, 200), -// Color.rgb(255, 0, 0) -// }; -// -// private static final float[] CUSTOM_GRADIENT_START_POINTS = { -// 0.0f, 0.2f, 1f -// }; -// -// public static final Gradient CUSTOM_HEATMAP_GRADIENT = new Gradient(CUSTOM_GRADIENT_COLORS, -// CUSTOM_GRADIENT_START_POINTS); -// @Override -// public void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// setUpMap(); -// Button first = findViewById(R.id.btn_bottom); -// first.setVisibility(View.VISIBLE); -// first.setText("自定义热力图"); -// first.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View v) { -// mProvider.setHeatTileGenerator(new HeatMapTileProvider.HeatTileGenerator() { -// @Override -// public double[] generateKernel(int radius) { -// double[] kernel = new double[radius * 2 + 1]; -// for (int i = -radius; i <= radius; i++) { -// kernel[i + radius] = Math.exp(-i * i / (2 * (radius / 2f) * (radius / 2f))); -// } -// return kernel; -// } -// -// @Override -// public int[] generateColorMap(double opacity) { -// return CUSTOM_HEATMAP_GRADIENT.generateColorMap(opacity); -// } -// }); -// mHeatmapTileOverlay.clearTileCache(); -// mHeatmapTileOverlay.reload(); -// } -// }); -// -// } -// private void setUpMap() { -// tencentMap.moveCamera(CameraUpdateFactory.newLatLngZoom( -// new com.tencent.tencentmap.mapsdk.maps.model.LatLng(39.917128, 116.399266), -// 7.946870f)); -// initHeatMap(); -// } -// private void initHeatMap() { -// BufferedReader br = null; -// try { -// ArrayList nodes = new ArrayList<>(); -// br = new BufferedReader(new InputStreamReader( -// getResources().getAssets().open("data2k"))); -// String line; -// while ((line = br.readLine()) != null) { -// String[] lines = line.split("\t"); -// if (lines.length == 3) { -// double value = Double.parseDouble(lines[2]); -// LatLng latLng = new LatLng((Double.parseDouble(lines[1])), -// (Double.parseDouble(lines[0]))); -// nodes.add(new WeightedLatLng(latLng, value)); -// } -// } -// -// mProvider = new HeatMapTileProvider.Builder() -// .weightedData(nodes) -// .gradient(ALT_HEATMAP_GRADIENT) -// .opacity(ALT_HEATMAP_OPACITY) -// .radius(ALT_HEATMAP_RADIUS) -// .readyListener(this) -// .build(tencentMap); -// mHeatmapTileOverlay = tencentMap.addTileOverlay(new TileOverlayOptions().tileProvider(mProvider)); -// } catch (Exception e) { -// e.printStackTrace(); -// } finally { -// if (br != null) { -// try { -// br.close(); -// } catch (IOException e) { -// e.printStackTrace(); -// } -// } -// } -// } -// -// @Override -// public void onHeatMapReady() { -// mHeatmapTileOverlay.clearTileCache(); -// mHeatmapTileOverlay.reload(); -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/GLModelActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/GLModelActivity.java deleted file mode 100644 index 6a6c381..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/GLModelActivity.java +++ /dev/null @@ -1,166 +0,0 @@ -package cc.winboll.studio.positions.demo.heatoverlay; - -import androidx.appcompat.app.AppCompatActivity; - -import android.os.Bundle; -import android.util.Log; -import android.view.View; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.Spinner; - -import com.tencent.map.sdk.utilities.visualization.glmodel.GLModelOverlay; -import com.tencent.map.sdk.utilities.visualization.glmodel.GLModelOverlayProvider; -import cc.winboll.studio.positions.R; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.MapView; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.TencentMapOptions; -import com.tencent.tencentmap.mapsdk.maps.model.GeneralTranslateAnimator; -import com.tencent.tencentmap.mapsdk.maps.model.IAnimatorModel; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds; -import com.tencent.tencentmap.mapsdk.maps.model.Polyline; -import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; - -import java.io.File; -import java.util.Arrays; - -import static com.tencent.map.sdk.utilities.visualization.glmodel.GLModelOverlayProvider.CoordType.GeoGraphicType; -import static com.tencent.map.sdk.utilities.visualization.glmodel.GLModelOverlayProvider.CoordType.PixelType; - -public class GLModelActivity extends AppCompatActivity { -// -// /** -// * 和其他覆盖物相同三维模型图也可控制图层的Level和zIndex -// * 可通过 GLModelOverlayProvider的displayLevel和zIndex进行设置 -// * displayLevel - 默认层级为POI之下 OverlayLevel.OverlayLevelAboveBuildings -// * 相同Level内的显示层级关系通过zIndex(int)来控制,zIndex越大越靠上显示。 Level优先级高于zIndex displayLevel必须为如下值之一,否则不生效 -// */ -// -// private MapView mapView; -// protected TencentMap tencentMap; -// private String mResourcePath; -// private GLModelOverlay vectorOverlay; -// private final String mLine = "39.98409,116.30804,39.98409,116.3081,39.98409,116.3081,39.98397,116.30809,39.9823,116.30809,39.9811,116.30817,39.9811,116.30817,39.97918,116.308266,39.97918,116.308266,39.9791,116.30827,39.9791,116.30827,39.979008,116.3083,39.978756,116.3084,39.978386,116.3086,39.977867,116.30884,39.977547,116.308914,39.976845,116.308914,39.975826,116.308945,39.975826,116.308945,39.975666,116.30901,39.975716,116.310486,39.975716,116.310486,39.975754,116.31129,39.975754,116.31129,39.975784,116.31241,39.975822,116.31327,39.97581,116.31352,39.97588,116.31591,39.97588,116.31591,39.97591,116.31735,39.97591,116.31735,39.97593,116.31815,39.975967,116.31879,39.975986,116.32034,39.976055,116.32211,39.976086,116.323395,39.976105,116.32514,39.976173,116.32631,39.976254,116.32811,39.976265,116.3288,39.976345,116.33123,39.976357,116.33198,39.976418,116.33346,39.976418,116.33346,39.97653,116.333755,39.97653,116.333755,39.978157,116.333664,39.978157,116.333664,39.978195,116.33509,39.978195,116.33509,39.978226,116.33625,39.978226,116.33625,39.97823,116.33656,39.97823,116.33656,39.978256,116.33791,39.978256,116.33791,39.978016,116.33789,39.977047,116.33791,39.977047,116.33791,39.97706,116.33768,39.97706,116.33768,39.976967,116.33706,39.976967,116.33697"; -// private LatLng[] mCarLatLngArray; -// private GeneralTranslateAnimator animator; -// private Polyline polyline; -// private Spinner mSpinner; -// private String[] glmodelAnimator = new String[]{"开启平滑移动", "开启骨骼动画", "关闭骨骼动画"}; -// private GLModelOverlayProvider provider; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// setContentView(R.layout.activity_g_l_model); -// mapView = findViewById(R.id.mapView); -// tencentMap = this.mapView.getMap(); -// String[] linePointsStr = mLine.split(","); -// mCarLatLngArray = new LatLng[linePointsStr.length / 4]; -// -// for (int i = 0; i < mCarLatLngArray.length; i++) { -// double latitude = Double.parseDouble(linePointsStr[i * 4]); -// double longitude = Double.parseDouble(linePointsStr[i * 4 + 1]); -// mCarLatLngArray[i] = new LatLng(latitude, longitude); -// } -// polyline = tencentMap.addPolyline(new PolylineOptions().add(mCarLatLngArray).color(R.color.colorAccent).arrow(true)); -// tencentMap.animateCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder().include(Arrays.asList(mCarLatLngArray)).build(), 50)); -// creatglmode(); -// init(); -// } -// -// private void creatglmode() { -// //gltf格式三维模型文件在assets内 -// String file = "BrainStem.gltf"; -// String SKELETON_PATH = "gltf-BrainStem"; -// //获取外部存储 -// mResourcePath = getExternalFilesDir(null).getAbsolutePath() + File.separator + SKELETON_PATH; -// provider = new GLModelOverlayProvider( -// mResourcePath + File.separator + file, -// new LatLng(39.98409, 116.30804)).coordType(PixelType) -// .pixelBounds(400, 1200).rotationX(90).rotationY(0).rotationZ(0).setClickEnable(true); -// vectorOverlay = tencentMap.addVectorOverlay(provider); -// } -// -// private void init() { -// mSpinner = findViewById(R.id.sp_glmode); -// ArrayAdapter adapter = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_spinner_dropdown_item, glmodelAnimator); -// mSpinner.setAdapter(adapter); -// mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { -// @Override -// public void onItemSelected(AdapterView parent, View view, int position, long id) { -// switch (position) { -// //开启骨骼动画 -// case 0: -// animator = new GeneralTranslateAnimator.Builder(vectorOverlay, 6000, -// mCarLatLngArray).rotateEnabled(true).initRotate(180).modelType(GeneralTranslateAnimator.ModelType.MODEL_OVERLAY).build(); -// animator.startAnimation(); -// animator.addAnimatorEndListener(new IAnimatorModel.IAnimatorEndListener() { -// @Override -// public void onAnimatorEnd() { -// Log.i("TransformActivity", "onAnimatorEnd"); -// } -// }); -// break; -// //停止骨骼动画 -// case 1: -// vectorOverlay.playSkeletonAnimation(0, 1, true); -// break; -// //模型平移 -// case 2: -// vectorOverlay.stopSkeletonAnimation(); -// break; -// } -// } -// -// @Override -// public void onNothingSelected(AdapterView parent) { -// -// } -// }); -// -// } -// -// /** -// * mapview的生命周期管理 -// */ -// @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 onDestroy() { -// super.onDestroy(); -// mapView.onDestroy(); -// vectorOverlay.remove(); -// -// } -// -// @Override -// protected void onRestart() { -// super.onRestart(); -// mapView.onRestart(); -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/HeatMapVectorOverlayActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/HeatMapVectorOverlayActivity.java deleted file mode 100644 index d4abd4d..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/HeatMapVectorOverlayActivity.java +++ /dev/null @@ -1,171 +0,0 @@ -package cc.winboll.studio.positions.demo.heatoverlay; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; - -import android.graphics.Color; -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.widget.Button; - -import com.tencent.map.sdk.utilities.visualization.datamodels.WeightedLatLng; -import com.tencent.map.sdk.utilities.visualization.heatmap.GradientVectorOverlay; -import com.tencent.map.sdk.utilities.visualization.heatmap.GradientVectorOverlayProvider; -import cc.winboll.studio.positions.R; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.MapView; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; - -public class HeatMapVectorOverlayActivity extends AppCompatActivity { -// private MapView mMapView; -// private TencentMap mTencentMap; -// private GradientVectorOverlay heatTileOverlay; -// private GradientVectorOverlayProvider heatMapTileProvider; -// boolean mIsSelected; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// setContentView(R.layout.activity_heat_map_vector_overlay_design); -// init(); -// } -// -// @Override -// public boolean onCreateOptionsMenu(Menu menu) { -// getMenuInflater().inflate(R.menu.vectorheatmap, menu); -// return true; -// } -// -// @Override -// public boolean onPrepareOptionsMenu(Menu menu) { -// menu.findItem(R.id.menu_open_vectorheatmap).setVisible(!mIsSelected); -// menu.findItem(R.id.menu_close_vectorheatmap).setVisible(mIsSelected); -// return super.onPrepareOptionsMenu(menu); -// } -// -// @Override -// public boolean onOptionsItemSelected(@NonNull MenuItem item) { -// switch (item.getItemId()) { -// case R.id.menu_open_vectorheatmap: -// addHeatMap(); -// break; -// case R.id.menu_close_vectorheatmap: -// mIsSelected = false; -// if (heatTileOverlay != null) { -// heatTileOverlay.remove(); -// heatTileOverlay = null; -// } -// break; -// } -// -// supportInvalidateOptionsMenu(); -// return super.onOptionsItemSelected(item); -// } -// -// @Override -// protected void onResume() { -// super.onResume(); -// mMapView.onResume(); -// } -// -// @Override -// protected void onPause() { -// super.onPause(); -// mMapView.onPause(); -// } -// -// @Override -// protected void onDestroy() { -// super.onDestroy(); -// mMapView.onDestroy(); -// } -// -// -// @Override -// protected void onStart() { -// super.onStart(); -// mMapView.onStart(); -// } -// -// @Override -// protected void onStop() { -// super.onStop(); -// mMapView.onStop(); -// } -// -// private void init() { -// mMapView = findViewById(R.id.mapView); -// mTencentMap = mMapView.getMap(); -// mTencentMap.setMapStyle(3); -// CameraUpdate cameraSigma = -// CameraUpdateFactory.newCameraPosition(new CameraPosition( -// new LatLng(31.085414, 111.024319), -// 4, -// 20f, -// 1f)); -// mTencentMap.moveCamera(cameraSigma); -// } -// -// -// private void addHeatMap() { -// mIsSelected = true; -// if (heatTileOverlay != null) { -// return; -// } -// mTencentMap.setBuildingEnable(false); -// mTencentMap.setPoisEnabled(false); -// BufferedReader br = null; -// try { -// ArrayList nodes = new ArrayList(); -// br = new BufferedReader(new InputStreamReader(getResources().getAssets().open("data2k"))); -// String line = null; -// while ((line = br.readLine()) != null) { -// String[] lines = line.split("\t"); -// if (lines.length == 3) { -// double value = Double.parseDouble(lines[2]); -// LatLng latLng = new LatLng((Double.parseDouble(lines[1])), (Double.parseDouble(lines[0]))); -// nodes.add(new WeightedLatLng(latLng, value)); -// } -// } -// -// // 通用配色1 -// int[] colors = { -// Color.argb(255, 77, 111, 255), -// Color.argb(255, 0, 238, 227), -// Color.argb(255, 113, 236, 80), -// Color.argb(255, 255, 176, 0), -// Color.argb(255, 255, 72, 0) -// }; -// float[] startPoints = {0.1f, 0.185f, 0.3571f, 0.6142f, 1f}; -// -// -// heatMapTileProvider = new GradientVectorOverlayProvider() -// .weightedData(nodes).enable3D(true) -// .radius(56).setMaxHeight(500).setAnimateDuration(3000); -// heatMapTileProvider.opacity(0.95f); -// heatMapTileProvider.gradient(colors, startPoints); -// heatTileOverlay = mTencentMap.addVectorOverlay(heatMapTileProvider); -// -// } catch (Exception e) { -// e.printStackTrace(); -// } finally { -// if (br != null) { -// try { -// br.close(); -// } catch (IOException e) { -// e.printStackTrace(); -// } -// } -// } -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/ScatterPlotOverlayActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/ScatterPlotOverlayActivity.java deleted file mode 100644 index f63b708..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/ScatterPlotOverlayActivity.java +++ /dev/null @@ -1,180 +0,0 @@ -package cc.winboll.studio.positions.demo.heatoverlay; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; - -import android.graphics.Color; -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.CompoundButton; -import android.widget.Spinner; -import android.widget.Switch; - -import com.tencent.map.sdk.utilities.visualization.datamodels.ScatterLatLng; -import com.tencent.map.sdk.utilities.visualization.scatterplot.BitmapScatterPlotOverlayProvider; -import com.tencent.map.sdk.utilities.visualization.scatterplot.DotScatterPlotOverlayProvider; -import cc.winboll.studio.positions.R; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.MapView; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; -import com.tencent.tencentmap.mapsdk.maps.model.VectorOverlay; - -import java.io.BufferedReader; -import java.util.ArrayList; -import java.util.Random; - -public class ScatterPlotOverlayActivity extends AppCompatActivity { -// private MapView mMapView; -// private TencentMap mTencentMap; -// private VectorOverlay vectorOverlay; -// boolean mIsSelected; -// private DotScatterPlotOverlayProvider dotScatterPlotOverlayProvider; -// private BitmapScatterPlotOverlayProvider provider; -// private String[] styles = new String[]{"添加点散点", "添加图片散点"}; -// private Spinner mSpinner; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// setContentView(R.layout.activity_scatter_plot_overlay); -// init(); -// } -// -// -// @Override -// protected void onResume() { -// super.onResume(); -// mMapView.onResume(); -// } -// -// @Override -// protected void onPause() { -// super.onPause(); -// mMapView.onPause(); -// } -// -// @Override -// protected void onDestroy() { -// super.onDestroy(); -// mMapView.onDestroy(); -// } -// -// -// @Override -// protected void onStart() { -// super.onStart(); -// mMapView.onStart(); -// } -// -// @Override -// protected void onStop() { -// super.onStop(); -// mMapView.onStop(); -// } -// -// private void init() { -// mMapView = findViewById(R.id.mapView); -// mTencentMap = mMapView.getMap(); -// mTencentMap.moveCamera(CameraUpdateFactory.zoomTo(5f)); -// mTencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(40.040219, 116.273348), 20, 0, 0))); -// mSpinner = findViewById(R.id.sp_style); -// ArrayAdapter adapter = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_spinner_dropdown_item, styles); -// mSpinner.setAdapter(adapter); -// mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { -// @Override -// public void onItemSelected(AdapterView parent, View view, int position, long id) { -// switch (position) { -// case 0: -// if (vectorOverlay != null) { -// vectorOverlay.remove(); -// vectorOverlay = null; -// } -// addDotVectorOverlay(); -// mTencentMap.updateVectorOverlay(vectorOverlay, dotScatterPlotOverlayProvider); -// break; -// case 1: -// if (vectorOverlay != null) { -// vectorOverlay.remove(); -// vectorOverlay = null; -// } -// addBitmapVectorOverlay(); -// mTencentMap.updateVectorOverlay(vectorOverlay, provider); -// break; -// } -// } -// -// @Override -// public void onNothingSelected(AdapterView parent) { -// -// } -// }); -// -// } -// -// -// private void addDotVectorOverlay() { -// mIsSelected = true; -// if (vectorOverlay == null) { -// BufferedReader br = null; -// final ArrayList nodes = new ArrayList(); -// double lat = 40.040219; -// double lng = 116.273348; -// double value = 100; -// Random r = new Random(); -// for (int i = 0; i < 2000; i++) { -// double a = r.nextInt(10) * 1E-5; -// double b = r.nextInt(10) * 1E-5; -// LatLng latLng = new LatLng(lat + a, lng + b); -// nodes.add(new ScatterLatLng(latLng, value)); -// } -// int[] colors = { -// Color.argb(255, 0, 0xd4, 0xff), -// Color.argb((int) (255 * 0.3), 0, 0xd4, 0xff), -// Color.argb(255, 0, 0xd4, 0xff) -// }; -// -// dotScatterPlotOverlayProvider = new DotScatterPlotOverlayProvider().data(nodes).opacity(2f).radius(2).animate(true).colors(colors); -// -// vectorOverlay = mTencentMap.addVectorOverlay(dotScatterPlotOverlayProvider); -// -// } -// -// } -// -// private void addBitmapVectorOverlay() { -// mIsSelected = true; -// if (vectorOverlay == null) { -// final ArrayList nodes = new ArrayList(); -// double lat = 40.040219; -// double lng = 116.273348; -// double value = 10; -// Random r = new Random(); -// for (int i = 0; i < 1000; i++) { -// double a = r.nextInt(10) * 1E-5; -// double b = r.nextInt(10) * 1E-5; -// LatLng latLng = new LatLng(lat + a, lng + b); -// nodes.add(new ScatterLatLng(latLng, value)); -// } -// BitmapDescriptor[] bitmaps = { -// BitmapDescriptorFactory.fromAsset("21.jpg"), -// BitmapDescriptorFactory.fromAsset("22.jpg"), -// BitmapDescriptorFactory.fromAsset("23.jpg"), -// BitmapDescriptorFactory.fromAsset("24.jpg"), -// BitmapDescriptorFactory.fromAsset("25.jpg"), -// BitmapDescriptorFactory.fromAsset("26.jpg"), -// }; -// provider = new BitmapScatterPlotOverlayProvider().data(nodes).bitmaps(bitmaps).opacity(2f).scale(20, 10); -// vectorOverlay = mTencentMap.addVectorOverlay(provider); -// } -// -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/TrailOverlayActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/TrailOverlayActivity.java deleted file mode 100644 index c7ce6cf..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/TrailOverlayActivity.java +++ /dev/null @@ -1,147 +0,0 @@ -package cc.winboll.studio.positions.demo.heatoverlay; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; - -import android.graphics.Color; -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; - -import com.tencent.map.sdk.utilities.visualization.datamodels.TimeLatLng; -import com.tencent.map.sdk.utilities.visualization.datamodels.TrailLatLng; -import com.tencent.map.sdk.utilities.visualization.trails.TrailOverlayProvider; -import cc.winboll.studio.positions.R; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.MapView; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.VectorOverlay; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.List; - -public class TrailOverlayActivity extends AppCompatActivity { -// private MapView mMapView; -// private TencentMap mTencentMap; -// private VectorOverlay vectorOverlay; -// boolean mIsSelected; -// private TrailOverlayProvider trailOverlayProvider; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// setContentView(R.layout.activity_trail_overlay); -// init(); -// } -// -// @Override -// public boolean onCreateOptionsMenu(Menu menu) { -// getMenuInflater().inflate(R.menu.vectorheatmap, menu); -// return true; -// } -// -// @Override -// public boolean onPrepareOptionsMenu(Menu menu) { -// menu.findItem(R.id.menu_open_vectorheatmap).setVisible(!mIsSelected); -// menu.findItem(R.id.menu_close_vectorheatmap).setVisible(mIsSelected); -// return super.onPrepareOptionsMenu(menu); -// } -// -// @Override -// public boolean onOptionsItemSelected(@NonNull MenuItem item) { -// switch (item.getItemId()) { -// case R.id.menu_open_vectorheatmap: -// addArcLineLayer(); -// break; -// case R.id.menu_close_vectorheatmap: -// mIsSelected = false; -// if (vectorOverlay != null) { -// vectorOverlay.remove(); -// vectorOverlay = null; -// } -// break; -// } -// -// supportInvalidateOptionsMenu(); -// return super.onOptionsItemSelected(item); -// } -// -// @Override -// protected void onResume() { -// super.onResume(); -// mMapView.onResume(); -// } -// -// @Override -// protected void onPause() { -// super.onPause(); -// mMapView.onPause(); -// } -// -// @Override -// protected void onDestroy() { -// super.onDestroy(); -// mMapView.onDestroy(); -// } -// -// -// @Override -// protected void onStart() { -// super.onStart(); -// mMapView.onStart(); -// } -// -// @Override -// protected void onStop() { -// super.onStop(); -// mMapView.onStop(); -// } -// -// private void init() { -// mMapView = findViewById(R.id.mapView); -// mTencentMap = mMapView.getMap(); -// mTencentMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(39.942117, 116.33668), 11)); -// } -// -// private void addArcLineLayer() { -// mIsSelected = true; -// if (vectorOverlay == null) { -// -// mTencentMap.setPoisEnabled(false); -// BufferedReader br = null; -// long currentTime = System.currentTimeMillis(); -// List startLats = new ArrayList<>(); -// try { -// br = new BufferedReader(new InputStreamReader(getResources().getAssets().open("trailData.dat"))); -// -// String line = null; -// while ((line = br.readLine()) != null) { -// String[] oneDot = line.split(","); -// TimeLatLng[] timeLatLngs = new TimeLatLng[oneDot.length]; -// int i = 0; -// for (String timeLatLng : oneDot) { -// String[] values = timeLatLng.split("\t"); -// LatLng latlng = new LatLng((Double.parseDouble(values[0])), (Double.parseDouble(values[1]))); -// int timeStamp = Integer.parseInt(values[2]); -// timeLatLngs[i++] = new TimeLatLng(latlng, timeStamp); -// } -// TrailLatLng tmp = new TrailLatLng(timeLatLngs); -// startLats.add(tmp); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } -// int[] colors = {Color.argb(0xff, 0x00, 0x00, 0xff), -// Color.argb(0x00, 0xff, 0xff, 0x00)}; -// -// trailOverlayProvider = new TrailOverlayProvider().type(TrailOverlayProvider.TrailOverlayType.Trail).data(startLats).opacity(2f).width(10).gradient(colors).setHighlightDuration(8000).setAnimateStartTime(0, 25000); -// vectorOverlay = mTencentMap.addVectorOverlay(trailOverlayProvider); -// -// -// } -// -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/VectorHeatMapActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/VectorHeatMapActivity.java deleted file mode 100644 index 0493afc..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/VectorHeatMapActivity.java +++ /dev/null @@ -1,182 +0,0 @@ -package cc.winboll.studio.positions.demo.heatoverlay; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; -import androidx.fragment.app.FragmentActivity; - -import android.os.Bundle; -import android.util.Log; -import android.view.Menu; -import android.view.MenuItem; -import android.widget.CompoundButton; -import android.widget.ToggleButton; - -import com.tencent.map.sdk.utilities.heatmap.WeightedLatLng; -import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.MapView; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.VectorHeatAggregationUnit; -import com.tencent.tencentmap.mapsdk.maps.model.VectorHeatOverlay; -import com.tencent.tencentmap.mapsdk.maps.model.VectorHeatOverlayOptions; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; - -/** - * 蜂窝热力图 - */ -public class VectorHeatMapActivity extends SupportMapFragmentActivity { - -// MapView mMapView; -// TencentMap mTencentMap; -// VectorHeatOverlay mOverlay; -// boolean mIsSelected; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// setContentView(R.layout.activity_vector_heat_map); -// mMapView = findViewById(R.id.map_view); -// mTencentMap = mMapView.getMap(); -// mTencentMap.moveCamera(CameraUpdateFactory.newLatLngZoom( -// new LatLng(36.139985, 120.402243), -// 11)); -// -// mTencentMap.setOnMapClickListener(new TencentMap.OnMapClickListener() { -// @Override -// public void onMapClick(LatLng latlng) { -// if (mOverlay == null) { -// return; -// } -// VectorHeatAggregationUnit unit = mOverlay.getUnit(latlng); -// if (unit == null) { -// Log.e("VectorHeatMapActivity", "no unit found"); -// return; -// } -// Log.e("VectorHeatMapActivity", "unit center:" + unit.getCenter() + -// ", intensity:" + unit.getIntensity() + -// ", size:" + unit.getNodes().length); -// } -// }); -// } -// -// @Override -// public boolean onCreateOptionsMenu(Menu menu) { -// getMenuInflater().inflate(R.menu.vectorheatmap, menu); -// return true; -// } -// -// @Override -// public boolean onPrepareOptionsMenu(Menu menu) { -// menu.findItem(R.id.menu_open_vectorheatmap).setVisible(!mIsSelected); -// menu.findItem(R.id.menu_close_vectorheatmap).setVisible(mIsSelected); -// return super.onPrepareOptionsMenu(menu); -// } -// -// @Override -// public boolean onOptionsItemSelected(@NonNull MenuItem item) { -// switch (item.getItemId()) { -// case R.id.menu_open_vectorheatmap: -// addVectorHeatMap(); -// break; -// case R.id.menu_close_vectorheatmap: -// removeVectorHeatMap(); -// break; -// } -// -// supportInvalidateOptionsMenu(); -// return super.onOptionsItemSelected(item); -// } -// -// private ArrayList getHeatNodes() { -// BufferedReader br = null; -// ArrayList nodes = null; -// try { -// nodes = new ArrayList<>(); -// br = new BufferedReader(new InputStreamReader( -// getResources().getAssets().open("honeycomb.txt"))); -// String line; -// while ((line = br.readLine()) != null) { -// String[] lines = line.split("\t"); -// if (lines.length == 3) { -// double value = Double.parseDouble(lines[2]); -// LatLng latLng = new LatLng((Double.parseDouble(lines[1])), -// (Double.parseDouble(lines[0]))); -// nodes.add(new WeightedLatLng(latLng, 1)); -// } -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } finally { -// if (br != null) { -// try { -// br.close(); -// } catch (IOException e) { -// e.printStackTrace(); -// } -// } -// return nodes; -// } -// } -// -// @Override -// protected void onResume() { -// super.onResume(); -// if (mMapView != null) { -// mMapView.onResume(); -// } -// } -// -// @Override -// protected void onPause() { -// super.onPause(); -// if (mMapView != null) { -// mMapView.onPause(); -// } -// } -// -// @Override -// protected void onStop() { -// super.onStop(); -// if (mMapView != null) { -// mMapView.onStop(); -// } -// } -// -// @Override -// protected void onDestroy() { -// super.onDestroy(); -// if (mMapView != null) { -// mMapView.onDestroy(); -// } -// } -// -// private void addVectorHeatMap() { -// mIsSelected = true; -// if (mOverlay != null) { -// return; -// } -// WeightedLatLng[] nodes = getHeatNodes().toArray(new WeightedLatLng[0]); -// VectorHeatOverlayOptions options = new VectorHeatOverlayOptions() -// .nodes(nodes) -// .size(2000) -// .gap(100) -// .colors(new int[]{0x45fa4b14, 0x99fa4b14, 0xd9fa4b14}) -// .startPoints(new double[]{0, 0.6, 0.8}); -// mOverlay = mTencentMap.addVectorHeatOverlay(options); -// } -// -// public void removeVectorHeatMap() { -// mIsSelected = false; -// if (mOverlay == null) { -// return; -// } -// mOverlay.remove(); -// mOverlay = null; -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/location/LocationLayerActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/location/LocationLayerActivity.java deleted file mode 100644 index 262ce9b..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/location/LocationLayerActivity.java +++ /dev/null @@ -1,252 +0,0 @@ -package cc.winboll.studio.positions.demo.location; - -import android.Manifest; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Matrix; -import android.location.Location; -import android.os.Looper; - -import androidx.annotation.NonNull; - -import android.os.Bundle; -import android.util.Log; -import android.view.View; -import android.widget.RadioGroup; -import android.widget.Toast; - -import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.google.gson.Gson; -import com.tencent.map.geolocation.TencentLocation; -import com.tencent.map.geolocation.TencentLocationListener; -import com.tencent.map.geolocation.TencentLocationManager; -import com.tencent.map.geolocation.TencentLocationRequest; -import com.tencent.tencentmap.mapsdk.maps.LocationSource; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle; - -import java.util.List; - -import pub.devrel.easypermissions.EasyPermissions; -import com.tencent.tencentmap.mapsdk.maps.LocationSource.OnLocationChangedListener; - -//public class LocationLayerActivity extends SupportMapFragmentActivity implements EasyPermissions.PermissionCallbacks, LocationSource, TencentLocationListener, TencentMap.OnMapLongClickListener, RadioGroup.OnCheckedChangeListener { -// -// private OnLocationChangedListener locationChangedListener; -// -// private TencentLocationManager locationManager; -// private TencentLocationRequest locationRequest; -// private MyLocationStyle locationStyle; -// private RadioGroup radioGroup; -// -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// -// -// //定位需要申请的权限 -// String[] perms = { -// Manifest.permission.ACCESS_FINE_LOCATION, -// Manifest.permission.ACCESS_COARSE_LOCATION, -// Manifest.permission.READ_PHONE_STATE -// }; -// -// if (EasyPermissions.hasPermissions(this, perms)) {//检查是否获取该权限 -// Log.i("location", "已获取权限"); -// } else { -// EasyPermissions.requestPermissions(this, "必要的权限", 0, perms); -// } -// //设置显示定位的图标 -// mapUiSettings.setMyLocationButtonEnabled(true); -// tencentMap.setOnMapLongClickListener(this); -// -// radioGroup = findViewById(R.id.location_type); -// radioGroup.setVisibility(View.VISIBLE); -// radioGroup.setOnCheckedChangeListener(this); -// -// //建立定位 -// initLocation(); -// //SDK版本4.3.5新增内置定位标点击回调监听 -// tencentMap.setMyLocationClickListener(new TencentMap.OnMyLocationClickListener() { -// @Override -// public boolean onMyLocationClicked(LatLng latLng) { -// Toast.makeText(LocationLayerActivity.this, "内置定位标点击回调", Toast.LENGTH_SHORT).show(); -// return true; -// } -// }); -// } -// -// /** -// * 定位的一些初始化设置 -// */ -// private void initLocation() { -// //用于访问腾讯定位服务的类, 周期性向客户端提供位置更新 -// locationManager = TencentLocationManager.getInstance(this); -// //设置坐标系 -// locationManager.setCoordinateType(TencentLocationManager.COORDINATE_TYPE_GCJ02); -// //创建定位请求 -// locationRequest = TencentLocationRequest.create(); -// //设置定位周期(位置监听器回调周期)为3s -// locationRequest.setInterval(3000); -// -// //地图上设置定位数据源 -// tencentMap.setLocationSource(this); -// //设置当前位置可见 -// tencentMap.setMyLocationEnabled(true); -// //设置定位图标样式 -// setLocMarkerStyle(); -// tencentMap.setMyLocationStyle(locationStyle); -// } -// -// /** -// * 设置定位图标样式 -// */ -// private void setLocMarkerStyle() { -// locationStyle = new MyLocationStyle(); -// //创建图标 -// BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.location_icon)); -// locationStyle.icon(bitmapDescriptor); -// //设置定位圆形区域的边框宽度 -// locationStyle.strokeWidth(3); -// //设置圆区域的颜色 -// locationStyle.fillColor(R.color.style); -// } -// -// private Bitmap getBitMap(int resourceId) { -// Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId); -// int width = bitmap.getWidth(); -// int height = bitmap.getHeight(); -// int newWidth = 55; -// int newHeight = 55; -// float widthScale = ((float) newWidth) / width; -// float heightScale = ((float) newHeight) / height; -// Matrix matrix = new Matrix(); -// matrix.postScale(widthScale, heightScale); -// bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); -// return bitmap; -// } -// -// /** -// * 实现位置监听 -// * -// * @param tencentLocation -// * @param i -// * @param s -// */ -// @Override -// public void onLocationChanged(TencentLocation tencentLocation, int i, String s) { -// -// if (i == TencentLocation.ERROR_OK && locationChangedListener != null) { -// Location location = new Location(tencentLocation.getProvider()); -// //设置经纬度以及精度 -// location.setLatitude(tencentLocation.getLatitude()); -// location.setLongitude(tencentLocation.getLongitude()); -// location.setAccuracy(tencentLocation.getAccuracy()); -// locationChangedListener.onLocationChanged(location); -// -// //显示回调的实时位置信息 -// runOnUiThread(new Runnable() { -// @Override -// public void run() { -// //打印tencentLocation的json字符串 -//// Toast.makeText(getApplicationContext(), new Gson().toJson(location), Toast.LENGTH_LONG).show(); -// } -// }); -// } -// } -// -// @Override -// public void onStatusUpdate(String s, int i, String s1) { -// //GPS, WiFi, Radio 等状态发生变化 -// Log.v("State changed", s + "===" + s1); -// } -// -// -// @Override -// public void activate(OnLocationChangedListener onLocationChangedListener) { -// locationChangedListener = onLocationChangedListener; -// -// int err = locationManager.requestLocationUpdates(locationRequest, this, Looper.myLooper()); -// switch (err) { -// case 1: -// Toast.makeText(this, "设备缺少使用腾讯定位服务需要的基本条件", Toast.LENGTH_SHORT).show(); -// break; -// case 2: -// Toast.makeText(this, "manifest 中配置的 key 不正确", Toast.LENGTH_SHORT).show(); -// break; -// case 3: -// Toast.makeText(this, "自动加载libtencentloc.so失败", Toast.LENGTH_SHORT).show(); -// break; -// -// default: -// break; -// } -// } -// -// @Override -// public void deactivate() { -// locationManager.removeUpdates(this); -// locationManager = null; -// locationRequest = null; -// locationChangedListener = null; -// } -// -// @Override -// public void onPermissionsGranted(int requestCode, @NonNull List perms) { -// Log.e("location quest: ", "success"); -// } -// -// @Override -// public void onPermissionsDenied(int requestCode, @NonNull List perms) { -// Log.e("location quest: ", "failed"); -// } -// -// @Override -// public void onMapLongClick(LatLng latLng) { -// Location location = new Location("LongPressLocationProvider"); -// location.setLatitude(latLng.latitude); -// location.setLongitude(latLng.longitude); -// location.setAccuracy(20); -// locationChangedListener.onLocationChanged(location); -// Log.i("long click", new Gson().toJson(latLng)); -// } -// -// @Override -// public void onCheckedChanged(RadioGroup radioGroup, int i) { -// switch (i) { -// //连续定位,但不会移动到地图中心点,并且会跟随设备移动 -// case R.id.btn_follow_no_center: -// -// initLocation(); -// locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_FOLLOW_NO_CENTER); -// tencentMap.setMyLocationStyle(locationStyle); -// break; -// //连续定位,且将视角移动到地图中心,定位点依照设备方向旋转,并且会跟随设备移动,默认是此种类型 -// case R.id.btn_location_rotate: -// -// initLocation(); -// locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE); -// tencentMap.setMyLocationStyle(locationStyle); -// break; -// //连续定位,但不会移动到地图中心点,定位点依照设备方向旋转,并且跟随设备移动 -// case R.id.btn_location_rotate_no_center: -// -// initLocation(); -// locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER); -// tencentMap.setMyLocationStyle(locationStyle); -// break; -// //连续定位,但不会移动到地图中心点,地图依照设备方向旋转,并且会跟随设备移动 -// case R.id.btn_map_rotate_no_center: -// -// initLocation(); -// locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_MAP_ROTATE_NO_CENTER); -// tencentMap.setMyLocationStyle(locationStyle); -// break; -// } -// } -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/location/LocationPointActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/location/LocationPointActivity.java deleted file mode 100644 index cb6eeda..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/location/LocationPointActivity.java +++ /dev/null @@ -1,216 +0,0 @@ -package cc.winboll.studio.positions.demo.location; - -import android.Manifest; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Matrix; -import android.location.Location; -import android.os.Bundle; -import android.os.Looper; -import androidx.annotation.NonNull; -import android.util.Log; -import android.widget.Toast; - -import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.map.geolocation.TencentLocation; -import com.tencent.map.geolocation.TencentLocationListener; -import com.tencent.map.geolocation.TencentLocationManager; -import com.tencent.map.geolocation.TencentLocationRequest; -import com.tencent.tencentmap.mapsdk.maps.LocationSource; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -import com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle; - -import java.util.List; - -import pub.devrel.easypermissions.EasyPermissions; -import com.tencent.tencentmap.mapsdk.maps.LocationSource.OnLocationChangedListener; - -public class LocationPointActivity extends SupportMapFragmentActivity implements EasyPermissions.PermissionCallbacks,LocationSource, TencentLocationListener { - - @Override - public void onPermissionsGranted(int p1, List p2) { - } - - @Override - public void onPermissionsDenied(int p1, List p2) { - } - - @Override - public void activate(LocationSource.OnLocationChangedListener p1) { - } - - @Override - public void deactivate() { - } - - @Override - public void onLocationChanged(TencentLocation p1, int p2, String p3) { - } - - @Override - public void onStatusUpdate(String p1, int p2, String p3) { - } - -// private LocationSource.OnLocationChangedListener locationChangedListener; -// -// private TencentLocationManager locationManager; -// private TencentLocationRequest locationRequest; -// private MyLocationStyle locationStyle; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// -// -// //定位需要申请的权限 -// String[] perms = { -// Manifest.permission.ACCESS_FINE_LOCATION, -// Manifest.permission.ACCESS_COARSE_LOCATION, -// Manifest.permission.READ_PHONE_STATE -// }; -// -// if (EasyPermissions.hasPermissions(this, perms)) {//检查是否获取该权限 -// Log.i("location", "已获取权限"); -// } else { -// EasyPermissions.requestPermissions(this, "必要的权限", 0, perms); -// } -// //设置显示定位的图标 -// TencentLocationManager.setUserAgreePrivacy(true); -// //建立定位 -// initLocation(); -// } -// -// -// /** -// * 设置定位图标样式 -// */ -// private void setLocMarkerStyle(){ -// locationStyle = new MyLocationStyle(); -// //创建图标 -// BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.marker)); -// locationStyle.icon(bitmapDescriptor); -// //设置定位圆形区域的边框宽度 -// locationStyle.strokeWidth(3); -// //设置圆区域的颜色 -// locationStyle.fillColor(R.color.style); -// -// tencentMap.setMyLocationStyle(locationStyle); -// } -// -// -// -// private Bitmap getBitMap(int resourceId){ -// Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId); -// int width = bitmap.getWidth(); -// int height = bitmap.getHeight(); -// int newWidth = 55; -// int newHeight = 55; -// float widthScale = ((float)newWidth)/width; -// float heightScale = ((float)newHeight)/height; -// Matrix matrix = new Matrix(); -// matrix.postScale(widthScale, heightScale); -// bitmap = Bitmap.createBitmap(bitmap,0,0,width,height,matrix,true); -// return bitmap; -// } -// -// -// -// /** -// * 定位的一些初始化设置 -// */ -// private void initLocation(){ -// //用于访问腾讯定位服务的类, 周期性向客户端提供位置更新 -// locationManager = TencentLocationManager.getInstance(this); -// //设置坐标系 -// locationManager.setCoordinateType(TencentLocationManager.COORDINATE_TYPE_GCJ02); -// //创建定位请求 -// locationRequest = TencentLocationRequest.create(); -// //设置定位周期(位置监听器回调周期)为3s -// locationRequest.setInterval(3000); -// -// //地图上设置定位数据源 -// tencentMap.setLocationSource(this); -// //设置当前位置可见 -// tencentMap.setMyLocationEnabled(true); -// //设置定位图标样式 -// setLocMarkerStyle(); -//// locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE); -// tencentMap.setMyLocationStyle(locationStyle); -// } -// /** -// * 实现位置监听 -// * @param tencentLocation -// * @param i -// * @param s -// */ -// @Override -// public void onLocationChanged(TencentLocation tencentLocation, int i, String s) { -// -// if(i == TencentLocation.ERROR_OK && locationChangedListener != null){ -// Location location = new Location(tencentLocation.getProvider()); -// //设置经纬度以及精度 -// location.setLatitude(tencentLocation.getLatitude()); -// location.setLongitude(tencentLocation.getLongitude()); -// location.setAccuracy(tencentLocation.getAccuracy()); -// locationChangedListener.onLocationChanged(location); -// -// //显示回调的实时位置信息 -// runOnUiThread(new Runnable() { -// @Override -// public void run() { -// //打印tencentLocation的json字符串 -//// Toast.makeText(getApplicationContext(), new Gson().toJson(location), Toast.LENGTH_LONG).show(); -// } -// }); -// } -// } -// -// @Override -// public void onStatusUpdate(String s, int i, String s1) { -// //GPS, WiFi, Radio 等状态发生变化 -// Log.v("State changed", s +"===" + s1); -// } -// -// -// @Override -// public void activate(OnLocationChangedListener onLocationChangedListener) { -// locationChangedListener = onLocationChangedListener; -// -// int err = locationManager.requestLocationUpdates(locationRequest, this, Looper.myLooper()); -// switch (err) { -// case 1: -// Toast.makeText(this,"设备缺少使用腾讯定位服务需要的基本条件",Toast.LENGTH_SHORT).show(); -// break; -// case 2: -// Toast.makeText(this,"manifest 中配置的 key 不正确",Toast.LENGTH_SHORT).show(); -// break; -// case 3: -// Toast.makeText(this,"自动加载libtencentloc.so失败",Toast.LENGTH_SHORT).show(); -// break; -// -// default: -// break; -// } -// } -// -// @Override -// public void deactivate() { -// locationManager.removeUpdates(this); -// locationManager = null; -// locationRequest = null; -// locationChangedListener=null; -// } -// -// @Override -// public void onPermissionsGranted(int requestCode, @NonNull List perms) { -// Log.e("location quest: ","success"); -// } -// -// @Override -// public void onPermissionsDenied(int requestCode, @NonNull List perms) { -// Log.e("location quest: ","failed"); -// } -// -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/CustomRenderActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/marker/CustomRenderActivity.java deleted file mode 100644 index 63256b5..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/CustomRenderActivity.java +++ /dev/null @@ -1,281 +0,0 @@ -package cc.winboll.studio.positions.demo.marker; - -//import androidx.appcompat.app.AppCompatActivity; -// -//import android.graphics.PointF; -//import android.opengl.GLES20; -//import android.os.Bundle; -//import android.util.Log; -// -//import cc.winboll.studio.positions.R; -//import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -//import com.tencent.tencentmap.mapsdk.maps.CustomRender; -//import com.tencent.tencentmap.mapsdk.maps.MapView; -//import com.tencent.tencentmap.mapsdk.maps.TencentMap; -//import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -//import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -// -//import java.nio.ByteBuffer; -//import java.nio.ByteOrder; -//import java.nio.FloatBuffer; -//import java.nio.ShortBuffer; -// -///** -// * OpenGL绘制 -// */ -//public class CustomRenderActivity extends AppCompatActivity { -// -// private static final String TAG = CustomRenderActivity.class.getSimpleName(); -// -// // 标识是否第一次绘制3D立方体 -// private boolean mIsFirstDraw3DCube = true; -// -// // 立方体8个顶点坐标 -// private float[] mVertices = { -// -1, -1, -0, -// 1, -1, -0, -// 1, 1, -0, -// -1, 1, -0, -// -1, -1, 1, -// 1, -1, 1, -// 1, 1, 1, -// -1, 1, 1, -// }; -// -// // 3D立方体顶点绘制顺序列表 -// private short[] mDrawIndices = { -// 5, 4, 0, 1, 5, 0, 6, 5, 1, 2, 6, 1, -// 7, 6, 2, 3, 7, 2, 4, 7, 3, 0, 4, 3, -// 6, 7, 4, 5, 6, 4, 1, 0, 3, 2, 1, 3 -// }; -// -// // 3D立方体8个顶点颜色值 -// private float[] mVertexColors = { -// 1f, 1f, 0f, 1f, -// 0f, 1f, 1f, 1f, -// 1f, 0f, 1f, 1f, -// 0f, 0f, 0f, 1f, -// 1f, 1f, 1f, 1f, -// 1f, 0f, 0f, 1f, -// 0f, 1f, 0f, 1f, -// 0f, 0f, 1f, 1f -// }; -// -// // 立方体顶点坐标Buffer -// private FloatBuffer mVertexBuffer; -// -// // 顶点绘制顺序Buffer -// private ShortBuffer mIndexBuffer; -// -// // 立方体顶点颜色Buffer -// private FloatBuffer mColorBuffer; -// -// // 3D立方体着色器 -// private CubeShader mCubeShader; -// -// private MapView mapView; -// -// private TencentMap mMap; -// -// private LatLng latlng = new LatLng(40.04199816,116.27479076); -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// setContentView(R.layout.activity_custom_render); -// mapView = findViewById(R.id.map_view); -// mMap = mapView.getMap(); -// mMap.addOnMapLoadedCallback(new TencentMap.OnMapLoadedCallback() { -// @Override -// public void onMapLoaded() { -// mMap.setCustomRender(new CubeRender()); -// mMap.removeOnMapLoadedCallback(this); -// } -// }); -// -// mMap.moveCamera(CameraUpdateFactory.newCameraPosition(CameraPosition.builder() -// .target(latlng).zoom(16).tilt(45).build())); -// -// -// } -// -// @Override -// protected void onResume() { -// // TODO Auto-generated method stub -// super.onResume(); -// mapView.onResume(); -// } -// -// @Override -// protected void onDestroy() { -// // TODO Auto-generated method stub -// super.onDestroy(); -// mapView.onDestroy(); -// } -// -// private class CubeRender implements CustomRender { -// -// private void initCubeData(float width, float height, float depth) { -// // 对标地图坐标 -// initVertices(mVertices, width, height, depth); -// -// // 立方体顶点数据Buffer -// mVertexBuffer = ByteBuffer.allocateDirect(mVertices.length * 4) -// .order(ByteOrder.nativeOrder()) -// .asFloatBuffer(); -// mVertexBuffer.put(mVertices).position(0); -// -// // 立方体顶点绘制顺序Buffer -// ByteBuffer byteBuffer = ByteBuffer.allocateDirect(mDrawIndices.length * 4); -// byteBuffer.order(ByteOrder.nativeOrder()); -// mIndexBuffer = byteBuffer.asShortBuffer(); -// mIndexBuffer.put(mDrawIndices); -// mIndexBuffer.position(0); -// -// // 立方体顶点颜色Buffer -// ByteBuffer byteBuffer1 = ByteBuffer.allocateDirect(mVertexColors.length * 4); -// byteBuffer1.order(ByteOrder.nativeOrder()); -// mColorBuffer = byteBuffer1.asFloatBuffer(); -// mColorBuffer.put(mVertexColors); -// mColorBuffer.position(0); -// } -// -// private void initCubeShader() { -// mCubeShader = new CubeShader(); -// mCubeShader.init(); -// } -// -// private void initVertices(float[] vertices, float width, float height, float depth) { -// for (int i = 0; i < vertices.length / 3; i++) { -// int m = i * 3; -// vertices[m] = vertices[m] * width; -// vertices[m + 1] = vertices[m + 1] * height; -// vertices[m + 2] = vertices[m + 2] * depth; -// } -// } -// -// @Override -// public void onDrawFrame() { -// drawCube(); -// } -// -// private void drawCube() { -// -// if (mIsFirstDraw3DCube) { -// float cubeWidth = 0.2f * 10000 / 2; -// float cubeHeight = 0.2f * 10000 / 2; -// float cubeDepth = 0.4f * 10000 / 2; -// initCubeData(cubeWidth, cubeHeight, cubeDepth); -// initCubeShader(); -// mIsFirstDraw3DCube = false; -// } -// -// if (null == mCubeShader) { -// return; -// } -// -// // 绑定地图移动 -// PointF p1f = mMap.getProjection().glVertexForCoordinate(latlng); -// float[] mvpMatrix = mMap.getProjection().glModelMatrix(p1f, 1); -// -// // Step2 开始绘制设置 -// GLES20.glUseProgram(mCubeShader.mProgram); -// checkGlError("glUseProgram"); -// -// GLES20.glEnable(GLES20.GL_DEPTH_TEST); -// checkGlError("glEnable"); -// -// //对齐矩阵 -// GLES20.glUniformMatrix4fv(mCubeShader.mMvpMatrix, 1, false, mvpMatrix, 0); -// checkGlError("glUniformMatrix4fv"); -// -// GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); -// // 顶点指针 -// GLES20.glEnableVertexAttribArray(mCubeShader.mVertex); -// checkGlError("glEnableVertexAttribArray"); -// GLES20.glVertexAttribPointer(mCubeShader.mVertex, 3, GLES20.GL_FLOAT, false, 0, mVertexBuffer); -// checkGlError("glVertexAttribPointer"); -// -// // 颜色指针 -// GLES20.glEnableVertexAttribArray(mCubeShader.mColor); -// checkGlError("glEnableVertexAttribArray"); -// GLES20.glVertexAttribPointer(mCubeShader.mColor, 4, GLES20.GL_FLOAT, false, 0, mColorBuffer); -// checkGlError("glVertexAttribPointer"); -// -// GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0); -// // 开始画 -// GLES20.glDrawElements(GLES20.GL_TRIANGLES, mDrawIndices.length, GLES20.GL_UNSIGNED_SHORT, mIndexBuffer); -// checkGlError("glDrawElements"); -// -// GLES20.glDisableVertexAttribArray(mCubeShader.mVertex); -// checkGlError("glDisableVertexAttribArray"); -// -// GLES20.glDisable(GLES20.GL_DEPTH_TEST); -// checkGlError("glDisable"); -// } -// } -// -// private static class CubeShader { -// int mVertex; -// int mMvpMatrix; -// int mColor; -// int mProgram; -// -// String vertexShader = "precision mediump float;\n" + -// " attribute vec3 mVertex;//顶点数组,三维坐标\n" + -// " attribute vec4 mColor;//颜色数组,三维坐标\n" + -// " uniform mat4 mMvpMatrix;//mvp矩阵\n" + -// " varying vec4 color;//\n" + -// " void main(){\n" + -// " gl_Position = mMvpMatrix * vec4(mVertex, 1.0);\n" + -// " color = mColor;\n" + -// " }"; -// -// String fragmentShader = "//有颜色 没有纹理\n" + -// " precision mediump float;\n" + -// " varying vec4 color;//\n" + -// " void main(){\n" + -// " gl_FragColor = color;\n" + -// " }"; -// -// public void init() { -// int vertexLocation = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER); -// GLES20.glShaderSource(vertexLocation, vertexShader); -// checkGlError("glShaderSource"); -// GLES20.glCompileShader(vertexLocation); -// checkGlError("glCompileShader"); -// int fragmentLocation = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER); -// GLES20.glShaderSource(fragmentLocation, fragmentShader); -// checkGlError("glShaderSource"); -// GLES20.glCompileShader(fragmentLocation); -// checkGlError("glCompileShader"); -// -// mProgram = GLES20.glCreateProgram(); -// GLES20.glAttachShader(mProgram, vertexLocation); -// GLES20.glAttachShader(mProgram, fragmentLocation); -// GLES20.glLinkProgram(mProgram); -// int[] linked = new int[1]; -// GLES20.glGetProgramiv(mProgram, GLES20.GL_LINK_STATUS, linked, 0); -// checkGlError("glLinkProgram"); -// if (linked[0] != GLES20.GL_TRUE) { -// Log.e(TAG, "Could not link program: "); -// Log.e(TAG, GLES20.glGetProgramInfoLog(mProgram)); -// GLES20.glDeleteProgram(mProgram); -// mProgram = 0; -// } -// -// -// mVertex = GLES20.glGetAttribLocation(mProgram, "mVertex"); -// mMvpMatrix = GLES20.glGetUniformLocation(mProgram, "mMvpMatrix"); -// mColor = GLES20.glGetAttribLocation(mProgram, "mColor"); -// } -// -// } -// -// static void checkGlError(String op) { -// int error; -// while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { -// Log.e(TAG, op + ": glError " + error); -// } -// } -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/GroundOverlayActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/marker/GroundOverlayActivity.java deleted file mode 100644 index fda3814..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/GroundOverlayActivity.java +++ /dev/null @@ -1,129 +0,0 @@ -package cc.winboll.studio.positions.demo.marker; - -//import androidx.annotation.NonNull; -//import androidx.appcompat.app.AppCompatActivity; -//import androidx.fragment.app.FragmentActivity; -// -//import android.os.Bundle; -//import android.view.Menu; -//import android.view.MenuItem; -//import android.view.View; -//import android.widget.Button; -//import android.widget.RadioGroup; -// -// -//import cc.winboll.studio.positions.R; -//import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -//import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -//import com.tencent.tencentmap.mapsdk.maps.MapView; -//import com.tencent.tencentmap.mapsdk.maps.TencentMap; -//import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -//import com.tencent.tencentmap.mapsdk.maps.model.GroundOverlay; -//import com.tencent.tencentmap.mapsdk.maps.model.GroundOverlayOptions; -//import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -//import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds; -//import com.tencent.tencentmap.mapsdk.maps.model.OverlayLevel; -// -//import java.util.ArrayList; -// -//public class GroundOverlayActivity extends SupportMapFragmentActivity { -// -// private MapView mMapView; -// private TencentMap mTencentMap; -// private GroundOverlay groundOverlay; -// GroundOverlayOptions groundOverlayOptions; -// private boolean mIsSelected; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// setContentView(R.layout.activity_ground_overlay); -// mMapView = findViewById(R.id.map_view); -// mTencentMap = mMapView.getMap(); -// mTencentMap.setIndoorEnabled(true); -// } -// -// -// @Override -// protected void onResume() { -// super.onResume(); -// mMapView.onResume(); -// } -// -// @Override -// protected void onPause() { -// super.onPause(); -// mMapView.onPause(); -// } -// -// @Override -// protected void onDestroy() { -// super.onDestroy(); -// mMapView.onDestroy(); -// } -// -// -// @Override -// protected void onStart() { -// super.onStart(); -// mMapView.onStart(); -// } -// -// @Override -// protected void onStop() { -// super.onStop(); -// mMapView.onStop(); -// } -// -// @Override -// public boolean onCreateOptionsMenu(Menu menu) { -// getMenuInflater().inflate(R.menu.marker_groundoverlay, menu); -// return true; -// } -// -// @Override -// public boolean onPrepareOptionsMenu(Menu menu) { -// menu.findItem(R.id.menu_add_groundoverlay).setVisible(!mIsSelected); -// menu.findItem(R.id.menu_remove_groundoverlay).setVisible(mIsSelected); -// return super.onPrepareOptionsMenu(menu); -// } -// -// @Override -// public boolean onOptionsItemSelected(@NonNull MenuItem item) { -// switch (item.getItemId()) { -// case R.id.menu_add_groundoverlay: -// addGroundOverlays(); -// break; -// case R.id.menu_remove_groundoverlay: -// removeGroundOverlays(); -// break; -// } -// -// supportInvalidateOptionsMenu(); -// return super.onOptionsItemSelected(item); -// } -// -// public void addGroundOverlays() { -// mIsSelected = true; -// LatLngBounds lb = new LatLngBounds( -// new LatLng(40.045226, 116.280069), -// new LatLng(40.038918, 116.271873)); -// groundOverlayOptions = new GroundOverlayOptions() -// .bitmap(BitmapDescriptorFactory -// .fromAsset("groundoverlay.jpg")) -// .latLngBounds(lb) -// .alpha(10); -// groundOverlay = mTencentMap.addGroundOverlay(groundOverlayOptions); -// mTencentMap.moveCamera(CameraUpdateFactory.newLatLngBounds(lb, 300)); -// -// } -// -// public void removeGroundOverlays() { -// mIsSelected = false; -// if (groundOverlay != null) { -// groundOverlay.remove(); -// groundOverlay = null; -// } -// } -// -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerActivity.java deleted file mode 100644 index 1c2112f..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerActivity.java +++ /dev/null @@ -1,74 +0,0 @@ -package cc.winboll.studio.positions.demo.marker; - -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Matrix; -import android.os.Bundle; -import android.view.View; -import android.widget.CompoundButton; -import android.widget.Switch; - -import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.Marker; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; - -public class MarkerActivity extends SupportMapFragmentActivity { -// public Marker marker; -// public Switch aSwitch; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// aSwitch = findViewById(R.id.switch_map); -// aSwitch.setVisibility(View.VISIBLE); -// aSwitch.setText("添加标注"); -// setMarker(); -// aSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { -// @Override -// public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { -// if(isChecked){ -// setMarker(); -// }else { -// if(marker!=null){ -// marker.remove(); -// } -// } -// } -// }); -// -// } -// -// /** -// * 设置标注 -// */ -// private void setMarker(){ -// LatLng latLng = new LatLng(39.984108,116.307557); -// BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.marker)); -// MarkerOptions options = new MarkerOptions().position(latLng).icon(bitmapDescriptor); -// -// //设置infowindow -// options.title("地址"); -// options.snippet("中国技术交易大厦"); -// marker = tencentMap.addMarker(options); -// marker.setInfoWindowEnable(true); -// } -// -// -// private Bitmap getBitMap(int resourceId){ -// Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId); -// int width = bitmap.getWidth(); -// int height = bitmap.getHeight(); -// int newWidth = 100; -// int newHeight = 100; -// float widthScale = ((float)newWidth)/width; -// float heightScale = ((float)newHeight)/height; -// Matrix matrix = new Matrix(); -// matrix.postScale(widthScale, heightScale); -// bitmap = Bitmap.createBitmap(bitmap,0,0,width,height,matrix,true); -// return bitmap; -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerAnimation.java b/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerAnimation.java deleted file mode 100644 index 39a58d5..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerAnimation.java +++ /dev/null @@ -1,235 +0,0 @@ -package cc.winboll.studio.positions.demo.marker; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Matrix; -import android.graphics.Point; -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.animation.AccelerateDecelerateInterpolator; -import android.view.animation.Interpolator; - -import androidx.annotation.Nullable; - -import cc.winboll.studio.positions.demo.AbsMapActivity; -import cc.winboll.studio.positions.R; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.AnimationListener; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.IAlphaAnimation; -import com.tencent.tencentmap.mapsdk.maps.model.IAnimationSet; -import com.tencent.tencentmap.mapsdk.maps.model.IRotateAnimation; -import com.tencent.tencentmap.mapsdk.maps.model.IScaleAnimation; -import com.tencent.tencentmap.mapsdk.maps.model.ITranslateAnimation; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.Marker; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; -import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; - -import java.util.ArrayList; -import java.util.List; -import java.util.Timer; -import java.util.TimerTask; - -public class MarkerAnimation extends AbsMapActivity { - -// private int rotate = 0; -// private int scale = 1; -// private int alpha = 2; -// private int translate = 3; -// private int set = 4; -// private boolean mHasAdded; -// private Marker marker; -// private IRotateAnimation rotateAnimation; -// private IScaleAnimation scaleAnimation; -// private IAlphaAnimation alphaAnimation; -// private ITranslateAnimation translateAnimation; -// private TencentMap tencentMap; -// private IAnimationSet animationSet; -// private LatLng latLng; -// -// @Override -// protected void onCreate(@Nullable Bundle savedInstanceState, TencentMap mTencentMap) { -// super.onCreate(savedInstanceState, mTencentMap); -// tencentMap = mTencentMap; -// tencentMap.moveCamera(CameraUpdateFactory.zoomTo(15)); -// } -// -// @Override -// public boolean onCreateOptionsMenu(Menu menu) { -// getMenuInflater().inflate(R.menu.marker_animation, menu); -// return true; -// } -// -// @Override -// public boolean onPrepareOptionsMenu(Menu menu) { -// menu.findItem(R.id.menu_add_marker).setVisible(!mHasAdded); -// menu.findItem(R.id.menu_delete_marker).setVisible(mHasAdded); -// return super.onPrepareOptionsMenu(menu); -// } -// -// @Override -// public boolean onOptionsItemSelected(MenuItem item) { -// switch (item.getItemId()) { -// case R.id.menu_add_marker_rotate: -// tencentMap.clear(); -// marker = tencentMap.addMarker(setMarkerAnimation(rotate)); -// mHasAdded = true; -// marker.setAnimation(rotateAnimation); -// marker.startAnimation(); -// break; -// -// case R.id.menu_add_marker_scale: -// tencentMap.clear(); -// marker = tencentMap.addMarker(setMarkerAnimation(scale)); -// mHasAdded = true; -// marker.setAnimation(scaleAnimation); -// marker.startAnimation(); -// scaleAnimation.setAnimationListener(new AnimationListener() { -// @Override -// public void onAnimationStart() { -// -// } -// -// @Override -// public void onAnimationEnd() { -// marker.startAnimation(); -// } -// }); -// -// -// break; -// case R.id.menu_add_marker_alpha: -// tencentMap.clear(); -// marker = tencentMap.addMarker(setMarkerAnimation(alpha)); -// mHasAdded = true; -// marker.setAnimation(alphaAnimation); -// marker.startAnimation(); -// break; -// case R.id.menu_add_marker_translate: -// tencentMap.clear(); -// marker = tencentMap.addMarker(setMarkerAnimation(translate)); -// mHasAdded = true; -// Point screenLocation = tencentMap.getProjection().toScreenLocation(latLng); -// -// marker.setFixingPoint(screenLocation.x, screenLocation.y); -// -// marker.setAnimation(translateAnimation); -// marker.startAnimation(); -// -// translateAnimation.setAnimationListener(new AnimationListener() { -// @Override -// public void onAnimationStart() { -// -// } -// -// @Override -// public void onAnimationEnd() { -// marker.setFixingPointEnable(false); -// -// } -// }); -// break; -// case R.id.menu_add_marker_set: -// tencentMap.clear(); -// marker = tencentMap.addMarker(setMarkerAnimation(set)); -// mHasAdded = true; -// marker.setAnimation(animationSet); -// marker.startAnimation(); -// break; -// -// case R.id.menu_delete_marker: -// if (marker != null) { -// marker.remove(); -// marker = null; -// mHasAdded = false; -// } -// break; -// } -// return super.onOptionsItemSelected(item); -// } -// -// private MarkerOptions setMarkerAnimation(int type) { -// latLng = new LatLng(39.984108, 116.307557); -// BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.marker)); -// MarkerOptions position = new MarkerOptions().position(latLng).icon(bitmapDescriptor); -// switch (type) { -// case 0: -// //旋转动画 -// rotateAnimation = tencentMap.getMapContext().createRotateAnimation(0, 360, 0, 0, 0); -// rotateAnimation.setDuration(2000); -// break; -// case 1: -// //缩放动画 -// scaleAnimation = tencentMap.getMapContext().createScaleAnimation(0.0f, 1f, 0.0f, 1f); -// scaleAnimation.setDuration(2000); -// scaleAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); -// -// case 2: -// //渐变 -// alphaAnimation = tencentMap.getMapContext().createAlphaAnimation(0f, 1f); -// alphaAnimation.setDuration(2000); -// alphaAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); -// -// break; -// case 3: -// //平移 -// Point point = tencentMap.getProjection().toScreenLocation(latLng); -// point.y -= dip2px(this, 250); -// LatLng target = tencentMap.getProjection().fromScreenLocation(point); -// translateAnimation = tencentMap.getMapContext().createTranslateAnimation(target); -// translateAnimation.setInterpolator(new Interpolator() { -// @Override -// public float getInterpolation(float v) { -// if (v <= 0.5f) { -// return (float) (0.5f - 2 * (0.5 - v) * (0.5 - v)); -// } else { -// return (float) (0.5f - Math.sqrt((v - 0.5f) * (1.5f - v))); -// } -// } -// }); -// translateAnimation.setDuration(2000); -// break; -// case 4: -// //组合动画 -// animationSet = tencentMap.getMapContext().createAnimationSet(true); -// if (rotateAnimation != null || scaleAnimation != null || alphaAnimation != null) { -// animationSet.addAnimation(rotateAnimation); -// animationSet.addAnimation(scaleAnimation); -// animationSet.addAnimation(alphaAnimation); -// } -// -// break; -// -// default: -// throw new IllegalStateException("Unexpected value: " + type); -// } -// return position; -// } -// -// private static int dip2px(Context context, float dpValue) { -// final float scale = context.getResources().getDisplayMetrics().density; -// return (int) (dpValue * scale + 1.5f); -// } -// -// private Bitmap getBitMap(int resourceId) { -// Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId); -// int width = bitmap.getWidth(); -// int height = bitmap.getHeight(); -// int newWidth = 100; -// int newHeight = 100; -// float widthScale = ((float) newWidth) / width; -// float heightScale = ((float) newHeight) / height; -// Matrix matrix = new Matrix(); -// matrix.postScale(widthScale, heightScale); -// bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); -// return bitmap; -// } - -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerClickActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerClickActivity.java deleted file mode 100644 index ddc8eaa..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerClickActivity.java +++ /dev/null @@ -1,25 +0,0 @@ -package cc.winboll.studio.positions.demo.marker; - -//import android.os.Bundle; -//import android.view.View; -//import android.widget.Toast; -// -//import com.tencent.tencentmap.mapsdk.maps.TencentMap; -//import com.tencent.tencentmap.mapsdk.maps.model.Marker; -// -//public class MarkerClickActivity extends MarkerActivity implements TencentMap.OnMarkerClickListener{ -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// marker.setInfoWindowEnable(false); -// aSwitch.setVisibility(View.GONE); -// tencentMap.setOnMarkerClickListener(this); -// } -// -// @Override -// public boolean onMarkerClick(Marker marker) { -// Toast.makeText(getApplicationContext(),"您点击了标注", Toast.LENGTH_SHORT).show(); -// return false; -// } -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerClusterActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerClusterActivity.java deleted file mode 100644 index 9afa055..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerClusterActivity.java +++ /dev/null @@ -1,387 +0,0 @@ -package cc.winboll.studio.positions.demo.marker; - -import android.annotation.TargetApi; -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Color; -import android.graphics.Point; -import android.os.Bundle; -import android.util.Log; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.view.animation.AccelerateDecelerateInterpolator; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; - -import androidx.annotation.Nullable; - -import cc.winboll.studio.positions.demo.AbsMapActivity; -import cc.winboll.studio.positions.R; -//import cc.winboll.studio.positions.demo.utils.CoordinateActivity; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.IAlphaAnimation; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds; -import com.tencent.tencentmap.mapsdk.maps.model.Marker; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; -import com.tencent.tencentmap.mapsdk.maps.model.PolygonOptions; -import com.tencent.tencentmap.mapsdk.maps.model.VisibleRegion; -import com.tencent.tencentmap.mapsdk.vector.utils.clustering.Cluster; -import com.tencent.tencentmap.mapsdk.vector.utils.clustering.ClusterItem; -import com.tencent.tencentmap.mapsdk.vector.utils.clustering.ClusterManager; -import com.tencent.tencentmap.mapsdk.vector.utils.clustering.algo.NonHierarchicalDistanceBasedAlgorithm; -import com.tencent.tencentmap.mapsdk.vector.utils.clustering.view.ClusterRenderer; -import com.tencent.tencentmap.mapsdk.vector.utils.clustering.view.DefaultClusterRenderer; -import com.tencent.tencentmap.mapsdk.vector.utils.ui.IconGenerator; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.lang.reflect.Array; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Set; -import java.util.Timer; -import java.util.TimerTask; - -//public class MarkerClusterActivity extends AbsMapActivity { -// private TencentMap tencentMap; -// private boolean mHasAdded; -// //点聚合坐标数据集合 -// private List generalItemList = new ArrayList<>(); -// private ClusterManager markerClusterItemClusterManager; -// private int i = 8; -// //自定义聚合 -// private ClusterManager petaItemClusterManager; -// private ArrayList petaItems; -// private ArrayList latLngs; -// private NonHierarchicalDistanceBasedAlgorithm ndba; -// private DefaultClusterRenderer markerClusterItemDefaultClusterRenderer; -// private String TAG="MarkerClusterActivity"; -// -// @Override -// -// protected void onCreate(@Nullable Bundle savedInstanceState, TencentMap mTencentMap) { -// super.onCreate(savedInstanceState, mTencentMap); -// tencentMap = mTencentMap; -// //tencentMap.enableMultipleInfowindow(true); -// tencentMap.moveCamera(CameraUpdateFactory.zoomTo(15)); -// //默认聚合管理 -// configDefaultCluterManger(); -// configCustomCluterManger(); -// petaItemClusterManager.setOnClusterClickListener(new ClusterManager.OnClusterClickListener() { -// @Override -// public boolean onClusterClick(Cluster cluster) { -// Collection items = cluster.getItems(); -// -// return false; -// } -// }); -// tencentMap.setOnCameraChangeListener(new TencentMap.OnCameraChangeListener() { -// @Override -// public void onCameraChange(CameraPosition cameraPosition) { -// -// } -// -// @Override -// public void onCameraChangeFinished(CameraPosition cameraPosition) { -// float zoom = cameraPosition.zoom; -// if (zoom < 6) { -// tencentMap.setOnCameraChangeListener(markerClusterItemClusterManager); -// markerClusterItemClusterManager.addItems(getMassiveCoords()); -// // tencentMap.animateCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder().include(latLngs).build(), 20)); -// markerClusterItemClusterManager.cluster(); -// -// } else { -// markerClusterItemClusterManager.cancel(); -// } -// Log.d(TAG, "onCameraChangeFinished: " + zoom); -// } -// }); -// } -// -// public class PetaItem implements ClusterItem { -// private final LatLng mLatLng; -// private int mDrawableResourceId; -// -// public PetaItem(double lat, double lon, int resourceId) { -// mLatLng = new LatLng(lat, lon); -// mDrawableResourceId = resourceId; -// } -// -// @Override -// public LatLng getPosition() { -// return mLatLng; -// } -// -// public int getDrawableResourceId() { -// return mDrawableResourceId; -// } -// } -// -// //聚合设置 -// private void configDefaultCluterManger() { -// //实例化点聚合管理者 -// markerClusterItemClusterManager = new ClusterManager<>(this, tencentMap); -// //默认聚合策略,调用时不用添加,如果需要其它聚合策略可以按以下修改 -// ndba = new NonHierarchicalDistanceBasedAlgorithm<>(this); -// //设置点聚合距离 -// ndba.setMaxDistanceAtZoom(35); -// //设置策略 -// markerClusterItemClusterManager.setAlgorithm(ndba); -// //设置聚合渲染器,按照需要设置 -// markerClusterItemDefaultClusterRenderer = new DefaultClusterRenderer<>(this, tencentMap, markerClusterItemClusterManager); -// //设置最小聚合数量,默认是4 -// markerClusterItemDefaultClusterRenderer.setMinClusterSize(5); -// //定义聚合的分段,例如:当超过5个不满足10个数据,显示5+ -// markerClusterItemDefaultClusterRenderer.setBuckets(new int[]{5, 10, 20, 50}); -// markerClusterItemClusterManager.setRenderer(markerClusterItemDefaultClusterRenderer); -// -// -// } -// -// //自定义聚合样式设置 -// private void configCustomCluterManger() { -// petaItemClusterManager = new ClusterManager<>(this, tencentMap); -// CustomIconClusterRenderer customIconClusterRender = new CustomIconClusterRenderer(this, tencentMap, petaItemClusterManager); -// customIconClusterRender.setMinClusterSize(3); -// petaItemClusterManager.setRenderer(customIconClusterRender); -// -// } -// -// -// //普通聚合 -// private Collection getGeneralCoords() { -// if (generalItemList == null || generalItemList.size() == 0) { -// generalItemList = getItemWithFileName("cluster_new"); -// } -// return generalItemList; -// } -// -// //海量聚合 -// private Collection getMassiveCoords() { -// if (generalItemList == null || generalItemList.size() == 0) { -// generalItemList = getItemWithFileName("datab"); -// } -// return generalItemList; -// } -// -// private List getItemWithFileName(String cluster_new) { -// ArrayList arrayList = new ArrayList<>(); -// latLngs = new ArrayList<>(); -// try { -// InputStream inputStream = getAssets().open(cluster_new); -// InputStreamReader inputStreamReader = new InputStreamReader(inputStream); -// BufferedReader bufferedReader = new BufferedReader(inputStreamReader); -// String line; -// while ((line = bufferedReader.readLine()) != null) { -// String[] data = line.split("\t"); -// double longitue = Double.parseDouble(data[0]); -// double latitue = Double.parseDouble(data[1]); -// arrayList.add(new MarkerClusterItem(latitue, longitue)); -// latLngs.add(new LatLng(latitue, longitue)); -// } -// inputStream.close(); -// inputStreamReader.close(); -// bufferedReader.close(); -// return arrayList; -// } catch (Exception e) { -// e.printStackTrace(); -// } -// return null; -// } -// -// @Override -// public boolean onCreateOptionsMenu(Menu menu) { -// getMenuInflater().inflate(R.menu.marker_cluster, menu); -// return true; -// } -// -// @Override -// public boolean onPrepareOptionsMenu(Menu menu) { -// menu.findItem(R.id.menu_add_marker).setVisible(!mHasAdded); -// menu.findItem(R.id.menu_delete_marker).setVisible(mHasAdded); -// return super.onPrepareOptionsMenu(menu); -// } -// -// @Override -// public boolean onOptionsItemSelected(MenuItem item) { -// tencentMap.setInfoWindowAdapter(new TencentMap.InfoWindowAdapter() { -// @Override -// public View getInfoWindow(Marker marker) { -// LinearLayout inflate = (LinearLayout) View.inflate(getApplicationContext(), R.layout.custom_infowindow, null); -// TextView title = inflate.findViewById(R.id.tv_title); -// Point point = tencentMap.getProjection().toScreenLocation(marker.getPosition()); -// title.setText("\t\t\t\t\t\t\t\t自定义View弹窗:\n点在屏幕位置:" + point); -// return inflate; -// } -// -// @Override -// public View getInfoContents(Marker marker) { -// return null; -// } -// }); -// final IAlphaAnimation alphaAnimation_custom = tencentMap.getMapContext().createAlphaAnimation(0f, 1f); -// alphaAnimation_custom.setDuration(1000); -// alphaAnimation_custom.setInterpolator(new AccelerateDecelerateInterpolator()); -// tencentMap.setOnMarkerClickListener(new TencentMap.OnMarkerClickListener() { -// @Override -// public boolean onMarkerClick(Marker marker) { -// Point point = tencentMap.getProjection().toScreenLocation(marker.getPosition()); -// marker.setTitle(point.toString()); -// marker.setAnimation(alphaAnimation_custom); -// marker.startAnimation(); -// return false; -// } -// }); -// switch (item.getItemId()) { -// case R.id.menu_add_marker_general: -// mHasAdded = true; -// //markerClusterItemClusterManager.cancel(); -// tencentMap.setOnCameraChangeListener(markerClusterItemClusterManager); -// markerClusterItemClusterManager.addItems(getGeneralCoords()); -// LatLng position = generalItemList.get(6).getPosition(); -// CameraUpdate cameraUpdate; -// if (i < 16) { -// i++; -// cameraUpdate = CameraUpdateFactory.newLatLngZoom(position, i); -// } else { -// i = 6; -// cameraUpdate = CameraUpdateFactory.newLatLngZoom(position, i); -// } -// tencentMap.animateCamera(cameraUpdate); -// markerClusterItemClusterManager.cluster(); -// -// break; -// case R.id.menu_add_marker_massive: -// mHasAdded = true; -// tencentMap.setOnCameraChangeListener(markerClusterItemClusterManager); -// markerClusterItemClusterManager.addItems(getMassiveCoords()); -// -// LatLng position_massive = generalItemList.get(60).getPosition(); -// CameraUpdate cameraUpdate_massive; -// if (i < 16) { -// i++; -// cameraUpdate_massive = CameraUpdateFactory.newLatLngZoom(position_massive, i); -// } else { -// i = 6; -// cameraUpdate_massive = CameraUpdateFactory.newLatLngZoom(position_massive, i); -// } -// tencentMap.animateCamera(cameraUpdate_massive); -// markerClusterItemClusterManager.cluster(); -// break; -// case R.id.menu_add_marker_custom: -// mHasAdded = true; -// tencentMap.setOnCameraChangeListener(petaItemClusterManager); -// addCustomClusterItem(); -// tencentMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(39.971595, 116.314316), 15)); -// petaItemClusterManager.cluster(); -// break; -// case R.id.menu_delete_marker: -// mHasAdded = false; -// clusterReMove(); -// break; -// -// } -// return super.onOptionsItemSelected(item); -// } -// -// private void addCustomClusterItem() { -// -// petaItemClusterManager.addItem(new PetaItem(39.971595, 116.294747, R.mipmap.petal_blue)); -// -// petaItemClusterManager.addItem(new PetaItem(39.971595, 116.314316, R.mipmap.petal_red)); -// -// petaItemClusterManager.addItem(new PetaItem(39.967385, 116.317063, R.mipmap.petal_green)); -// -// petaItemClusterManager.addItem(new PetaItem(39.951596, 116.302300, R.mipmap.petal_yellow)); -// -// petaItemClusterManager.addItem(new PetaItem(39.970543, 116.290627, R.mipmap.petal_orange)); -// -// petaItemClusterManager.addItem(new PetaItem(39.966333, 116.311569, R.mipmap.petal_purple)); -// } -// -// //移除聚合数据 -// private void clusterReMove() { -// markerClusterItemClusterManager.cancel(); -// markerClusterItemClusterManager.cluster(); -// generalItemList.clear(); -// petaItemClusterManager.cancel(); -// petaItemClusterManager.cluster(); -// tencentMap.clearAllOverlays(); -// -// } -// -// class CustomIconClusterRenderer extends DefaultClusterRenderer { -// -// private IconGenerator mIconGenerator = new IconGenerator(getApplicationContext()); -// private IconGenerator mClusterIconGenerator = new IconGenerator(getApplicationContext()); -// private ImageView mItemImageView = new ImageView(getApplicationContext()); -// private ImageView mClusterImageView = new ImageView(getApplicationContext()); -// -// public CustomIconClusterRenderer( -// Context context, TencentMap map, ClusterManager clusterManager) { -// super(context, map, clusterManager); -// mItemImageView.setLayoutParams( -// new ViewGroup.LayoutParams( -// ViewGroup.LayoutParams.WRAP_CONTENT, -// ViewGroup.LayoutParams.WRAP_CONTENT)); -// mIconGenerator.setContentView(mItemImageView); -// -// mClusterImageView.setLayoutParams( -// new ViewGroup.LayoutParams( -// ViewGroup.LayoutParams.WRAP_CONTENT, -// ViewGroup.LayoutParams.WRAP_CONTENT)); -// mClusterIconGenerator.setContentView(mClusterImageView); -// -// setMinClusterSize(1); -// } -// -// @Override -// public void onBeforeClusterRendered( -// Cluster cluster, MarkerOptions markerOptions) { -// int[] resources = new int[cluster.getItems().size()]; -// int i = 0; -// for (PetaItem item : cluster.getItems()) { -// resources[i++] = item.getDrawableResourceId(); -// } -// -// PetalDrawable drawable = new PetalDrawable(getApplicationContext(), resources); -// mClusterImageView.setImageDrawable(drawable); -// Bitmap icon = mClusterIconGenerator.makeIcon(); -// markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon)); -// } -// -// @Override -// public void onBeforeClusterItemRendered(PetaItem item, MarkerOptions markerOptions) { -// mItemImageView.setImageResource(item.getDrawableResourceId()); -// Bitmap icon = mIconGenerator.makeIcon(); -// markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon)); -// } -// } -// -// class MarkerClusterItem implements ClusterItem { -// private final LatLng mLatLng; -// -// public MarkerClusterItem(double lat, double lon) { -// mLatLng = new LatLng(lat, lon); -// } -// -// @Override -// public LatLng getPosition() { -// return mLatLng; -// } -// } -//} - - diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerCollisions.java b/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerCollisions.java deleted file mode 100644 index e27d58a..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerCollisions.java +++ /dev/null @@ -1,116 +0,0 @@ -package cc.winboll.studio.positions.demo.marker; - -//import androidx.annotation.NonNull; -//import androidx.appcompat.app.AppCompatActivity; -// -//import android.os.Bundle; -//import android.view.Menu; -//import android.view.MenuItem; -//import android.view.View; -// -//import cc.winboll.studio.positions.R; -//import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; -//import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -//import com.tencent.tencentmap.mapsdk.maps.MapView; -//import com.tencent.tencentmap.mapsdk.maps.TencentMap; -//import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; -//import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -//import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -//import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -//import com.tencent.tencentmap.mapsdk.maps.model.MapPoi; -//import com.tencent.tencentmap.mapsdk.maps.model.Marker; -//import com.tencent.tencentmap.mapsdk.maps.model.MarkerCollisionItem; -//import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; -// -//public class MarkerCollisions extends AppCompatActivity { -// -// private MapView mapView; -// private TencentMap tencentMap; -// private boolean mMarkerAdded; -// private Marker mMarker; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// setContentView(R.layout.activity_marker_collisions); -// intit(); -// } -// -// private void intit() { -// mapView = findViewById(R.id.mapView); -// tencentMap = mapView.getMap(); -// CameraUpdate cameraSigma = -// CameraUpdateFactory.newCameraPosition(new CameraPosition( -// new LatLng(39.984066, 116.307548), -// 15, -// 0f, -// 0f)); -// //移动地图 -// tencentMap.moveCamera(cameraSigma); -// } -// -// @Override -// public boolean onCreateOptionsMenu(Menu menu) { -// getMenuInflater().inflate(R.menu.markercol, menu); -// return super.onCreateOptionsMenu(menu); -// } -// -// @Override -// public boolean onPrepareOptionsMenu(Menu menu) { -// menu.findItem(R.id.menu_open_collisionsmap).setVisible(!mMarkerAdded); -// menu.findItem(R.id.menu_close_collisionsmap).setVisible(mMarkerAdded); -// return super.onPrepareOptionsMenu(menu); -// } -// -// @Override -// public boolean onOptionsItemSelected(@NonNull MenuItem item) { -// switch (item.getItemId()) { -// case R.id.menu_open_collisionsmap: -// mMarkerAdded = true; -// BitmapDescriptor custom = BitmapDescriptorFactory.fromResource(R.drawable.marker); -// MarkerOptions options = new MarkerOptions().position(new LatLng(39.984066, 116.307548)); -// options.icon(custom); -// mMarker = tencentMap.addMarker(options); -// mMarker.setCollisions(MarkerCollisionItem.POI); -// break; -// case R.id.menu_close_collisionsmap: -// mMarkerAdded = false; -// mMarker.remove(); -// break; -// } -// -// supportInvalidateOptionsMenu(); -// return super.onOptionsItemSelected(item); -// } -// -// @Override -// protected void onResume() { -// super.onResume(); -// mapView.onResume(); -// } -// -// @Override -// protected void onPause() { -// super.onPause(); -// mapView.onPause(); -// } -// -// @Override -// protected void onDestroy() { -// super.onDestroy(); -// mapView.onDestroy(); -// } -// -// -// @Override -// protected void onStart() { -// super.onStart(); -// mapView.onStart(); -// } -// -// @Override -// protected void onStop() { -// super.onStop(); -// mapView.onStop(); -// } -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerDragActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerDragActivity.java deleted file mode 100644 index 9d82547..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerDragActivity.java +++ /dev/null @@ -1,58 +0,0 @@ -package cc.winboll.studio.positions.demo.marker; - -import android.os.Bundle; -import android.util.Log; -import android.view.View; -import android.widget.TextView; -import android.widget.Toast; - -import cc.winboll.studio.positions.R; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.Marker; - -public class MarkerDragActivity extends MarkerActivity implements TencentMap.OnMarkerDragListener { - - @Override - public void onMarkerDragStart(Marker p1) { - } - - @Override - public void onMarkerDrag(Marker p1) { - } - - @Override - public void onMarkerDragEnd(Marker p1) { - } - -// private TextView textView; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// marker.setInfoWindowEnable(false); -// aSwitch.setVisibility(View.GONE); -// -// textView = findViewById(R.id.tv_info); -// textView.setText("长按标记开始拖动"); -// textView.setVisibility(View.VISIBLE); -// -// marker.setDraggable(true); -// tencentMap.setOnMarkerDragListener(this); -// } -// -// @Override -// public void onMarkerDragStart(Marker marker) { -// Log.e("marker:","drag"); -// Toast.makeText(this, "拖拽开始", Toast.LENGTH_SHORT).show(); -// } -// -// @Override -// public void onMarkerDrag(Marker marker) { -// -// } -// -// @Override -// public void onMarkerDragEnd(Marker marker) { -// Toast.makeText(this, "拖拽结束", Toast.LENGTH_SHORT).show(); -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerInfoWindowActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerInfoWindowActivity.java deleted file mode 100644 index 8ec544d..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerInfoWindowActivity.java +++ /dev/null @@ -1,254 +0,0 @@ -package cc.winboll.studio.positions.demo.marker; - -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.widget.LinearLayout; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.annotation.Nullable; - -import cc.winboll.studio.positions.demo.AbsMapActivity; -import cc.winboll.studio.positions.R; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.Marker; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; - -public class MarkerInfoWindowActivity extends AbsMapActivity { - - -// private static final int TYPE_BITMAP = 0; -// private static final int TYPE_VIEW = 1; -// -// private static final int STYLE_NO_FRAME = 1; -// private static final int STYLE_FRAME = 2; -// -// private Marker mMarker; -// private Marker mAnotherMarker; -// private TencentMap mTencentMap; -// private int mInfoWindowAdapterStyle; -// private int mInfoWindowType = TYPE_BITMAP; -// private LinearLayout mCustomInfoWindowView; -// -// /** -// * 自定义信息窗 -// */ -// private TencentMap.InfoWindowAdapter mInfoWindowAdapter = new TencentMap.InfoWindowAdapter() { -// -// TextView tvTitle; -// -// //返回View为信息窗自定义样式,返回null时为默认信息窗样式 -// @Override -// public View getInfoWindow(final Marker marker) { -// if (mInfoWindowAdapterStyle == 1 && marker.equals(mMarker)) { -// return createCustomInfoView(marker); -// } -// return null; -// } -// -// //返回View为信息窗内容自定义样式,返回null时为默认信息窗样式 -// @Override -// public View getInfoContents(Marker marker) { -// if (mInfoWindowAdapterStyle == 2 && marker.equals(mMarker)) { -// return createCustomInfoView(marker); -// } -// return null; -// } -// -// private View createCustomInfoView(Marker marker) { -// mCustomInfoWindowView = (LinearLayout) View.inflate( -// getApplicationContext(), R.layout.custom_infowindow, null); -// tvTitle = mCustomInfoWindowView.findViewById(R.id.tv_title); -// //设置自定义信息窗的内容 -// tvTitle.setText("我是自定义信息窗口:"); -// tvTitle.append("\n" + marker.getTitle()); -// tvTitle.append("\n" + marker.getSnippet()); -// return mCustomInfoWindowView; -// } -// }; -// private boolean mMultEnable; -// -// -// @Override -// protected void onCreate(@Nullable Bundle savedInstanceState, TencentMap pTencentMap) { -// super.onCreate(savedInstanceState, pTencentMap); -// mTencentMap = pTencentMap; -// mMarker = createMarker(); -// pTencentMap.setOnMarkerClickListener(new TencentMap.OnMarkerClickListener() { -// @Override -// public boolean onMarkerClick(Marker marker) { -// invalidateOptionsMenu(); -// return false; -// } -// }); -// pTencentMap.setOnInfoWindowClickListener(new TencentMap.OnInfoWindowClickListener() { -// @Override -// public void onInfoWindowClick(Marker marker) { -// Toast.makeText(getApplicationContext(), "信息窗被点击", Toast.LENGTH_SHORT).show(); -// } -// -// @Override -// public void onInfoWindowClickLocation(int i, int i1, int i2, int i3) { -// Toast.makeText(getApplicationContext(), -// "尺寸:" + i + "x" + i1 + " 位置:" + i2 + "," + i3, Toast.LENGTH_SHORT).show(); -// } -// }); -// } -// -// private Marker createMarker() { -// if (mTencentMap == null) { -// return null; -// } -// if (mMarker != null) { -// mMarker.remove(); -// mMarker = null; -// } -// LatLng position = new LatLng(39.908710, 116.397499); -// MarkerOptions options = new MarkerOptions(position); -// options.infoWindowEnable(true);//默认为true -// options.title("天安门")//标注的InfoWindow的标题 -// .snippet("地址: 北京市东城区东长安街")//标注的InfoWindow的内容 -// .anchor(0.5f, 1) -// .viewInfoWindow(mInfoWindowType == TYPE_VIEW) -// .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker));//设置自定义Marker图标 -// mTencentMap.moveCamera(CameraUpdateFactory.newLatLngZoom(position, 15)); -// return mTencentMap.addMarker(options); -// } -// -// private Marker createMultMarker() { -// if (mTencentMap == null) { -// return null; -// } -// if (mAnotherMarker != null) { -// mAnotherMarker.remove(); -// mAnotherMarker = null; -// } -// LatLng position = new LatLng(39.902500,116.397750); -// MarkerOptions options = new MarkerOptions(position); -// options.infoWindowEnable(true);//默认为true -// options.title("毛主席纪念堂")//标注的InfoWindow的标题 -// .snippet("地址: 北京市东城区前门东大街11号")//标注的InfoWindow的内容 -// .anchor(0.5f, 1) -// .viewInfoWindow(mInfoWindowType == TYPE_VIEW) -// .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker));//设置自定义Marker图标 -// return mTencentMap.addMarker(options); -// } -// -// @Override -// public boolean onCreateOptionsMenu(Menu menu) { -// getMenuInflater().inflate(R.menu.infowindow, menu); -// return super.onCreateOptionsMenu(menu); -// } -// -// @Override -// public boolean onPrepareOptionsMenu(Menu menu) { -// String typeName = null; -// if (mInfoWindowType == TYPE_VIEW) { -// typeName = "View类型"; -// } else if (mInfoWindowType == TYPE_BITMAP) { -// typeName = "Bitmap类型"; -// } -// if (typeName != null) { -// menu.findItem(R.id.menu_type).setTitle(typeName) -// .setVisible(!mMarker.isInfoWindowShown()); -// } -// menu.findItem(R.id.menu_mult).setTitle(mMultEnable ? "开启多窗口" : "关闭多窗口") -// .setVisible(!mMarker.isInfoWindowShown()); -// menu.findItem(R.id.menu_add).setVisible(!mMarker.isInfoWindowShown()); -// menu.findItem(R.id.menu_play).setVisible(mMarker.isInfoWindowShown()); -// menu.findItem(R.id.menu_delete).setVisible(mMarker.isInfoWindowShown()); -// return super.onPrepareOptionsMenu(menu); -// } -// -// @Override -// public boolean onOptionsItemSelected(MenuItem item) { -// switch (item.getItemId()) { -// case R.id.menu_mult_enable: -// mMultEnable = true; -// initMarkers(); -// hideInfoWindow(); -// break; -// case R.id.menu_mult_close: -// mMultEnable = false; -// if (mAnotherMarker != null) { -// mAnotherMarker.remove(); -// mAnotherMarker = null; -// } -// -// hideInfoWindow(); -// break; -// case R.id.menu_type_bitmap: -// mInfoWindowType = TYPE_BITMAP; -// initMarkers(); -// hideInfoWindow(); -// break; -// case R.id.menu_type_view: -// mInfoWindowType = TYPE_VIEW; -// initMarkers(); -// hideInfoWindow(); -// break; -// case R.id.menu_add_infowindow_default: -// showInfoWindow(); -// break; -// case R.id.menu_add_infowindow_custom_1: -// mInfoWindowAdapterStyle = STYLE_NO_FRAME; -// mTencentMap.setInfoWindowAdapter(mInfoWindowAdapter); -// showInfoWindow(); -// break; -// case R.id.menu_add_infowindow_custom_2: -// mInfoWindowAdapterStyle = STYLE_FRAME; -// mTencentMap.setInfoWindowAdapter(mInfoWindowAdapter); -// showInfoWindow(); -// break; -// case R.id.menu_play: -// animationPlay(); -// break; -// case R.id.menu_delete: -// hideInfoWindow(); -// break; -// } -// -// mTencentMap.enableMultipleInfowindow(mMultEnable); -// return super.onOptionsItemSelected(item); -// } -// -// private void initMarkers() { -// mMarker = createMarker(); -// if (mMultEnable) { -// mAnotherMarker = createMultMarker(); -// } -// } -// -// private void showInfoWindow() { -// if (mMarker != null) { -// mMarker.showInfoWindow(); -// } -// -// if (mAnotherMarker != null && mMultEnable) { -// mAnotherMarker.showInfoWindow(); -// } -// } -// -// private void hideInfoWindow() { -// if (mMarker != null) { -// mMarker.hideInfoWindow(); -// } -// -// if (mAnotherMarker != null && mMultEnable) { -// mAnotherMarker.hideInfoWindow(); -// } -// mTencentMap.setInfoWindowAdapter(null); -// } -// -// private void animationPlay() { -// -// if (mInfoWindowType == TYPE_VIEW) { -// //TODO :动画 -// } -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerOptionsActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerOptionsActivity.java deleted file mode 100644 index 1fff6c5..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/MarkerOptionsActivity.java +++ /dev/null @@ -1,54 +0,0 @@ -package cc.winboll.studio.positions.demo.marker; - -//import android.graphics.Bitmap; -//import android.graphics.BitmapFactory; -//import android.graphics.Matrix; -//import android.os.Bundle; -// -//import cc.winboll.studio.positions.R; -//import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -//import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -//import com.tencent.tencentmap.mapsdk.maps.model.CircleOptions; -//import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -//import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; -// -//public class MarkerOptionsActivity extends SupportMapFragmentActivity { -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// options.fastLoad(true); //设置是否快速加载 -// options.icon(BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.marker))); //加载图标 -// options.tag(tencentMap.addCircle(new CircleOptions().center(new LatLng(39.984059, 116.305756)))); //设置标签对象 -// tencentMap.addMarker(options); -// } -// -// private LatLng latLng = new LatLng(39.984864, 116.305756); -// -// private Bitmap getBitMap(int resourceId){ -// Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId); -// int width = bitmap.getWidth(); -// int height = bitmap.getHeight(); -// int newWidth = 100; -// int newHeight = 100; -// float widthScale = ((float)newWidth)/width; -// float heightScale = ((float)newHeight)/height; -// Matrix matrix = new Matrix(); -// matrix.postScale(widthScale, heightScale); -// bitmap = Bitmap.createBitmap(bitmap,0,0,width,height,matrix,true); -// return bitmap; -// } -// -// -// private MarkerOptions options = new MarkerOptions(latLng). //坐标设置 -// anchor(0.5f, 0.5f). //标注的锚点 -// clockwise(true). //旋转角度顺时针 -// draggable(true). //标注可被拖动 -// flat(true). //设置3D标注 -// infoWindowEnable(true). //弹出infowindow -// infoWindowAnchor(0.5f, 0.5f). //标注信息infowindow锚点 -// rotation(90f). //旋转角度 -// snippet("气泡infowindow内容"). //设置infowindow内容 -// title("标题内容"). //infowindow标题内容 -// visible(true). //标注是否可见 -// zIndex(0); //堆叠顺序,越大优先级越高 -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/SimpleMarkerActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/marker/SimpleMarkerActivity.java deleted file mode 100644 index eac1f62..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/SimpleMarkerActivity.java +++ /dev/null @@ -1,107 +0,0 @@ -package cc.winboll.studio.positions.demo.marker; - -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; - -import androidx.annotation.Nullable; - -import cc.winboll.studio.positions.demo.AbsMapActivity; -import cc.winboll.studio.positions.R; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.AlphaAnimation; -import com.tencent.tencentmap.mapsdk.maps.model.Animation; -import com.tencent.tencentmap.mapsdk.maps.model.AnimationListener; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.Marker; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; - -public class SimpleMarkerActivity extends AbsMapActivity { - -// private TencentMap mTencentMap; -// private Marker mSimpleMarker; -// private Marker mCustomMarker; -// -// private boolean mMarkerAdded; -// @Override -// protected void onCreate(@Nullable Bundle savedInstanceState, TencentMap pTencentMap) { -// super.onCreate(savedInstanceState, pTencentMap); -// mTencentMap = pTencentMap; -// } -// -// @Override -// public boolean onCreateOptionsMenu(Menu menu) { -// getMenuInflater().inflate(R.menu.simple_marker, menu); -// return super.onCreateOptionsMenu(menu); -// } -// -// @Override -// public boolean onPrepareOptionsMenu(Menu menu) { -// menu.findItem(R.id.menu_add).setVisible(!mMarkerAdded); -// menu.findItem(R.id.menu_delete).setVisible(mMarkerAdded); -// return super.onPrepareOptionsMenu(menu); -// } -// -// @Override -// public boolean onOptionsItemSelected(MenuItem item) { -// switch (item.getItemId()) { -// case R.id.menu_add_marker_simple: -// if (mSimpleMarker == null) { -// LatLng position = new LatLng(40.011313,116.391907); -// mSimpleMarker = mTencentMap.addMarker(new MarkerOptions(position)); -// mTencentMap.moveCamera(CameraUpdateFactory.newLatLng(position)); -// mMarkerAdded = true; -// } -// break; -// case R.id.menu_add_marker_custom: -// -// if (mCustomMarker == null) { -// LatLng position = new LatLng(40.011313,116.391907); -// BitmapDescriptor custom = BitmapDescriptorFactory.fromResource(R.drawable.marker); -// mCustomMarker = mTencentMap.addMarker(new MarkerOptions(position) -// .icon(custom) -// .alpha(0.7f) -// .flat(true) -// .clockwise(false) -// .rotation(30) -// ); -// -// Animation animation = new AlphaAnimation(0.7f, 0f); -// animation.setDuration(2000); -// animation.setAnimationListener(new AnimationListener() { -// @Override -// public void onAnimationStart() { -// -// } -// -// @Override -// public void onAnimationEnd() { -// mCustomMarker.setAlpha(1); -// } -// }); -// mCustomMarker.setAnimation(animation); -// mCustomMarker.startAnimation(); -// mTencentMap.moveCamera(CameraUpdateFactory.newLatLng(position)); -// mMarkerAdded = true; -// } -// break; -// case R.id.menu_delete: -// if (mSimpleMarker != null) { -// mSimpleMarker.remove(); -// mSimpleMarker = null; -// } -// -// if (mCustomMarker != null) { -// mCustomMarker.remove(); -// mCustomMarker = null; -// } -// -// mMarkerAdded = false; -// break; -// } -// return super.onOptionsItemSelected(item); -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/poi/PoiClickActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/poi/PoiClickActivity.java deleted file mode 100644 index aa7b88a..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/poi/PoiClickActivity.java +++ /dev/null @@ -1,64 +0,0 @@ -package cc.winboll.studio.positions.demo.poi; - -import android.os.Bundle; -import android.view.View; -import android.widget.CompoundButton; -import android.widget.Switch; - -import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.MapPoi; -import com.tencent.tencentmap.mapsdk.maps.model.Marker; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; - -public class PoiClickActivity extends SupportMapFragmentActivity implements TencentMap.OnMapPoiClickListener { - - @Override - public void onClicked(MapPoi p1) { - } - -// private Switch poiSwitch; -// private Marker marker; -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// poiSwitch = findViewById(R.id.switch_poi); -// poiSwitch.setVisibility(View.VISIBLE); -// poiSwitch.setText("Poi显示"); -// tencentMap.setOnMapPoiClickListener(this); -// poiSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { -// @Override -// public void onCheckedChanged(CompoundButton compoundButton, boolean b) { -// if (b){ -// tencentMap.setPoisEnabled(true); -// }else{ -// tencentMap.setPoisEnabled(false); -// if (marker != null) -// marker.remove(); -// } -// } -// }); -// } -// -// @Override -// public void onClicked(MapPoi mapPoi) { -// setMarker(mapPoi.getPosition(), mapPoi.getName()); -// } -// -// /** -// * 设置标注 -// */ -// private void setMarker(LatLng latLng, String name){ -// -// if(marker != null) -// marker.remove(); -// MarkerOptions options = new MarkerOptions().position(latLng); -// //设置infowindow -// options.title("地址:"); -// options.snippet(name); -// marker = tencentMap.addMarker(options); -// marker.showInfoWindow(); -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/polygon/DrawPolygonActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/polygon/DrawPolygonActivity.java deleted file mode 100644 index 2630176..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/polygon/DrawPolygonActivity.java +++ /dev/null @@ -1,38 +0,0 @@ -package cc.winboll.studio.positions.demo.polygon; - -//import android.os.Bundle; -// -//import cc.winboll.studio.positions.R; -//import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -//import com.tencent.tencentmap.mapsdk.maps.TencentMap; -//import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -//import com.tencent.tencentmap.mapsdk.maps.model.Polygon; -//import com.tencent.tencentmap.mapsdk.maps.model.PolygonOptions; -// -//public class DrawPolygonActivity extends SupportMapFragmentActivity { -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// LatLng[] latLngs = { -// new LatLng(39.984864, 116.305756), -// new LatLng(39.983618, 116.305848), -// new LatLng(39.982347, 116.305966), -// new LatLng(39.982412, 116.308111), -// new LatLng(39.984122, 116.308224), -// new LatLng(39.984955, 116.308099), -// new LatLng(39.984864, 116.305756) -// }; -// Polygon polygon = tencentMap.addPolygon(new PolygonOptions(). -// add(latLngs). -// fillColor(getResources().getColor(R.color.style)). -// strokeColor(getResources().getColor(R.color.colorPrimary)). -// strokeWidth(1)); -// tencentMap.setOnPolygonClickListener(new TencentMap.OnPolygonClickListener() { -// @Override -// public void onPolygonClick(Polygon polygon, LatLng latLng) { -// -// } -// }); -// } -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/polygon/PolylonOptionsActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/polygon/PolylonOptionsActivity.java deleted file mode 100644 index 738ce9d..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/polygon/PolylonOptionsActivity.java +++ /dev/null @@ -1,73 +0,0 @@ -package cc.winboll.studio.positions.demo.polygon; - -//import android.os.Bundle; -// -//import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -//import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -//import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; -//import com.tencent.tencentmap.mapsdk.maps.model.Polygon; -//import com.tencent.tencentmap.mapsdk.maps.model.PolygonOptions; -// -//import java.util.ArrayList; -//import java.util.List; -// -//public class PolylonOptionsActivity extends SupportMapFragmentActivity { -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// Polygon polygon = tencentMap.addPolygon(polygonOptions); -// polygon.setPoints(transferArrayToList(latLngs)); //Options中设置顶点 -// Polygon newPolygon = tencentMap.addPolygon(newPolygonOptions); -// newPolygon.setOptions(newPolygonOptions); //重新设置Options -// newPolygon.setClickable(true); //设置可点击 -// newPolygon.setFillColor(0xaa324354); -// newPolygon.setPoints(transferArrayToList(newLatLngs)); //设置坐标 -// newPolygon.setTag(tencentMap.addMarker(new MarkerOptions().position(new LatLng(39.984866, 116.305759)).title("设置标注").draggable(true))); -// -// -// } -// -// private List transferArrayToList(LatLng[] latLngs){ //坐标数组与List转换 -// List list = new ArrayList<>(); -// if (latLngs == null) -// return list; -// for (int i = 0; i < latLngs.length; i++) -// list.add(latLngs[i]); -// -// return list; -// -// } -// private LatLng[] latLngs = { -// new LatLng(39.984864, 116.305756), -// new LatLng(39.983618, 116.305848), -// new LatLng(39.982347, 116.305966), -// new LatLng(39.982412, 116.308111), -// new LatLng(39.984122, 116.308224), -// new LatLng(39.984955, 116.308099), -// new LatLng(39.984864, 116.305756) -// }; -// -// private LatLng[] newLatLngs = { -// new LatLng(39.984864, 116.305756), -// new LatLng(39.983618, 116.305848), -// new LatLng(39.982347, 116.305966), -// new LatLng(39.982412, 116.308111), -// new LatLng(39.984122, 116.308224), -// new LatLng(39.984955, 116.308099), -// new LatLng(39.984864, 116.305756) -// }; -// -// -// private PolygonOptions polygonOptions = new PolygonOptions(). -// add(latLngs). // 添加图形坐标点 -// fillColor(0x56643313). //填充颜色 -// strokeColor(0xfa349012). //描边颜色 -// strokeWidth(1). //描边宽度 -// visible(true). //是否可见 -// zIndex(0). //堆叠顺序,越大优先级越高 -// clickable(true); // 是否可点击 -// -// private PolygonOptions newPolygonOptions = new PolygonOptions(). -// addAll(transferArrayToList(newLatLngs)); //设置批量添加顶点 -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/polygon/TileOverlayActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/polygon/TileOverlayActivity.java deleted file mode 100644 index a7c8125..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/polygon/TileOverlayActivity.java +++ /dev/null @@ -1,178 +0,0 @@ -package cc.winboll.studio.positions.demo.polygon; - -//import androidx.annotation.NonNull; -//import androidx.appcompat.app.AppCompatActivity; -// -//import android.os.Bundle; -//import android.util.Log; -//import android.view.Menu; -//import android.view.MenuItem; -//import android.view.View; -// -//import cc.winboll.studio.positions.R; -//import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; -//import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -//import com.tencent.tencentmap.mapsdk.maps.MapView; -//import com.tencent.tencentmap.mapsdk.maps.TencentMap; -//import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; -//import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -//import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -//import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -//import com.tencent.tencentmap.mapsdk.maps.model.MarkerCollisionItem; -//import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; -//import com.tencent.tencentmap.mapsdk.maps.model.Tile; -//import com.tencent.tencentmap.mapsdk.maps.model.TileOverlay; -//import com.tencent.tencentmap.mapsdk.maps.model.TileOverlayOptions; -//import com.tencent.tencentmap.mapsdk.maps.model.TileProvider; -// -//import java.io.ByteArrayOutputStream; -//import java.io.IOException; -//import java.io.InputStream; -// -//public class TileOverlayActivity extends AppCompatActivity { -// private MapView mapView; -// private TencentMap tencentMap; -// private boolean mMarkerAdded; -// private TileOverlay mTileOverlay; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// setContentView(R.layout.activity_tile_overlay); -// initView(); -// } -// -// private void initView() { -// mapView = findViewById(R.id.mapView); -// tencentMap = mapView.getMap(); -// CameraUpdate cameraSigma = -// CameraUpdateFactory.newCameraPosition(new CameraPosition( -// new LatLng(39.917505, 116.397657), -// 15, -// 0f, -// 0f)); -// //移动地图 -// tencentMap.moveCamera(cameraSigma); -// } -// -// @Override -// public boolean onCreateOptionsMenu(Menu menu) { -// getMenuInflater().inflate(R.menu.markercol, menu); -// return super.onCreateOptionsMenu(menu); -// } -// -// @Override -// public boolean onPrepareOptionsMenu(Menu menu) { -// menu.findItem(R.id.menu_open_collisionsmap).setVisible(!mMarkerAdded); -// menu.findItem(R.id.menu_close_collisionsmap).setVisible(mMarkerAdded); -// return super.onPrepareOptionsMenu(menu); -// } -// -// @Override -// public boolean onOptionsItemSelected(@NonNull MenuItem item) { -// switch (item.getItemId()) { -// case R.id.menu_open_collisionsmap: -// mMarkerAdded = true; -// if (mTileOverlay == null) { -// mTileOverlay = tencentMap.addTileOverlay( -// new TileOverlayOptions(). -// tileProvider(new LocalTileProvider())); -// } -// -// break; -// case R.id.menu_close_collisionsmap: -// mMarkerAdded = false; -// if (mTileOverlay != null) { -// mTileOverlay.clearTileCache(); -// mTileOverlay.remove(); -// mTileOverlay = null; -// } -// break; -// } -// -// supportInvalidateOptionsMenu(); -// return super.onOptionsItemSelected(item); -// } -// -// class LocalTileProvider implements TileProvider { -// -// @Override -// public Tile getTile(int x, int y, int zoom) { -// LatLng latLng = new LatLng(39.917505, 116.397657); -// int iZ = 16; -// double n = Math.pow(2, iZ); -// int iX = (int) (((latLng.getLongitude() + 180) / 360) * n); -// int iY = (int) ((1 - (Math.log(Math.tan(Math.toRadians(latLng.getLatitude())) + -// (1 / Math.cos(Math.toRadians(latLng.getLatitude())))) / Math.PI)) / 2 * n); -// if (iX == x && iY == y && iZ == zoom) { -// Log.e("tile", "zoom:" + zoom + " x:" + x + " y:" + y); -// return new Tile(256, 256, tileData()); -// } -// return TileProvider.NO_TILE; -// } -// -// byte[] tileData() { -// InputStream is = null; -// ByteArrayOutputStream baos = null; -// try { -// is = getApplicationContext().getAssets().open("gugong.jpg"); -// baos = new ByteArrayOutputStream(); -// byte[] byteBuffer = new byte[1024]; -// int count = 0; -// while ((count = is.read(byteBuffer)) != -1) { -// baos.write(byteBuffer, 0, count); -// } -// return baos.toByteArray(); -// } catch (IOException e) { -// e.printStackTrace(); -// return null; -// } finally { -// if (is != null) { -// try { -// is.close(); -// } catch (IOException e) { -// e.printStackTrace(); -// } -// } -// if (baos != null) { -// try { -// baos.close(); -// } catch (IOException e) { -// e.printStackTrace(); -// } -// } -// } -// } -// } -// -// @Override -// protected void onResume() { -// super.onResume(); -// mapView.onResume(); -// } -// -// @Override -// protected void onPause() { -// super.onPause(); -// mapView.onPause(); -// } -// -// @Override -// protected void onDestroy() { -// super.onDestroy(); -// mapView.onDestroy(); -// } -// -// -// @Override -// protected void onStart() { -// super.onStart(); -// mapView.onStart(); -// } -// -// @Override -// protected void onStop() { -// super.onStop(); -// mapView.onStop(); -// } -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/polyline/DrawLineActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/polyline/DrawLineActivity.java deleted file mode 100644 index 27405cf..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/polyline/DrawLineActivity.java +++ /dev/null @@ -1,194 +0,0 @@ -package cc.winboll.studio.positions.demo.polyline; - -//import android.graphics.Color; -//import android.os.Bundle; -//import android.view.Menu; -//import android.view.MenuItem; -// -//import androidx.annotation.Nullable; -// -//import cc.winboll.studio.positions.demo.AbsMapActivity; -//import cc.winboll.studio.positions.R; -//import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -//import com.tencent.tencentmap.mapsdk.maps.TencentMap; -//import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -//import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -//import com.tencent.tencentmap.mapsdk.maps.model.Polyline; -//import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; -// -//import java.util.ArrayList; -//import java.util.List; -// -//public class DrawLineActivity extends AbsMapActivity { -// private int typeSimple = 0; -// private int typeImage = 1; -// private int typeColor = 2; -// private int typeArrow = 3; -// private int typeGradient = 4; -// -// private TencentMap mTencentMap; -// private boolean mHasAdded; -// private boolean mHasEnableText; -// private Polyline polyline; -// private PolylineOptions.Text mPolylineText; -// -// @Override -// protected void onCreate(@Nullable Bundle savedInstanceState, TencentMap tencentMap) { -// super.onCreate(savedInstanceState, tencentMap); -// mTencentMap = tencentMap; -// tencentMap.moveCamera(CameraUpdateFactory.zoomTo(15)); -// } -// -// @Override -// public boolean onCreateOptionsMenu(Menu menu) { -// getMenuInflater().inflate(R.menu.polyline, menu); -// return true; -// } -// -// @Override -// public boolean onPrepareOptionsMenu(Menu menu) { -// menu.findItem(R.id.menu_add).setVisible(!mHasAdded); -// menu.findItem(R.id.menu_text).setTitle(mHasEnableText ? "关闭路名" : "开启路名").setVisible(mHasAdded); -// menu.findItem(R.id.menu_delete).setVisible(mHasAdded); -// return super.onPrepareOptionsMenu(menu); -// } -// -// @Override -// public boolean onOptionsItemSelected(MenuItem item) { -// switch (item.getItemId()) { -// case R.id.menu_add_line_simple: -// mTencentMap.clear(); -// polyline = mTencentMap.addPolyline(setLineStyle(typeSimple)); -// mHasAdded = true; -// break; -// -// case R.id.menu_add_line_dash: -// mTencentMap.clear(); -// polyline = mTencentMap.addPolyline(setLineStyle(typeImage)); -// mHasAdded = true; -// break; -// case R.id.menu_add_line_segment: -// mTencentMap.clear(); -// polyline = mTencentMap.addPolyline(setLineStyle(typeColor)); -// int[] color = {0, 1, 2, 3, 4}; -// int[] index = {0, 1, 2, 3, 4, 5}; -// polyline.setColors(color, index); -// mHasAdded = true; -// break; -// case R.id.menu_add_line_texture: -// mTencentMap.clear(); -// polyline = mTencentMap.addPolyline(setLineStyle((typeArrow))); -// mHasAdded = true; -// break; -// case R.id.menu_add_line_gradient: -// mTencentMap.clear(); -// polyline = mTencentMap.addPolyline(setLineStyle((typeGradient))); -// int[] indexes = {0, 1, 2, 3, 4}; -//// 设置每段索引之间的颜色,这个颜色同样支持纹理颜色,即 PolylineOptions.Colors 中定义的 [0, 10] 值 -// int[] colors = { -// 0xff00ff00, // 线上点 [0, 1] 之间为绿色 -// 0xffffff00, // 线上点 [1, 2] 之间为黄色 -// 0xffff0000, // 线上点 [2, 3] 之间为红色 -// 0xff131313, // 线上点 [3, 4] 之间为黄色 -// 0xff1033f6 // 线上点 [4, 最后一个点] 之间为绿色 -// }; -// polyline.setColors(colors, indexes); -// mHasAdded = true; -// break; -// case R.id.menu_text: -// mHasEnableText = !mHasEnableText; -// if (mHasEnableText) { -// if (mPolylineText == null) { -// mPolylineText = generateText(); -// //设置显示优先级,可选项有HIGH或NORMAL -// mPolylineText.setPriority(PolylineOptions.TextPriority.HIGH); -// //设置字体大小 -// mPolylineText.setTextSize(10); -// //设置填充颜色 -// mPolylineText.setStrokeColor(Color.WHITE); -// //设置文字颜色 -// mPolylineText.setTextColor(Color.BLACK); -// } -// -// polyline.setText(mPolylineText); -// } else { -// polyline.setText(null); -// } -// -// break; -// -// case R.id.menu_delete: -// if (polyline != null) { -// polyline.remove(); -// polyline = null; -// mHasAdded = false; -// mHasEnableText = false; -// -// } -// break; -// } -// return super.onOptionsItemSelected(item); -// } -// -// private PolylineOptions setLineStyle(int type) { -// PolylineOptions polylineOptions = new PolylineOptions().addAll(getLatlons()).lineCap(true); -// switch (type) { -// case 0: -// //设置折线颜色、宽度 -// polylineOptions -// .color(0xff00ff00) -// .width(5f); -// break; -// case 1: -// List list = new ArrayList<>(); -// list.add(35); -// list.add(20); -// polylineOptions -// .lineType(PolylineOptions.LineType.LINE_TYPE_IMAGEINARYLINE) -// .width(10) -// .pattern(list); -// break; -// case 2: -// //线路颜色值纹理图片里的颜色索引 -// polylineOptions -// .colorType(PolylineOptions.ColorType.LINE_COLOR_TEXTURE) -// .color(PolylineOptions.Colors.GREEN) -// .colorTexture(BitmapDescriptorFactory.fromAsset("color_texture.png")); -// break; -// case 3: -// polylineOptions -// .arrow(true) -// .arrowSpacing(30) -// .arrowTexture(BitmapDescriptorFactory.fromAsset("color_arrow_texture.png")); -// break; -// case 4: -// polylineOptions -// .gradient(true) -// .lineType(PolylineOptions.LineType.LINE_TYPE_MULTICOLORLINE) -// .width(20); -// break; -// -// } -// return polylineOptions; -// } -// -// private PolylineOptions.Text generateText() { -// List segmentTexts = new ArrayList<>(); -// //参数分别表示坐标路径数组起点index,终点index,动态路名文字 -// segmentTexts.add(new PolylineOptions.SegmentText(0, 1, "苏州街")); -// segmentTexts.add(new PolylineOptions.SegmentText(1, 2, "北四环西路辅路")); -// segmentTexts.add(new PolylineOptions.SegmentText(2, 4, "彩和坊路")); -// return new PolylineOptions.Text.Builder(segmentTexts).build(); -// } -// -// private List getLatlons() { -// List latLngs = new ArrayList(); -// latLngs.add(new LatLng(39.984864, 116.305756)); -// latLngs.add(new LatLng(39.983618, 116.305848)); -// latLngs.add(new LatLng(39.982347, 116.305966)); -// latLngs.add(new LatLng(39.982412, 116.308111)); -// latLngs.add(new LatLng(39.984122, 116.308224)); -// latLngs.add(new LatLng(39.984955, 116.308099)); -// return latLngs; -// } -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/polyline/LineTextActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/polyline/LineTextActivity.java deleted file mode 100644 index d9fa753..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/polyline/LineTextActivity.java +++ /dev/null @@ -1,132 +0,0 @@ -package cc.winboll.studio.positions.demo.polyline; - -import android.graphics.Color; -import android.os.Bundle; -import android.view.View; -import android.widget.CompoundButton; -import android.widget.Switch; - -import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.Polyline; -import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; - -import java.util.ArrayList; -import java.util.List; - -public class LineTextActivity extends SupportMapFragmentActivity { -// private Polyline polyline; -// private static List mPoints = new ArrayList<>(); -// private Switch switch_style; -// private Switch switch_off; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// initView(); -// tencentMap.moveCamera(CameraUpdateFactory.zoomTo(16)); -// switch_style.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { -// -// @Override -// public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { -// if (polyline == null) { -// return; -// } -// -// PolylineOptions.Text text = polyline.getText(); -// removeText(); -// if (checked) { -// //设置显示优先级,可选项有HIGH或NORMAL -// text.setPriority(PolylineOptions.TextPriority.HIGH); -// //设置字体大小 -// text.setTextSize(10); -// //设置填充颜色 -// text.setStrokeColor(Color.WHITE); -// //设置文字颜色 -// text.setTextColor(Color.BLACK); -// } else { -// //设置显示优先级,可选项有HIGH或NORMAL -// text.setPriority(PolylineOptions.TextPriority.NORMAL); -// //设置字体大小 -// text.setTextSize(8); -// //设置填充颜色 -// text.setStrokeColor(Color.WHITE); -// //设置文字颜色 -// text.setTextColor(Color.GRAY); -// -// } -// -// polyline.setText(text); -// } -// }); -// -// switch_off.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { -// @Override -// public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { -// if (checked) { -// polyline = createLineWithText(); -// } else { -// removeText(); -// polyline.remove(); -// polyline = null; -// } -// } -// }); -// } -// -// -// private void initView() { -// //文字 -// switch_style = (Switch) findViewById(R.id.switch_style); -// switch_style.setVisibility(View.VISIBLE); -// switch_off = (Switch) findViewById(R.id.switch_off); -// switch_off.setVisibility(View.VISIBLE); -// } -// -// public Polyline addLine() { -// Polyline polyline = tencentMap.addPolyline(new PolylineOptions().addAll(mPoints).color(0x22ff0000)); -// -// return polyline; -// } -// -// -// //生成坐标点路径 -// private List generateLatLngs() { -// if (mPoints.size() != 0) -// mPoints = new ArrayList<>(); -// //苏州街 -// mPoints.add(new LatLng(39.982382, 116.305883)); -// //北四环西路辅路 -// mPoints.add(new LatLng(39.984914, 116.305690)); -// //彩和坊路 -// mPoints.add(new LatLng(39.985045, 116.308136)); -// mPoints.add(new LatLng(39.983570, 116.308088)); -// mPoints.add(new LatLng(39.980063, 116.308297)); -// return mPoints; -// } -// -// private PolylineOptions.Text generateText() { -// List segmentTexts = new ArrayList<>(); -// //参数分别表示坐标路径数组起点index,终点index,动态路名文字 -// segmentTexts.add(new PolylineOptions.SegmentText(0, 1, "苏州街")); -// segmentTexts.add(new PolylineOptions.SegmentText(1, 2, "北四环西路辅路")); -// segmentTexts.add(new PolylineOptions.SegmentText(2, 4, "彩和坊路")); -// -// return new PolylineOptions.Text.Builder(segmentTexts).build(); -// } -// -// -// private Polyline createLineWithText() { -// Polyline polyline = tencentMap.addPolyline(new PolylineOptions().addAll(generateLatLngs()).text(generateText())); -// PolylineOptions.Text text = polyline.getText(); -// return polyline; -// } -// -// -// private void removeText() { -// polyline.setText(null); -// } -// -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/polyline/MutablePolylineActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/polyline/MutablePolylineActivity.java deleted file mode 100644 index 0553f73..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/polyline/MutablePolylineActivity.java +++ /dev/null @@ -1,291 +0,0 @@ -package cc.winboll.studio.positions.demo.polyline; - -import android.os.Handler; -import android.os.Looper; -import android.os.Message; -import android.view.Menu; -import android.view.MenuItem; -import android.view.SubMenu; - -import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.Polyline; -import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; - -import java.util.ArrayList; -import java.util.List; - -import androidx.annotation.NonNull; - -/** - * @version v1.0 - * @since 2020/6/11 - */ -public class MutablePolylineActivity extends SupportMapFragmentActivity { -// private boolean mIsAdd; -// private Polyline mPolyline; -// -// private final static Object[][] sData = { -// {"更新1"}, -// {"更新2"}, -// {"重置"}, -// {"删除"}, -// }; -// -// private List mAppendPoints = new ArrayList<>(); -// private int mAppendIndex; -// -// private Handler sHandler = new Handler(Looper.getMainLooper()) { -// @Override -// public void handleMessage(@NonNull Message msg) { -// super.handleMessage(msg); -// -// if (msg.what == 1 && mPolyline != null && mAppendIndex < mAppendPoints.size()) { -// mPolyline.appendPoint(mAppendPoints.get(mAppendIndex)); -// mAppendIndex++; -// -// sendEmptyMessageDelayed(1, 300); -// } -// } -// }; -// -// @Override -// public boolean onCreateOptionsMenu(Menu menu) { -// getMenuInflater().inflate(R.menu.menu_polyline_items, menu); -// -// MenuItem actionMenu = menu.findItem(R.id.menu_actions); -// SubMenu actionSubMenu = actionMenu.getSubMenu(); -// -// for (int i = 0; i < sData.length; i++) { -// Object[] indoor = sData[i]; -// actionSubMenu.add(0, i, 0, String.valueOf(indoor[0])); -// } -// return true; -// } -// -// @Override -// public boolean onPrepareOptionsMenu(Menu menu) { -// menu.findItem(R.id.menu_actions).setVisible(mIsAdd); -// return super.onPrepareOptionsMenu(menu); -// } -// -// @Override -// public boolean onOptionsItemSelected(@NonNull MenuItem item) { -// -// int itemId = item.getItemId(); -// -// if (mPolyline != null && itemId >= 0 && itemId < sData.length) { -// if (itemId == 3) { -// mPolyline.remove(); -// mIsAdd = false; -// mAppendIndex = 0; -// invalidateOptionsMenu(); -// } else if (itemId == 2) { -// mPolyline.setPoints(getPoints(itemId)); -// } else { -// mPolyline.appendPoints(getPoints(itemId)); -// } -// return true; -// } -// -// List pattern = new ArrayList<>(); -// pattern.add(35); -// pattern.add(20); -// -// PolylineOptions options = new PolylineOptions() -// .addAll(getCreatePoints()) -// .width(15); -// -// switch (item.getItemId()) { -// case R.id.menu_add: -// if (mIsAdd) { -// break; -// } -// mIsAdd = true; -// mPolyline = tencentMap.addPolyline(options); -// break; -// case R.id.menu_add_anim: -// if (mIsAdd) { -// break; -// } -// mIsAdd = true; -// -// mPolyline = tencentMap.addPolyline(options); -// -// sHandler.sendEmptyMessage(1); -// break; -// -// } -// invalidateOptionsMenu(); -// return super.onOptionsItemSelected(item); -// } -// -// private static List getCreatePoints() { -// List listPoints = new ArrayList<>(); -// addLine(listPoints); -// return listPoints; -// } -// -// private static List getPoints(int itemId) { -// List listPoints = new ArrayList(); -// if (itemId == 0) { -// addLine1(listPoints); -// } else if (itemId == 1) { -// addLine2(listPoints); -// } else if (itemId == 2) { -// addLine(listPoints); -// } -// -// return listPoints; -// } -// -// private static void addLine(List listPoints) { -// listPoints.add(new LatLng(39.981787, 116.306649)); -// listPoints.add(new LatLng(39.982021, 116.306739)); -// listPoints.add(new LatLng(39.982351, 116.306883)); -// listPoints.add(new LatLng(39.98233, 116.306047)); -// listPoints.add(new LatLng(39.982324, 116.305867)); -// listPoints.add(new LatLng(39.981918, 116.305885)); -// listPoints.add(new LatLng(39.981298, 116.305921)); -// listPoints.add(new LatLng(39.981091, 116.305939)); -// listPoints.add(new LatLng(39.980506, 116.305975)); -// listPoints.add(new LatLng(39.980148, 116.306002)); -// listPoints.add(new LatLng(39.980121, 116.306002)); -// listPoints.add(new LatLng(39.979708, 116.306038)); -// listPoints.add(new LatLng(39.979205, 116.306074)); -// listPoints.add(new LatLng(39.979205, 116.306074)); -// listPoints.add(new LatLng(39.978813, 116.306101)); -// listPoints.add(new LatLng(39.978015, 116.306182)); -// listPoints.add(new LatLng(39.977299, 116.306227)); -// listPoints.add(new LatLng(39.976996, 116.306245)); -// listPoints.add(new LatLng(39.976913, 116.306245)); -// listPoints.add(new LatLng(39.97597, 116.306308)); -// listPoints.add(new LatLng(39.97575, 116.306326)); -// listPoints.add(new LatLng(39.97564, 116.306335)); -// listPoints.add(new LatLng(39.975178, 116.306371)); -// listPoints.add(new LatLng(39.975185, 116.306514)); -// listPoints.add(new LatLng(39.97564, 116.306272)); -// listPoints.add(new LatLng(39.975633, 116.306272)); -// listPoints.add(new LatLng(39.975715, 116.307997)); -// listPoints.add(new LatLng(39.975819, 116.311545)); -// listPoints.add(new LatLng(39.975936, 116.314878)); -// listPoints.add(new LatLng(39.975998, 116.317528)); -// listPoints.add(new LatLng(39.976025, 116.318785)); -// listPoints.add(new LatLng(39.976108, 116.321714)); -// listPoints.add(new LatLng(39.976259, 116.326843)); -// listPoints.add(new LatLng(39.976328, 116.328622)); -// listPoints.add(new LatLng(39.976397, 116.330356)); -// listPoints.add(new LatLng(39.9765, 116.333967)); -// listPoints.add(new LatLng(39.976459, 116.341019)); -// listPoints.add(new LatLng(39.976473, 116.341674)); -// listPoints.add(new LatLng(39.976473, 116.341944)); -// listPoints.add(new LatLng(39.976473, 116.342546)); -// listPoints.add(new LatLng(39.976479, 116.345295)); -// listPoints.add(new LatLng(39.976197, 116.353829)); -// listPoints.add(new LatLng(39.976459, 116.369926)); -// listPoints.add(new LatLng(39.97672, 116.381353)); -// } -// -// private static void addLine2(List listPoints) { -// listPoints.add(new LatLng(39.91254, 116.41786)); -// listPoints.add(new LatLng(39.911258, 116.417905)); -// listPoints.add(new LatLng(39.910459, 116.417923)); -// listPoints.add(new LatLng(39.908557, 116.418049)); -// listPoints.add(new LatLng(39.908337, 116.418058)); -// listPoints.add(new LatLng(39.90824, 116.418067)); -// listPoints.add(new LatLng(39.90669, 116.418148)); -// listPoints.add(new LatLng(39.904795, 116.418283)); -// listPoints.add(new LatLng(39.903416, 116.418265)); -// listPoints.add(new LatLng(39.901218, 116.418408)); -// listPoints.add(new LatLng(39.900805, 116.418417)); -// listPoints.add(new LatLng(39.900805, 116.418426)); -// listPoints.add(new LatLng(39.901335, 116.417968)); -// listPoints.add(new LatLng(39.901342, 116.417968)); -// listPoints.add(new LatLng(39.901342, 116.418004)); -// listPoints.add(new LatLng(39.901197, 116.418193)); -// listPoints.add(new LatLng(39.901204, 116.418426)); -// listPoints.add(new LatLng(39.901218, 116.418552)); -// listPoints.add(new LatLng(39.901087, 116.418624)); -// listPoints.add(new LatLng(39.901053, 116.41884)); -// listPoints.add(new LatLng(39.901004, 116.419028)); -// listPoints.add(new LatLng(39.900922, 116.419388)); -// listPoints.add(new LatLng(39.900839, 116.419774)); -// listPoints.add(new LatLng(39.900749, 116.420043)); -// listPoints.add(new LatLng(39.900722, 116.420178)); -// listPoints.add(new LatLng(39.900667, 116.42034)); -// listPoints.add(new LatLng(39.900619, 116.420519)); -// listPoints.add(new LatLng(39.900557, 116.420744)); -// listPoints.add(new LatLng(39.900515, 116.420915)); -// listPoints.add(new LatLng(39.900488, 116.421067)); -// listPoints.add(new LatLng(39.900467, 116.421274)); -// listPoints.add(new LatLng(39.900467, 116.421301)); -// listPoints.add(new LatLng(39.900467, 116.421301)); -// listPoints.add(new LatLng(39.900674, 116.428856)); -// listPoints.add(new LatLng(39.900681, 116.429287)); -// listPoints.add(new LatLng(39.900674, 116.429287)); -// listPoints.add(new LatLng(39.900694, 116.429745)); -// listPoints.add(new LatLng(39.900736, 116.43173)); -// listPoints.add(new LatLng(39.900729, 116.433132)); -// listPoints.add(new LatLng(39.900729, 116.433267)); -// listPoints.add(new LatLng(39.900743, 116.433545)); -// } -// -// private static void addLine1(List listPoints) { -// listPoints.add(new LatLng(39.976748, 116.382314)); -// listPoints.add(new LatLng(39.976851, 116.388045)); -// listPoints.add(new LatLng(39.976892, 116.393597)); -// listPoints.add(new LatLng(39.976906, 116.394199)); -// listPoints.add(new LatLng(39.976906, 116.394298)); -// listPoints.add(new LatLng(39.976996, 116.405949)); -// listPoints.add(new LatLng(39.977016, 116.407692)); -// listPoints.add(new LatLng(39.97701, 116.417564)); -// listPoints.add(new LatLng(39.97701, 116.417564)); -// listPoints.add(new LatLng(39.977127, 116.417591)); -// listPoints.add(new LatLng(39.977127, 116.417582)); -// listPoints.add(new LatLng(39.969017, 116.417932)); -// listPoints.add(new LatLng(39.968549, 116.417977)); -// listPoints.add(new LatLng(39.9666, 116.418094)); -// listPoints.add(new LatLng(39.965099, 116.418193)); -// listPoints.add(new LatLng(39.963957, 116.418256)); -// listPoints.add(new LatLng(39.961533, 116.418301)); -// listPoints.add(new LatLng(39.959343, 116.418301)); -// listPoints.add(new LatLng(39.95422, 116.418732)); -// listPoints.add(new LatLng(39.952375, 116.418858)); -// listPoints.add(new LatLng(39.952106, 116.418876)); -// listPoints.add(new LatLng(39.95192, 116.418849)); -// listPoints.add(new LatLng(39.951693, 116.418696)); -// listPoints.add(new LatLng(39.951528, 116.418525)); -// listPoints.add(new LatLng(39.951383, 116.41822)); -// listPoints.add(new LatLng(39.95128, 116.417941)); -// listPoints.add(new LatLng(39.951239, 116.417609)); -// listPoints.add(new LatLng(39.951218, 116.417312)); -// listPoints.add(new LatLng(39.951218, 116.417088)); -// listPoints.add(new LatLng(39.951197, 116.416899)); -// listPoints.add(new LatLng(39.951115, 116.416675)); -// listPoints.add(new LatLng(39.950984, 116.416513)); -// listPoints.add(new LatLng(39.950839, 116.416378)); -// listPoints.add(new LatLng(39.950639, 116.41627)); -// listPoints.add(new LatLng(39.950426, 116.416217)); -// listPoints.add(new LatLng(39.950095, 116.416243)); -// listPoints.add(new LatLng(39.948835, 116.416486)); -// listPoints.add(new LatLng(39.948697, 116.416486)); -// listPoints.add(new LatLng(39.945557, 116.416648)); -// listPoints.add(new LatLng(39.941686, 116.416791)); -// listPoints.add(new LatLng(39.941005, 116.4168)); -// listPoints.add(new LatLng(39.938442, 116.416944)); -// listPoints.add(new LatLng(39.936045, 116.417016)); -// listPoints.add(new LatLng(39.933662, 116.417142)); -// listPoints.add(new LatLng(39.929247, 116.417295)); -// listPoints.add(new LatLng(39.927683, 116.417393)); -// listPoints.add(new LatLng(39.926553, 116.417438)); -// listPoints.add(new LatLng(39.924583, 116.417492)); -// listPoints.add(new LatLng(39.924369, 116.417492)); -// listPoints.add(new LatLng(39.921779, 116.417573)); -// listPoints.add(new LatLng(39.919044, 116.417654)); -// listPoints.add(new LatLng(39.917404, 116.417708)); -// listPoints.add(new LatLng(39.917287, 116.417717)); -// listPoints.add(new LatLng(39.916233, 116.417825)); -// listPoints.add(new LatLng(39.913904, 116.417807)); -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/polyline/PolylineOptionsActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/polyline/PolylineOptionsActivity.java deleted file mode 100644 index e99c380..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/polyline/PolylineOptionsActivity.java +++ /dev/null @@ -1,87 +0,0 @@ -package cc.winboll.studio.positions.demo.polyline; - -//import android.os.Bundle; -// -//import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -//import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -//import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -//import com.tencent.tencentmap.mapsdk.maps.model.Polyline; -//import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; -// -//import java.util.ArrayList; -//import java.util.List; -// -//public class PolylineOptionsActivity extends SupportMapFragmentActivity { -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// Polyline polyline = tencentMap.addPolyline(polylineOptions); -// Polyline newPolyline = tencentMap.addPolyline(newPolylineOptions); -// polyline.pattern(patternLine(patterns)); //设置虚线样式 -// } -// -// private int[] patterns = {10, 15, 20}; -// private List patternLine(int [] patterns){ -// List patternLine = new ArrayList<>(); -// if (patterns == null) -// return patternLine; -// for (int i = 0; i < patterns.length; i++) -// patternLine.add(patterns[i]); -// return patternLine; -// } -// -// -// private List transferArrayToList(LatLng[] latLngs){ //坐标数组与List转换 -// List list = new ArrayList<>(); -// if (latLngs == null) -// return list; -// for (int i = 0; i < latLngs.length; i++) -// list.add(latLngs[i]); -// -// return list; -// -// } -// -// private LatLng[] latLngs = { -// new LatLng(39.984864, 116.305756), -// new LatLng(39.983618, 116.305848), -// new LatLng(39.982347, 116.305966), -// new LatLng(39.982412, 116.308111), -// new LatLng(39.984122, 116.308224), -// new LatLng(39.984955, 116.308099), -// new LatLng(39.984864, 116.305756) -// }; -// -// private LatLng[] newLatLngs = { -// new LatLng(39.984864, 116.305756), -// new LatLng(39.983618, 116.305848), -// new LatLng(39.982347, 116.305966), -// new LatLng(39.982412, 116.308111), -// new LatLng(39.984122, 116.308224), -// new LatLng(39.984955, 116.308099), -// new LatLng(39.984864, 116.305756) -// }; -// private PolylineOptions polylineOptions = new PolylineOptions(). -// addAll(transferArrayToList(latLngs)). //添加顶点 -// alpha(0.5f). //设置透明度 -// arrow(true). //导航用 接口 -// arrowSpacing(110). // 设置方向箭头间距 -// arrowTexture(BitmapDescriptorFactory.fromAsset("color_arrow_texture.png")). // 设置箭头纹理 -// borderColor(0xaa323456). //设置描边颜色 -// borderWidth(1f). //设置描边宽度 -// clickable(true). //可点击 -// color(PolylineOptions.Colors.LIGHT_BLUE). //线的颜色 -// colorTexture(BitmapDescriptorFactory.fromAsset("color_texture.png")). //颜色纹理 -// lineCap(true). //路线是否显示半圆端点 -// lineType(PolylineOptions.LineType.LINE_TYPE_MULTICOLORLINE). //设置线的类型 -// visible(true). //设置折线可见性 -// width(10f). //设置线的宽度 -// zIndex(0); //堆叠顺序,越大优先级越高 -// -// -// private PolylineOptions newPolylineOptions = new PolylineOptions().add(newLatLngs). -// lineType(PolylineOptions.LineType.LINE_TYPE_DOTTEDLINE). -// visible(true). -// pattern(patternLine(patterns)). -// zIndex(1); -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/search/DistrictActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/search/DistrictActivity.java deleted file mode 100644 index d8658dd..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/search/DistrictActivity.java +++ /dev/null @@ -1,174 +0,0 @@ -package cc.winboll.studio.positions.demo.search; - -import android.os.Bundle; -import android.util.Log; -import android.view.View; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.Spinner; -import android.widget.TextView; -import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.lbssearch.TencentSearch; -import com.tencent.lbssearch.httpresponse.BaseObject; -import com.tencent.lbssearch.httpresponse.HttpResponseListener; -import com.tencent.lbssearch.object.param.DistrictChildrenParam; -import com.tencent.lbssearch.object.result.DistrictResultObject; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import java.util.ArrayList; -import java.util.List; - -public class DistrictActivity extends SupportMapFragmentActivity { -// private Spinner spProvince; -// private Spinner spCity; -// private Spinner spDistrict; -// private TextView tvResult; -// private List latLngs = new ArrayList<>(); -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// initView(); -// initSpinner(); -// } -// -// protected void initView() { -// spProvince = (Spinner) findViewById(R.id.sp_province); -// spCity = (Spinner) findViewById(R.id.sp_city); -// spDistrict = (Spinner) findViewById(R.id.sp_district); -// tvResult = (TextView) findViewById(R.id.tv_result); -// spProvince.setVisibility(View.VISIBLE); -// spCity.setVisibility(View.VISIBLE); -// spDistrict.setVisibility(View.VISIBLE); -// tvResult.setVisibility(View.VISIBLE); -// } -// -// protected void initSpinner() { -// -// //初始化行政区划,像北京市等只有市和区两级的数据,可能会输出错误id -// getDistrict(0, R.id.sp_province); -// AdapterView.OnItemSelectedListener onItemSelectedListener = new AdapterView.OnItemSelectedListener() { -// -// @Override -// public void onItemSelected(AdapterView parent, View view, -// int position, long id) { -// // TODO Auto-generated method stub -// switch (parent.getId()) { -// case R.id.sp_province: -// getDistrict(((List) parent.getTag()). -// get(position).intValue(), R.id.sp_city); -// break; -// case R.id.sp_city: -// getDistrict(((List) parent.getTag()). -// get(position).intValue(), R.id.sp_district); -// break; -// case R.id.sp_district: -// getDistrict(((List) parent.getTag()). -// get(position).intValue(), R.id.sp_district); -// tencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(latLngs.get(position), 15f, 0, 0))); -// default: -// break; -// } -// } -// -// @Override -// public void onNothingSelected(AdapterView parent) { -// // TODO Auto-generated method stub -// -// } -// }; -// spProvince.setOnItemSelectedListener(onItemSelectedListener); -// spCity.setOnItemSelectedListener(onItemSelectedListener); -// spDistrict.setOnItemSelectedListener(onItemSelectedListener); -// } -// -// /** -// * 获取行政区划 -// */ -// protected void getDistrict(int pDistrict, final int spId) { -// TencentSearch tencentSearch = new TencentSearch(this); -// DistrictChildrenParam districtChildrenParam = new DistrictChildrenParam(); -// Log.d("eqrwqeqewr", "getDistrict: " + spId); -// //如果不设置id,则获取全部数据 -// if (spId != R.id.sp_province && spId == R.id.sp_city) { -// districtChildrenParam.id(pDistrict); -// } -// if (spId != R.id.sp_province && spId != R.id.sp_city) { -// districtChildrenParam.id(pDistrict); -// } -// -// tencentSearch.getDistrictChildren(districtChildrenParam, new HttpResponseListener() { -// -// @Override -// public void onSuccess(int arg0, BaseObject arg1) { -// // TODO Auto-generated method stub -// if (arg1 == null) { -// return; -// } -// DistrictResultObject obj = (DistrictResultObject) arg1; -// switch (spId) { -// case R.id.sp_province: -// setDistrictAdapter(spProvince, obj); -// break; -// case R.id.sp_city: -// setDistrictAdapter(spCity, obj); -// break; -// case R.id.sp_district: -// setDistrictAdapter(spDistrict, obj); -// break; -// -// default: -// break; -// } -// } -// -// @Override -// public void onFailure(int arg0, String arg1, Throwable arg2) { -// // TODO Auto-generated method stub -// // printResult(arg1); -// } -// }); -// } -// -// /** -// * 设置行政区划的adapter -// * -// * @param spinner 要设置adapter的spinner -// * @param obj 用于填充adapter的数据源 -// */ -// protected void setDistrictAdapter(Spinner spinner, final DistrictResultObject obj) { -// List names = new ArrayList(); -// List ids = new ArrayList(); -// latLngs.clear(); -// final List districtResults = obj.result.get(0); -// for (final DistrictResultObject.DistrictResult result : districtResults) { -// names.add(result.fullname); -// ids.add(result.id); -// latLngs.add(result.latLng); -// Log.d("位置", "setDistrictAdapter: " + result.fullname); -// -// } -// ArrayAdapter adapter = new ArrayAdapter(this, -// android.R.layout.simple_spinner_item, names); -// spinner.setAdapter(adapter); -// //将行政区划编码附到spinner方便后续查询 -// spinner.setTag(ids); -// -// } -// -// -// protected void printResult(final String result) { -// runOnUiThread(new Runnable() { -// -// @Override -// public void run() { -// // TODO Auto-generated method stub -// tvResult.setText(result); -// } -// }); -// } -// -} - diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/search/DrivingRouteActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/search/DrivingRouteActivity.java deleted file mode 100644 index b0972bd..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/search/DrivingRouteActivity.java +++ /dev/null @@ -1,75 +0,0 @@ -package cc.winboll.studio.positions.demo.search; - -import android.os.Bundle; -import android.util.Log; - -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.lbssearch.TencentSearch; -import com.tencent.lbssearch.httpresponse.HttpResponseListener; -import com.tencent.lbssearch.object.param.DrivingParam; -import com.tencent.lbssearch.object.result.DrivingResultObject; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds; -import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; - -import java.util.List; - -public class DrivingRouteActivity extends SupportMapFragmentActivity { -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// CameraUpdate cameraSigma = -// CameraUpdateFactory.newCameraPosition(new CameraPosition( -// new LatLng(24.66493, 117.09568), -// 15, -// 0f, -// 0f)); -// //移动地图 -// tencentMap.moveCamera(cameraSigma); -// getDrivingRoute(); -// } -// -// private LatLng fromPoint = new LatLng(24.66493, 117.09568); // 起点坐标 -// private LatLng toPoint = new LatLng(26.8857, 120.00514); //终点坐标 -// -// /** -// * 获取驾车路线规划 -// */ -// private void getDrivingRoute() { -// long l = (System.currentTimeMillis() / 1000)+1000; -// Log.d("时间戳", "getDrivingRoute: " + l); -// DrivingParam drivingParam = new DrivingParam(fromPoint, toPoint); //创建导航参数 -// drivingParam.roadType(DrivingParam.RoadType.ON_MAIN_ROAD_BELOW_BRIDGE); -// drivingParam.heading(90); -// drivingParam.accuracy(30); -// //drivingParam.departureTime(l) -// TencentSearch tencentSearch = new TencentSearch(this); -// tencentSearch.getRoutePlan(drivingParam, new HttpResponseListener() { -// -// @Override -// public void onSuccess(int i, DrivingResultObject drivingResultObject) { -// if (drivingResultObject == null) { -// return; -// } -// for (DrivingResultObject.Route route : drivingResultObject.result.routes) { -// List lines = route.polyline; -// tencentMap.addPolyline(new PolylineOptions().addAll(lines).color(0x22ff0000)); -// tencentMap.moveCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder() -// .include(route.polyline).build(), 100)); -// tencentMap.moveCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder() -// .include(lines).build(), 100)); -// } -// } -// -// @Override -// public void onFailure(int i, String s, Throwable throwable) { -// -// } -// }); -// } - -} - diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/search/GeoCoderActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/search/GeoCoderActivity.java deleted file mode 100644 index 2530362..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/search/GeoCoderActivity.java +++ /dev/null @@ -1,186 +0,0 @@ -package cc.winboll.studio.positions.demo.search; - -import android.content.Context; -import android.os.Bundle; -import android.view.View; -import android.widget.Button; -import android.widget.EditText; -import android.widget.TextView; -import android.widget.Toast; - -import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.lbssearch.TencentSearch; -import com.tencent.lbssearch.httpresponse.BaseObject; -import com.tencent.lbssearch.httpresponse.HttpResponseListener; -import com.tencent.lbssearch.httpresponse.Poi; -import com.tencent.lbssearch.object.param.Address2GeoParam; -import com.tencent.lbssearch.object.param.Geo2AddressParam; -import com.tencent.lbssearch.object.result.Address2GeoResultObject; -import com.tencent.lbssearch.object.result.Geo2AddressResultObject; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; - -public class GeoCoderActivity extends SupportMapFragmentActivity { - -// private EditText etGeocoder; -// private Button btnGeocoder; -// private EditText etRegeocoder; -// private Button btnRegeocoder; -// private TextView tvResult; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// initView(); -// } -// -// -// private void initView(){ -// etGeocoder = (EditText) findViewById(R.id.et_geocoder); -// btnGeocoder = (Button) findViewById(R.id.btn_geocoder); -// etRegeocoder = (EditText) findViewById(R.id.et_regeocoder); -// btnRegeocoder = (Button) findViewById(R.id.btn_regeocoder); -// etGeocoder.setVisibility(View.VISIBLE); -// btnGeocoder.setVisibility(View.VISIBLE); -// etRegeocoder.setVisibility(View.VISIBLE); -// btnRegeocoder.setVisibility(View.VISIBLE); -// tvResult = (TextView) findViewById(R.id.tv_result); -// tvResult.setVisibility(View.VISIBLE); -// btnGeocoder.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View view) { -// geocoder(); -// } -// }); -// -// btnRegeocoder.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View view) { -// reGeocoder(); -// } -// }); -// } -// /** -// *地理编码 -// */ -// protected void geocoder() { -// TencentSearch tencentSearch = new TencentSearch(this); -// String address = etGeocoder.getText().toString(); -// Address2GeoParam address2GeoParam = -// new Address2GeoParam(address).region("北京"); -// tencentSearch.address2geo(address2GeoParam, new HttpResponseListener() { -// -// @Override -// public void onSuccess(int arg0, BaseObject arg1) { -// // TODO Auto-generated method stub -// if (arg1 == null) { -// return; -// } -// Address2GeoResultObject obj = (Address2GeoResultObject)arg1; -// StringBuilder sb = new StringBuilder(); -// sb.append("地址解析"); -// if (obj.result.latLng != null) { -// sb.append("\n坐标:" + obj.result.latLng.toString()); -// } else { -// sb.append("\n无坐标"); -// } -// printResult(sb.toString()); -// tencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(obj.result.latLng,15f, 0, 0))); -// tencentMap.addMarker(new MarkerOptions() -// .position(obj.result.latLng)); -// } -// -// @Override -// public void onFailure(int arg0, String arg1, Throwable arg2) { -// // TODO Auto-generated method stub -// printResult(arg1); -// } -// }); -// } -// -// /** -// * 逆地理编码 -// */ -// protected void reGeocoder() { -// String str = etRegeocoder.getText().toString().trim(); -// LatLng latLng = str2Coordinate(this, str); -// if (latLng == null) { -// return; -// } -// TencentSearch tencentSearch = new TencentSearch(this); -// //还可以传入其他坐标系的坐标,不过需要用coord_type()指明所用类型 -// //这里设置返回周边poi列表,可以在一定程度上满足用户获取指定坐标周边poi的需求 -// Geo2AddressParam geo2AddressParam = new Geo2AddressParam(latLng).getPoi(true) -// .setPoiOptions(new Geo2AddressParam.PoiOptions() -// .setRadius(1000).setCategorys("面包") -// .setPolicy(Geo2AddressParam.PoiOptions.POLICY_O2O)); -// tencentSearch.geo2address(geo2AddressParam, new HttpResponseListener() { -// -// @Override -// public void onSuccess(int arg0, BaseObject arg1) { -// // TODO Auto-generated method stub -// if (arg1 == null) { -// return; -// } -// Geo2AddressResultObject obj = (Geo2AddressResultObject)arg1; -// StringBuilder sb = new StringBuilder(); -// sb.append("逆地址解析"); -// sb.append("\n地址:" + obj.result.address); -// sb.append("\npois:"); -// for (Poi poi : obj.result.pois) { -// sb.append("\n\t" + poi.title); -// tencentMap.addMarker(new MarkerOptions() -// .position(poi.latLng) //标注的位置 -// .title(poi.title) //标注的InfoWindow的标题 -// .snippet(poi.address) //标注的InfoWindow的内容 -// ); -// } -// //printResult(sb.toString()); -// } -// -// @Override -// public void onFailure(int arg0, String arg1, Throwable arg2) { -// // TODO Auto-generated method stub -// printResult(arg1); -// } -// }); -// } -// -// -// /** -// * 由字符串获取坐标 -// * @param context -// * @param str -// * @return -// */ -// public static LatLng str2Coordinate(Context context, String str) { -// if (!str.contains(",")) { -// Toast.makeText(context, "经纬度用\",\"分割", Toast.LENGTH_SHORT).show(); -// return null; -// } -// String[] strs = str.split(","); -// double lat = 0; -// double lng = 0; -// try { -// lat = Double.parseDouble(strs[0]); -// lng = Double.parseDouble(strs[1]); -// } catch (NumberFormatException e) { -// Toast.makeText(context, e.toString(), Toast.LENGTH_SHORT).show(); -// return null; -// } -// return new LatLng(lat, lng); -// } -// protected void printResult(final String result) { -// runOnUiThread(new Runnable() { -// -// @Override -// public void run() { -// // TODO Auto-generated method stub -// tvResult.setText(result); -// } -// }); -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/search/SearchBasicActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/search/SearchBasicActivity.java deleted file mode 100644 index f97239a..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/search/SearchBasicActivity.java +++ /dev/null @@ -1,305 +0,0 @@ -package cc.winboll.studio.positions.demo.search; - -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.text.Editable; -import android.text.TextWatcher; -import android.util.Log; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.BaseAdapter; -import android.widget.Button; -import android.widget.EditText; -import android.widget.ListView; -import android.widget.TextView; -import android.widget.Toast; - -import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.lbssearch.TencentSearch; -import com.tencent.lbssearch.httpresponse.BaseObject; -import com.tencent.lbssearch.httpresponse.HttpResponseListener; -import com.tencent.lbssearch.object.param.SearchParam; -import com.tencent.lbssearch.object.param.SuggestionParam; -import com.tencent.lbssearch.object.result.SearchResultObject; -import com.tencent.lbssearch.object.result.SuggestionResultObject; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; - -import java.lang.ref.WeakReference; -import java.util.List; - -public class SearchBasicActivity extends SupportMapFragmentActivity { -// private EditText etSearch; -// private Button btnSearch; -// private ListView lvSuggesion; -// private SuggestionAdapter suggestionAdapter; -// private final int MSG_SUGGESTION = 10000; -// private final MyHandler handler = new MyHandler(this); -// -// private static class MyHandler extends Handler { -// private final WeakReference mActivity; -// -// public MyHandler(SearchBasicActivity activity) { -// // TODO Auto-generated constructor stub -// mActivity = new WeakReference<>(activity); -// } -// -// @Override -// public void handleMessage(Message msg) { -// // TODO Auto-generated method stub -// SearchBasicActivity activity = mActivity.get(); -// if (activity != null) { -// activity.handleMessage(msg); -// } -// } -// } -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// initView(); -// } -// -// protected void initView(){ -// etSearch = (EditText) findViewById(R.id.et_search_poi); -// btnSearch = (Button) findViewById(R.id.btn_search_poi); -// etSearch.setVisibility(View.VISIBLE); -// btnSearch.setVisibility(View.VISIBLE); -// lvSuggesion = (ListView) findViewById(R.id.lv_suggestions); -// -// etSearch.addTextChangedListener(textWatcher); -// etSearch.setOnFocusChangeListener(new View.OnFocusChangeListener() { -// -// @Override -// public void onFocusChange(View v, boolean hasFocus) { -// // TODO Auto-generated method stub -// if (!etSearch.hasFocus()) { -// lvSuggesion.setVisibility(View.GONE); -// } -// } -// }); -// -// lvSuggesion.setOnItemClickListener(new AdapterView.OnItemClickListener() { -// -// @Override -// public void onItemClick(AdapterView parent, View view, -// int position, long id) { -// // TODO Auto-generated method stub -// etSearch.removeTextChangedListener(textWatcher); -// CharSequence cs = -// ((TextView)view.findViewById(R.id.label)).getText(); -// etSearch.setText(cs); -// lvSuggesion.setVisibility(View.GONE); -// etSearch.addTextChangedListener(textWatcher); -// } -// }); -// -// btnSearch.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View view) { -// searchPoi(); -// } -// }); -// } -// -// final TextWatcher textWatcher = new TextWatcher() { -// -// @Override -// public void onTextChanged(CharSequence s, int start, int before, int count) { -// // TODO Auto-generated method stub -// suggestion(s.toString()); -// } -// -// @Override -// public void beforeTextChanged(CharSequence s, int start, int count, -// int after) { -// // TODO Auto-generated method stub -// -// } -// -// @Override -// public void afterTextChanged(Editable s) { -// // TODO Auto-generated method stub -// -// } -// }; -// -// -// -// /** -// * poi检索 -// */ -// protected void searchPoi() { -// TencentSearch tencentSearch = new TencentSearch(this); -// String keyWord = etSearch.getText().toString().trim(); -// //城市搜索 -// SearchParam.Region region = new SearchParam.Region("北京").//设置搜索城市 -// autoExtend(false);//设置搜索范围不扩大 -// //圆形范围搜索 -// LatLng latLng1 = new LatLng(39.984154, 116.307490); -// SearchParam.Nearby nearBy = new SearchParam.Nearby(latLng1, 1000); -// //矩形搜索,这里的范围是故宫 -// LatLng latLng2 = new LatLng(39.913127, 116.392164); -// LatLng latLng3 = new LatLng(39.923034, 116.402078); -// SearchParam.Rectangle rectangle = new SearchParam.Rectangle(latLng2, latLng3); -// -// //filter()方法可以设置过滤类别, -// //search接口还提供了排序方式、返回条目数、返回页码具体用法见文档, -// //同时也可以参考官网的webservice对应接口的说明 -// SearchParam searchParam = new SearchParam(keyWord, region);//.pageIndex(0).pageSize(20).filter("大学,中学"); -// tencentSearch.search(searchParam, new HttpResponseListener() { -// -// @Override -// public void onFailure(int arg0, String arg2, -// Throwable arg3) { -// Toast.makeText(getApplicationContext(), arg2, Toast.LENGTH_LONG).show(); -// } -// -// @Override -// public void onSuccess(int arg0, BaseObject arg1) { -// if (arg1 == null) { -// return; -// } -// SearchResultObject obj = (SearchResultObject) arg1; -// if(obj.data == null){ -// return; -// } -// tencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(obj.data.get(0).latLng,15f, 0, 0))); -// for(SearchResultObject.SearchResultData data : obj.data){ -// Log.v("SearchDemo","title:"+data.title + ";" + data.address); -// tencentMap.addMarker(new MarkerOptions() -// .position(data.latLng) //标注的位置 -// .title(data.title) //标注的InfoWindow的标题 -// .snippet(data.address) //标注的InfoWindow的内容 -// ); -// -// } -// } -// }); -// } -// -// public void handleMessage(Message msg) { -// switch (msg.what) { -// case MSG_SUGGESTION: -// showAutoComplete((SuggestionResultObject)msg.obj); -// break; -// -// default: -// break; -// } -// } -// -// /** -// * 显示完整ListView -// * @param obj -// */ -// protected void showAutoComplete(SuggestionResultObject obj) { -// if (obj.data.size() == 0) { -// lvSuggesion.setVisibility(View.GONE); -// return; -// } -// if (suggestionAdapter == null) { -// suggestionAdapter = new SuggestionAdapter(obj.data); -// lvSuggesion.setAdapter(suggestionAdapter); -// } else { -// suggestionAdapter.setDatas(obj.data); -// suggestionAdapter.notifyDataSetChanged(); -// } -// lvSuggesion.setVisibility(View.VISIBLE); -// } -// /** -// * 关键字提示 -// * @param keyword -// */ -// protected void suggestion(String keyword) { -// if (keyword.trim().length() == 0) { -// lvSuggesion.setVisibility(View.GONE); -// return; -// } -// TencentSearch tencentSearch = new TencentSearch(this); -// SuggestionParam suggestionParam = new SuggestionParam(keyword, "北京"); -// //suggestion也提供了filter()方法和region方法 -// //具体说明见文档,或者官网的webservice对应接口 -// tencentSearch.suggestion(suggestionParam, new HttpResponseListener() { -// -// @Override -// public void onSuccess(int arg0, BaseObject arg1) { -// if (arg1 == null || -// etSearch.getText().toString().trim().length() == 0) { -// lvSuggesion.setVisibility(View.GONE); -// return; -// } -// -// Message msg = new Message(); -// msg.what = MSG_SUGGESTION; -// msg.obj = arg1; -// handler.sendMessage(msg); -// } -// -// @Override -// public void onFailure(int arg0, String arg1, Throwable arg2) { -// //printResult(arg1); -// } -// }); -// } -// -// class SuggestionAdapter extends BaseAdapter { -// -// List mSuggestionDatas; -// -// public SuggestionAdapter(List suggestionDatas) { -// // TODO Auto-generated constructor stub -// setDatas(suggestionDatas); -// } -// -// public void setDatas(List suggestionDatas) { -// mSuggestionDatas = suggestionDatas; -// } -// -// @Override -// public int getCount() { -// // TODO Auto-generated method stub -// return mSuggestionDatas.size(); -// } -// -// @Override -// public Object getItem(int position) { -// // TODO Auto-generated method stub -// return mSuggestionDatas.get(position); -// } -// -// @Override -// public long getItemId(int position) { -// // TODO Auto-generated method stub -// return position; -// } -// -// @Override -// public View getView(int position, View convertView, ViewGroup parent) { -// // TODO Auto-generated method stub -// ViewHolder viewHolder; -// if (convertView == null) { -// convertView = View.inflate(SearchBasicActivity.this, -// R.layout.suggestion_list_item, null); -// viewHolder = new ViewHolder(); -// viewHolder.tvTitle = (TextView) convertView.findViewById(R.id.label); -// viewHolder.tvAddress = (TextView) convertView.findViewById(R.id.desc); -// convertView.setTag(viewHolder); -// } else { -// viewHolder = (ViewHolder) convertView.getTag(); -// } -// viewHolder.tvTitle.setText(mSuggestionDatas.get(position).title); -// viewHolder.tvAddress.setText(mSuggestionDatas.get(position).address); -// return convertView; -// } -// -// private class ViewHolder{ -// TextView tvTitle; -// TextView tvAddress; -// } -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/search/TransitRouteActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/search/TransitRouteActivity.java deleted file mode 100644 index 10c7c31..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/search/TransitRouteActivity.java +++ /dev/null @@ -1,93 +0,0 @@ -package cc.winboll.studio.positions.demo.search; - -//import android.os.Bundle; -//import android.util.Log; -// -//import com.tencent.lbssearch.TencentSearch; -//import com.tencent.lbssearch.httpresponse.HttpResponseListener; -//import com.tencent.lbssearch.object.param.TransitParam; -//import com.tencent.lbssearch.object.result.TransitResultObject; -//import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -//import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -//import com.tencent.tencentmap.mapsdk.maps.TencentMap; -//import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -//import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -//import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; -// -//import java.util.List; -// -//public class TransitRouteActivity extends SupportMapFragmentActivity { -// private LatLng fromPoint = new LatLng(40.127265, 116.208051); // 起点坐标 -// private LatLng toPoint = new LatLng(40.040219, 116.273348); //终点坐标 -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// //移动地图 -// tencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition( -// new LatLng(40.080287, 116.244949), -// 12, -// 0f, -// 0f))); -// getTransitRoute(); -// tencentMap.setOnMapClickListener(new TencentMap.OnMapClickListener() { -// @Override -// public void onMapClick(LatLng latLng) { -// Log.d("TAG", "onMapClick: "+latLng); -// } -// }); -// } -// -// /** -// * 获取公交路径规划 -// * TransitResultObject中的Segment是抽象类,要转换成具体的子类才能获取数据 -// */ -// private void getTransitRoute() { -// TransitParam transitParam = new TransitParam(fromPoint, toPoint); -// TencentSearch tencentSearch = new TencentSearch(this); -// transitParam.policy(TransitParam.Policy.LEAST_WALKING, TransitParam.Preference.NO_SUBWAY); -// tencentSearch.getRoutePlan(transitParam, new HttpResponseListener() { -// -// @Override -// public void onSuccess(int i, TransitResultObject transitResultObject) { -// if (transitResultObject == null) { -// Log.i("TAG", "baseObject为空"); -// return; -// } -// showTransitRoute(transitResultObject); -// -// } -// -// @Override -// public void onFailure(int i, String s, Throwable throwable) { -// Log.d("TransitRouteActivity", "onFailure: " + s); -// } -// }); -// } -// -// private void showTransitRoute(TransitResultObject transitResultObject) { -// tencentMap.clearAllOverlays(); -// if (transitResultObject.result != null && transitResultObject.result.routes != null && transitResultObject.result.routes.size() > 0) { -// for (int i = 0; i < transitResultObject.result.routes.size(); i++) { -// TransitResultObject.Route route = transitResultObject.result.routes.get(i); -// -// List steps = route.steps; -// for (int j = 0; j < steps.size(); j++) { -// TransitResultObject.Segment segment = steps.get(j); -// if (segment instanceof TransitResultObject.Transit) { -// TransitResultObject.Transit transit = (TransitResultObject.Transit) segment; -// tencentMap.addPolyline(new PolylineOptions().addAll(transit.lines.get(0).polyline).color(i + 1).width(20)); -// -// } else if (segment instanceof TransitResultObject.Walking) { -// TransitResultObject.Walking walking = (TransitResultObject.Walking) segment; -// tencentMap.addPolyline(new PolylineOptions().addAll(walking.polyline).color(j + 1).lineType(PolylineOptions.LineType.LINE_TYPE_IMAGEINARYLINE).width(20)); -// } -// -// } -// } -// -// } else { -// Log.i("TAG", "路线结果为空"); -// } -// } -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/search/TruckingRouteActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/search/TruckingRouteActivity.java deleted file mode 100644 index ecd40e8..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/search/TruckingRouteActivity.java +++ /dev/null @@ -1,77 +0,0 @@ -package cc.winboll.studio.positions.demo.search; - -import androidx.appcompat.app.AppCompatActivity; - -import android.os.Bundle; -import android.util.Log; - -import com.tencent.lbssearch.TencentSearch; -import com.tencent.lbssearch.httpresponse.HttpResponseListener; -import com.tencent.lbssearch.object.param.TransitParam; -import com.tencent.lbssearch.object.param.TruckingParam; -import com.tencent.lbssearch.object.result.RoutePlanningObject; -import com.tencent.lbssearch.object.result.TransitResultObject; -import com.tencent.lbssearch.object.result.TruckingResultObject; -import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds; -import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; - -import java.util.List; - -public class TruckingRouteActivity extends SupportMapFragmentActivity { -// private LatLng fromPoint = new LatLng(40.127265, 116.208051); // 起点坐标 -// private LatLng toPoint = new LatLng(40.040219, 116.273348); //终点坐标 -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// CameraUpdate cameraSigma = -// CameraUpdateFactory.newCameraPosition(new CameraPosition( -// new LatLng(40.040219, 116.273348), -// 15, -// 0f, -// 0f)); -// //移动地图 -// tencentMap.moveCamera(cameraSigma); -// geTruckingRoute(); -// } -// -// private void geTruckingRoute() { -// TruckingParam truckingParam = new TruckingParam(); -// truckingParam.from(fromPoint); -// truckingParam.to(toPoint); -// truckingParam.setMultRoute(1); -// // truckingParam.setNoPolyline(1); -// truckingParam.trafficSpeed(true); -// TencentSearch tencentSearch = new TencentSearch(this); -// tencentSearch.getRoutePlan(truckingParam, new HttpResponseListener() { -// -// @Override -// public void onSuccess(int i, TruckingResultObject truckingResultObject) { -// if (null != truckingResultObject.result && null != truckingResultObject.result.routes && truckingResultObject.result.routes.size() > 0) { -// for (int j = 0; j < truckingResultObject.result.routes.size(); j++) { -// TruckingResultObject.Result result = truckingResultObject.result; -// TruckingResultObject.Route route = result.routes.get(j); -// // List steps = route.steps; -// tencentMap.addPolyline(new PolylineOptions().addAll(route.polyline).color(i + 1).width(20)); -// tencentMap.moveCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder() -// .include(route.polyline).build(), 100)); -// -// } -// } -// } -// -// @Override -// public void onFailure(int i, String s, Throwable throwable) { -// Log.d("TruckingRouteActivity", "onFailure: " + s); -// -// } -// }); -// -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/search/WalkingRouteActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/search/WalkingRouteActivity.java deleted file mode 100644 index 642265b..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/search/WalkingRouteActivity.java +++ /dev/null @@ -1,76 +0,0 @@ -package cc.winboll.studio.positions.demo.search; - -import android.os.Bundle; -import android.util.Log; - -import com.tencent.lbssearch.object.result.RoutePlanningObject; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.lbssearch.TencentSearch; -import com.tencent.lbssearch.httpresponse.HttpResponseListener; -import com.tencent.lbssearch.object.param.WalkingParam; -import com.tencent.lbssearch.object.result.WalkingResultObject; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds; -import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; - - -public class WalkingRouteActivity extends SupportMapFragmentActivity { - -// private LatLng fromPoint = new LatLng(40.040219, 116.273348); // 起点坐标 -// private LatLng toPoint = new LatLng(40.048055, 116.281166); //终点坐标 -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// getWalkingRoute(); -// } -// -// /** -// * 获取步行路线规划 -// */ -// private void getWalkingRoute() { -// WalkingParam walkingParam = new WalkingParam(); -// walkingParam.from(fromPoint); -// walkingParam.to(toPoint); -// TencentSearch tencentSearch = new TencentSearch(getApplicationContext()); -// Log.i("TAG", "checkParams:" + walkingParam.checkParams()); -// tencentSearch.getRoutePlan(walkingParam, new HttpResponseListener() { -// @Override -// public void onSuccess(int statusCode, WalkingResultObject object) { -// if (object == null) { -// Log.i("TAG", "baseObject为空"); -// return; -// } -// showWalkingRoute(object); -// Log.i("TAG", "message:" + object.message); -// } -// -// @Override -// public void onFailure(int statusCode, String responseString, Throwable throwable) { -// Log.i("TAG:", statusCode + " " + responseString); -// } -// }); -// } -// -// private void showWalkingRoute(WalkingResultObject object) { -// tencentMap.clearAllOverlays(); -// if (object.result != null && object.result.routes != null && object.result.routes.size() > 0) { -// for (int i = 0; i < object.result.routes.size(); i++) { -// WalkingResultObject.Route result = object.result.routes.get(i); -// tencentMap.addPolyline(new PolylineOptions().addAll(result.polyline).color(i + 1).width(20)); -// Log.i("TAG", "distance:" + result.distance + " duration:" + result.duration -// + " mode:" + result.mode + " direction:" + result.direction); -// for (RoutePlanningObject.Step step : result.steps) { -// Log.i("TAG", "step:" + step.road_name + " " + step.distance + " " -// + step.instruction + " " + step.act_desc + " " + step.dir_desc); -// } -// tencentMap.moveCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder() -// .include(result.polyline).build(), 100)); -// } -// -// } else { -// Log.i("TAG", "路线结果为空"); -// } -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/smooth/SmoothMoveActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/smooth/SmoothMoveActivity.java deleted file mode 100644 index d578020..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/smooth/SmoothMoveActivity.java +++ /dev/null @@ -1,257 +0,0 @@ -package cc.winboll.studio.positions.demo.smooth; - -import androidx.appcompat.app.AppCompatActivity; -import androidx.core.graphics.drawable.RoundedBitmapDrawable; -import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory; - -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Matrix; -import android.os.Bundle; -import android.util.Log; -import android.view.View; -import android.widget.Button; -import android.widget.ImageView; - -import cc.winboll.studio.positions.R; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.MapView; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds; -import com.tencent.tencentmap.mapsdk.maps.model.Marker; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; -import com.tencent.tencentmap.mapsdk.maps.model.Polyline; -import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; -import com.tencent.tencentmap.mapsdk.vector.utils.animation.MarkerTranslateAnimator; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Timer; -import java.util.TimerTask; - -import static com.tencent.tencentmap.mapsdk.vector.utils.animation.MarkerTranslateAnimator.MarkerTranslateStatusListener.AnimationStatus.AnimationComplete; - -public class SmoothMoveActivity extends AppCompatActivity implements View.OnClickListener { - -@Override -public void onClick(View p1) -{ -} - -// private MapView mapView; -// private final String mLine = "39.98409,116.30804,39.98409,116.3081,39.98409,116.3081,39.98397,116.30809,39.9823,116.30809,39.9811,116.30817,39.9811,116.30817,39.97918,116.308266,39.97918,116.308266,39.9791,116.30827,39.9791,116.30827,39.979008,116.3083,39.978756,116.3084,39.978386,116.3086,39.977867,116.30884,39.977547,116.308914,39.976845,116.308914,39.975826,116.308945,39.975826,116.308945,39.975666,116.30901,39.975716,116.310486,39.975716,116.310486,39.975754,116.31129,39.975754,116.31129,39.975784,116.31241,39.975822,116.31327,39.97581,116.31352,39.97588,116.31591,39.97588,116.31591,39.97591,116.31735,39.97591,116.31735,39.97593,116.31815,39.975967,116.31879,39.975986,116.32034,39.976055,116.32211,39.976086,116.323395,39.976105,116.32514,39.976173,116.32631,39.976254,116.32811,39.976265,116.3288,39.976345,116.33123,39.976357,116.33198,39.976418,116.33346,39.976418,116.33346,39.97653,116.333755,39.97653,116.333755,39.978157,116.333664,39.978157,116.333664,39.978195,116.33509,39.978195,116.33509,39.978226,116.33625,39.978226,116.33625,39.97823,116.33656,39.97823,116.33656,39.978256,116.33791,39.978256,116.33791,39.978016,116.33789,39.977047,116.33791,39.977047,116.33791,39.97706,116.33768,39.97706,116.33768,39.976967,116.33706,39.976967,116.33697"; -// private TencentMap map; -// private Polyline mPolyline; -// private Marker mCarMarker; -// private LatLng[] mCarLatLngArray; -// private MarkerTranslateAnimator mAnimator; -// private Polyline polyline; -// private ArrayList skews; -// private ArrayList roates; -// private String parentPath; -// private ImageView imageView; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// setContentView(R.layout.activity_smooth_move); -// mapView = findViewById(R.id.map); -// map = mapView.getMap(); -// //解析路线 -// init(); -// Button btLin = findViewById(R.id.button_set); -// Button btStart = findViewById(R.id.satrt); -// Button btStop = findViewById(R.id.stop); -// btLin.setOnClickListener(this); -// btStart.setOnClickListener(this); -// btStop.setOnClickListener(this); -// } -// -// private void init() { -// String[] linePointsStr = mLine.split(","); -// mCarLatLngArray = new LatLng[linePointsStr.length / 4]; -// skews = new ArrayList<>(); -// roates = new ArrayList<>(); -// -// for (int i = 0; i < mCarLatLngArray.length; i++) { -// double latitude = Double.parseDouble(linePointsStr[i * 4]); -// double longitude = Double.parseDouble(linePointsStr[i * 4 + 1]); -// // float skew = Float.parseFloat(linePointsStr[i * 4 + 2]); -// // float roate = Float.parseFloat(linePointsStr[i * 4 + 3]); -// mCarLatLngArray[i] = new LatLng(latitude, longitude); -// // skews.add(skew); -// // roates.add(roate); -// } -// } -// -// @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 onDestroy() { -// super.onDestroy(); -// mapView.onDestroy(); -// } -// -// @Override -// protected void onRestart() { -// super.onRestart(); -// mapView.onRestart(); -// } -// -// @Override -// public void onClick(View v) { -// switch (v.getId()) { -// case R.id.button_set: -// if (polyline == null && mCarMarker == null) { -// //添加小车路线 -// polyline = map.addPolyline(new PolylineOptions().add(mCarLatLngArray).color(R.color.colorPrimaryDark)); -// LatLng carLatLng = mCarLatLngArray[0]; -// mCarMarker = map.addMarker( -// new MarkerOptions(carLatLng) -// .anchor(0.5f, 0.5f) -// .title("即将到达终点") -// .icon(BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.taxi))) -// .flat(true) -// .clockwise(false)); -// //调整最佳视界 -// map.animateCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder().include(Arrays.asList(mCarLatLngArray)).build(), 50)); -// TimerTask timerTask = new TimerTask() { -// @Override -// public void run() { -// if (polyline != null) { -// snapshot(); -// } -// -// } -// }; -// Timer timer = new Timer(); -// timer.schedule(timerTask, 800); -// } -// break; -// case R.id.satrt: -// if (mAnimator == null) { -// //创建移动动画 -// mAnimator = new MarkerTranslateAnimator(mCarMarker, 100 * 1000, mCarLatLngArray, true, new MarkerTranslateAnimator.MarkerTranslateStatusListener() { -// private CameraUpdate cameraSigma; -// -// @Override -// public void onInterpolatePoint(LatLng latLng, int i, AnimationStatus animationStatus) { -// //路线擦出 -// polyline.setEraseable(true); -// polyline.eraseTo(i, latLng); -// -// /* CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBoundsWithMapCenter(LatLngBounds.builder().include(Arrays.asList(mCarLatLngArray)).build(), latLng, 10); -// map.animateCamera(cameraUpdate);*/ -// if (mCarMarker.getRotation() < 90 && mCarMarker.getRotation() > 0) { -// cameraSigma = -// CameraUpdateFactory.newCameraPosition(new CameraPosition( -// latLng, -// 18, -// 60, -// mCarMarker.getRotation() + 180)); -// } else if (mCarMarker.getRotation() >= 90 && mCarMarker.getRotation() <= 180) { -// cameraSigma = -// CameraUpdateFactory.newCameraPosition(new CameraPosition( -// latLng, -// 18, -// 60, -// -mCarMarker.getRotation())); -// } else { -// cameraSigma = -// CameraUpdateFactory.newCameraPosition(new CameraPosition( -// latLng, -// 18, -// 60, -// -mCarMarker.getRotation())); -// } -// -// //移动地图 -// map.moveCamera(cameraSigma); -// map.enableMultipleInfowindow(true); -// if (i == 41) { -// mCarMarker.startAnimation(); -// mCarMarker.showInfoWindow(); -// } -// if (animationStatus == AnimationComplete) { -// mCarMarker.setTitle("到达目的地"); -// } -// } -// }); -// -// -// //开启动画 -// mAnimator.startAnimation(); -// } -// break; -// case R.id.stop: -// if (mAnimator != null && polyline != null && mCarMarker != null) { -// mAnimator.endAnimation(); -// //mAnimator.cancelAnimation(); -// polyline.remove(); -// polyline = null; -// mCarMarker.remove(); -// mCarMarker = null; -// mAnimator = null; -// } -// -// -// break; -// default: -// throw new IllegalStateException("Unexpected value: " + v.getId()); -// } -// } -// -// private void snapshot() { -// imageView = findViewById(R.id.iv); -// -// map.snapshot(new TencentMap.SnapshotReadyCallback() { -// @Override -// public void onSnapshotReady(Bitmap bitmap) { -// RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), bitmap); -// roundedBitmapDrawable.setCircular(true); -// imageView.setImageDrawable(roundedBitmapDrawable); -// } -// }, Bitmap.Config.ARGB_8888); -// } -// -// //设置图片 -// private Bitmap getBitMap(int resourceId) { -// Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId); -// int width = bitmap.getWidth(); -// int height = bitmap.getHeight(); -// int newWidth = 100; -// int newHeight = 150; -// float widthScale = ((float) newWidth) / width; -// float heightScale = ((float) newHeight) / height; -// Matrix matrix = new Matrix(); -// matrix.postScale(widthScale, heightScale); -// bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); -// return bitmap; -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/transaction/AnimateCameraActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/transaction/AnimateCameraActivity.java deleted file mode 100644 index 3348940..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/transaction/AnimateCameraActivity.java +++ /dev/null @@ -1,66 +0,0 @@ -package cc.winboll.studio.positions.demo.transaction; - -import android.os.Bundle; -import android.view.View; -import android.widget.Button; - -import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; - -public class AnimateCameraActivity extends SupportMapFragmentActivity implements View.OnClickListener { - - @Override - public void onClick(View p1) { - } - - -// private Button btn; -// private boolean flag; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// -// btn = findViewById(R.id.btn_bottom); -// btn.setVisibility(View.VISIBLE); -// btn.setText("以动画的方式改变地图视图"); -// btn.setOnClickListener(this); -// -// flag = true; -// } -// -// /** -// * 改变地图视图 -// * @param v -// */ -// @Override -// public void onClick(View v) { -// if(flag){ -// CameraUpdate cameraSigma = -// CameraUpdateFactory.newCameraPosition(new CameraPosition( -// new LatLng(39.977290,116.337000), //新的中心点坐标 -// 19, //新的缩放级别 -// 40f, //俯仰角 0~45° (垂直地图时为0) -// 45f)); //偏航角 0~360° (正北方为0) -// //移动地图 -// tencentMap.animateCamera(cameraSigma); -// flag = !flag; -// }else { -// CameraUpdate cameraSigma = -// CameraUpdateFactory.newCameraPosition(new CameraPosition( -// new LatLng(39.877290,116.437000), //新的中心点坐标 -// 18, //新的缩放级别 -// 0f, //俯仰角 0~45° (垂直地图时为0) -// 0f)); //偏航角 0~360° (正北方为0) -// //移动地图 -// tencentMap.animateCamera(cameraSigma); -// flag = !flag; -// } -// -// } -// -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/transaction/MoveCameraActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/transaction/MoveCameraActivity.java deleted file mode 100644 index 3570e8f..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/transaction/MoveCameraActivity.java +++ /dev/null @@ -1,66 +0,0 @@ -package cc.winboll.studio.positions.demo.transaction; - -import android.os.Bundle; -import android.view.View; -import android.widget.Button; - -import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; - -public class MoveCameraActivity extends SupportMapFragmentActivity implements View.OnClickListener { - - @Override - public void onClick(View p1) { - } - - - -// private Button btn; -// private boolean flag; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// -// btn = findViewById(R.id.btn_bottom); -// btn.setVisibility(View.VISIBLE); -// btn.setText("以移动的方式改变地图视图"); -// btn.setOnClickListener(this); -// -// flag = true; -// } -// -// /** -// * 改变地图视图 -// * @param v -// */ -// @Override -// public void onClick(View v) { -// if(flag){ -// CameraUpdate cameraSigma = -// CameraUpdateFactory.newCameraPosition(new CameraPosition( -// new LatLng(39.977290,116.337000), //新的中心点坐标 -// 19, //新的缩放级别 -// 40f, //俯仰角 0~45° (垂直地图时为0) -// 45f)); //偏航角 0~360° (正北方为0) -// //移动地图 -// tencentMap.moveCamera(cameraSigma); -// flag = !flag; -// }else { -// CameraUpdate cameraSigma = -// CameraUpdateFactory.newCameraPosition(new CameraPosition( -// new LatLng(39.877290,116.437000), //新的中心点坐标 -// 18, //新的缩放级别 -// 0f, //俯仰角 0~45° (垂直地图时为0) -// 0f)); //偏航角 0~360° (正北方为0) -// //移动地图 -// tencentMap.moveCamera(cameraSigma); -// flag = !flag; -// } -// -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/transaction/RotateMapActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/transaction/RotateMapActivity.java deleted file mode 100644 index 2cf410c..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/transaction/RotateMapActivity.java +++ /dev/null @@ -1,28 +0,0 @@ -package cc.winboll.studio.positions.demo.transaction; - -//import android.os.Bundle; -//import android.view.View; -//import android.widget.Button; -// -//import cc.winboll.studio.positions.R; -//import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -//import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; -//import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -// -//public class RotateMapActivity extends SupportMapFragmentActivity { -// private Button btn; -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// btn = findViewById(R.id.btn_bottom); -// btn.setVisibility(View.VISIBLE); -// btn.setText("旋转地图"); -// btn.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View v) { -// CameraUpdate cameraUpdate = CameraUpdateFactory.rotateTo(90f,1.5f); -// tencentMap.animateCamera(cameraUpdate); -// } -// }); -// } -//} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/transaction/ScollMapActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/transaction/ScollMapActivity.java deleted file mode 100644 index 1752224..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/transaction/ScollMapActivity.java +++ /dev/null @@ -1,87 +0,0 @@ -package cc.winboll.studio.positions.demo.transaction; - -import android.os.Bundle; -import android.view.View; -import android.widget.Button; -import android.widget.CompoundButton; -import android.widget.LinearLayout; - -import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; - -public class ScollMapActivity extends SupportMapFragmentActivity implements View.OnClickListener { - - @Override - public void onClick(View p1) { - } - -// private static final int SCROLL_BY_PX = 100; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// LinearLayout linearLayout = findViewById(R.id.ll); -// linearLayout.setVisibility(View.VISIBLE); -// Button scrollLeft = (Button) findViewById(R.id.scroll_left); -// scrollLeft.setOnClickListener(this); -// -// Button scrollRight = (Button) findViewById(R.id.scroll_right); -// scrollRight.setOnClickListener(this); -// -// Button scrollUp = (Button) findViewById(R.id.scroll_up); -// scrollUp.setOnClickListener(this); -// -// Button scrollDown = (Button) findViewById(R.id.scroll_down); -// scrollDown.setOnClickListener(this); -// -// /* btn.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View v) { -// CameraUpdate cameraUpdate = CameraUpdateFactory.scrollBy(50f,50f); -// tencentMap.animateCamera(cameraUpdate); -// } -// });*/ -// } -// -// -// // 根据动画按钮状态,调用函数animateCamera或moveCamera来改变可视区域 -// -// private void changeCamera(CameraUpdate update, TencentMap.CancelableCallback callback) { -// boolean animated = ((CompoundButton) findViewById(R.id.animate)) -// .isChecked(); -// if (animated) { -// tencentMap.animateCamera(update, 1000, callback); -// } else { -// tencentMap.moveCamera(update); -// } -// } -// -// @Override -// public void onClick(View v) { -// switch (v.getId()) { -// //点击向左移动按钮响应事件,camera将向左边移动 -// -// case R.id.scroll_left: -// changeCamera(CameraUpdateFactory.scrollBy(-SCROLL_BY_PX, 0), null); -// break; -// // 点击向右移动按钮响应事件,camera将向右边移动 -// case R.id.scroll_right: -// changeCamera(CameraUpdateFactory.scrollBy(SCROLL_BY_PX, 0), null); -// break; -// // 点击向上移动按钮响应事件,camera将向上边移动 -// case R.id.scroll_up: -// changeCamera(CameraUpdateFactory.scrollBy(0, -SCROLL_BY_PX), null); -// break; -// // 点击向下移动按钮响应事件,camera将向下边移动 -// case R.id.scroll_down: -// changeCamera(CameraUpdateFactory.scrollBy(0, SCROLL_BY_PX), null); -// break; -// -// default: -// break; -// } -// } -} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/transaction/ZoomCalulateActivity.java b/positions/src/main/java/cc/winboll/studio/positions/demo/transaction/ZoomCalulateActivity.java deleted file mode 100644 index 296cbbe..0000000 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/transaction/ZoomCalulateActivity.java +++ /dev/null @@ -1,73 +0,0 @@ -package cc.winboll.studio.positions.demo.transaction; - -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Matrix; -import android.os.Bundle; -import android.view.View; -import android.widget.Button; - -import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; - -import java.util.ArrayList; - -public class ZoomCalulateActivity extends SupportMapFragmentActivity { - -// private Button btn; -// private int leftpadding = 50,rightpadding =50, toppadding = 50, bottompadding=50; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// btn = findViewById(R.id.btn_bottom); -// btn.setVisibility(View.VISIBLE); -// btn.setText("根据点集缩放地图"); -// btn.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View v) { -// CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(addMarker()); -// tencentMap.moveCamera(cameraUpdate); -// } -// }); -// } -// -// -// private CameraPosition addMarker(){ -// ArrayList points = new ArrayList<>(); -// points.add(new LatLng(39.984059,116.307621)); -// points.add(new LatLng(39.984049,116.307631)); -//// points.add(new LatLng(39.981527,116.308994)); -//// points.add(new LatLng(39.984026,116.316419)); -//// points.add(new LatLng(39.978501,116.311827)); -// //根据markers计算缩放级别 -// for(int i=0; iHg$K#o*^3Op;&k7Z-^e*u5f z|38zsq5@RluN2V1d^w-tNm*MvkF#1^;48T0+~8)II|YN6W1yE~EUX+)JSp;u&9Pq- U+d!uy?sOo3222+k75KIScfYe0mjD0& literal 0 HcmV?d00001 diff --git a/positions/src/main/java/com/tencent/.DS_Store b/positions/src/main/java/com/tencent/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..1ec5418c22324c7f67ae20f4e1909792705277a7 GIT binary patch literal 6148 zcmeH~I}XA?3`A{0fkcy%avKi74OR$Fzyb zkk95LdL}*!6`%s+P{6(q1#Ya#7W7XCf{y^;6lFK8eU<==6~LNoK~!KGtzfjOk0Dm~ zcCh4iHQ9pEE}FxK=AG517??)8Xh8zg>R_M(RA8V$7kO{z{}%pj{vWh3r2`X%C`-z*}i#W4;fJ)9A`{&98deh+cX`T?B4^%eUdMEm%V&k z@@<1g1*iZOpaN8Y3M{Tbme}?4;wSS!DnJGPy8`xoC~(7?I0yQt1B15!z!k!7n0qe) zEEWLP#5oWVmj$YvLT}bi|zwb>!3`IW^4*{}x%&4UY=naG*IYBQFB<_~NLy=ua&nLyDZs)=XJ^}KHlnL8^ zuuK4Ud`$1a2w+Ed;?2XtjQM~GpZLN&ec$fadA@s*w&{SU^bw2w+!myO6p#W^Knh5K z6)BL%_-?NP&d{+n$ep{-5c8&HsxQrBXl& zyqE$uoIXxRzEqyAzh2Mlm#q4_(aE@+;m1z^6F-U%^f2xhUywD~I$5FVM<8TSkOKdz Fz!O6Z5~=_I literal 0 HcmV?d00001 diff --git a/positions/src/main/java/com/tencent/map/vector/demo/.DS_Store b/positions/src/main/java/com/tencent/map/vector/demo/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..e7a62d4689f3df07f69aff374858200ad5a25ace GIT binary patch literal 6148 zcmeHKOKL(v5Ufsw2-&!FIalxogP0TK0wGb{2!h7_Tjg9HE!7`Fjf|aFr_=<%fs0Gx%Lj3PX|Mc0K^H?VO+;7 zL2RBN_QD~N8JZ=Pm{h9~!;;Q?tGZq|BqkkJ!-v($RuhWF>3n~Sa#&APlmb%VQh~?Z z&b&~MEDmn7|^fE2hZ1#GfaC;8d9Q8sH@erH>26#Hg(2E8G1@UV-j3%{ cly%M5eBKL(#Go@DbfSI+To;)X_-_Ti0cP42sQ>@~ literal 0 HcmV?d00001 diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/AbsActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/AbsActivity.java similarity index 94% rename from positions/src/main/java/cc/winboll/studio/positions/demo/AbsActivity.java rename to positions/src/main/java/com/tencent/map/vector/demo/AbsActivity.java index d73d2e8..d7a3eb6 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/AbsActivity.java +++ b/positions/src/main/java/com/tencent/map/vector/demo/AbsActivity.java @@ -1,4 +1,4 @@ -package cc.winboll.studio.positions.demo; +package com.tencent.map.vector.demo; import android.content.pm.PackageManager; import android.os.Build; @@ -6,7 +6,7 @@ import android.os.Bundle; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import androidx.appcompat.app.AppCompatActivity; - +import cc.winboll.studio.positions.R; import java.util.ArrayList; import java.util.List; diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/AbsListActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/AbsListActivity.java similarity index 96% rename from positions/src/main/java/cc/winboll/studio/positions/demo/AbsListActivity.java rename to positions/src/main/java/com/tencent/map/vector/demo/AbsListActivity.java index 2d8dd0a..22327e3 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/AbsListActivity.java +++ b/positions/src/main/java/com/tencent/map/vector/demo/AbsListActivity.java @@ -1,11 +1,10 @@ -package cc.winboll.studio.positions.demo; +package com.tencent.map.vector.demo; -import cc.winboll.studio.positions.R; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; - +import cc.winboll.studio.positions.R; import com.tencent.map.geolocation.TencentLocationManager; import com.tencent.tencentmap.mapsdk.maps.TencentMapInitializer; diff --git a/positions/src/main/java/com/tencent/map/vector/demo/AbsMapActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/AbsMapActivity.java new file mode 100644 index 0000000..f8c8231 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/AbsMapActivity.java @@ -0,0 +1,53 @@ +package com.tencent.map.vector.demo; + +import android.os.Bundle; +import androidx.annotation.Nullable; +import androidx.fragment.app.FragmentManager; +import android.view.Menu; +import android.view.MenuItem; +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.SupportMapFragment; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; + +public abstract class AbsMapActivity extends AbsActivity { + + private TencentMap mTencentMap; + + protected int getLayoutId() { + return R.layout.activity_map_container; + } + + @Override + protected final void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(getLayoutId()); + + FragmentManager manager = getSupportFragmentManager(); + SupportMapFragment fragment = (SupportMapFragment) manager.findFragmentById(R.id.fragment_map); + if (fragment != null) { + mTencentMap = fragment.getMap(); + } + + onCreate(savedInstanceState, mTencentMap); + } + + protected boolean checkMapInvalid() { + return mTencentMap == null || mTencentMap.isDestroyed(); + } + + protected void onCreate(@Nullable Bundle savedInstanceState, TencentMap tencentMap) { + + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + supportInvalidateOptionsMenu(); + return super.onPrepareOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + supportInvalidateOptionsMenu(); + return super.onOptionsItemSelected(item); + } +} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/MainActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/DemoMainActivity.java similarity index 96% rename from positions/src/main/java/cc/winboll/studio/positions/demo/MainActivity.java rename to positions/src/main/java/com/tencent/map/vector/demo/DemoMainActivity.java index fe14997..3497d79 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/MainActivity.java +++ b/positions/src/main/java/com/tencent/map/vector/demo/DemoMainActivity.java @@ -1,6 +1,5 @@ -package cc.winboll.studio.positions.demo; +package com.tencent.map.vector.demo; -import cc.winboll.studio.positions.R; import android.Manifest; import android.content.Context; import android.content.Intent; @@ -28,8 +27,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import cc.winboll.studio.positions.R; -public class MainActivity extends AbsListActivity { +public class DemoMainActivity extends AbsListActivity { private static final String DEMO_TYPE = "DEMO_TYPE"; @@ -53,7 +53,7 @@ public class MainActivity extends AbsListActivity { @Override protected int getLayoutId() { - return R.layout.activity_main_demo; + return R.layout.activity_demomain; } private void setupViews(String type) { @@ -95,7 +95,7 @@ public class MainActivity extends AbsListActivity { items = new ArrayList<>(); mDemoMap.put(demoType, items); mDemoTypes.add(new DemoInfo( - MainActivity.class.getName(), + DemoMainActivity.class.getName(), demoType, "")); } @@ -192,7 +192,7 @@ public class MainActivity extends AbsListActivity { @NonNull @Override public DemoInfoHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - return new DemoInfoHolder(MainActivity.this, parent, viewType); + return new DemoInfoHolder(DemoMainActivity.this, parent, viewType); } @Override diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/IndoorFloorView.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/IndoorFloorView.java similarity index 99% rename from positions/src/main/java/cc/winboll/studio/positions/demo/basic/IndoorFloorView.java rename to positions/src/main/java/com/tencent/map/vector/demo/basic/IndoorFloorView.java index 447dc78..cc8d899 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/IndoorFloorView.java +++ b/positions/src/main/java/com/tencent/map/vector/demo/basic/IndoorFloorView.java @@ -1,4 +1,4 @@ -package cc.winboll.studio.positions.demo.basic; +package com.tencent.map.vector.demo.basic; import android.app.Activity; import android.content.Context; diff --git a/positions/src/main/java/com/tencent/map/vector/demo/basic/IndoorMapActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/IndoorMapActivity.java new file mode 100644 index 0000000..df4a37c --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/basic/IndoorMapActivity.java @@ -0,0 +1,198 @@ +package com.tencent.map.vector.demo.basic; + +import android.os.Bundle; +import android.os.Handler; +import android.text.TextUtils; +import android.util.Log; + +import androidx.appcompat.app.AppCompatActivity; + +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.MapView; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.UiSettings; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.IndoorBuilding; +import com.tencent.tencentmap.mapsdk.maps.model.IndoorInfo; +import com.tencent.tencentmap.mapsdk.maps.model.IndoorLevel; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.MapPoi; +import com.tencent.tencentmap.mapsdk.maps.model.Marker; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; +import com.tencent.tencentmap.mapsdk.vector.utils.clustering.ClusterItem; +import com.tencent.tencentmap.mapsdk.vector.utils.clustering.ClusterManager; +import com.tencent.tencentmap.mapsdk.vector.utils.clustering.algo.NonHierarchicalDistanceBasedAlgorithm; +import com.tencent.tencentmap.mapsdk.vector.utils.clustering.view.DefaultClusterRenderer; + +import java.util.ArrayList; +import java.util.List; + +public class IndoorMapActivity extends AppCompatActivity implements TencentMap.OnIndoorStateChangeListener { + + private static final String TAG = "IndoorMapActivity"; + private MapView mapView; + private TencentMap tencentMap; + private IndoorFloorView indoorFloorView; + private UiSettings uiSettings; + private Handler handler = new Handler(); + private String floorName; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_indoor); + mapView = findViewById(R.id.mapView); + indoorFloorView = findViewById(R.id.indoor_floor); + if (tencentMap == null) { + tencentMap = mapView.getMap(); + } + //欧美汇室内地图,需Key开通室内地图权限 + CameraUpdate camera = + CameraUpdateFactory.newCameraPosition(new CameraPosition( + new LatLng(39.979382, 116.314106), + 18, + 0f, + 0f)); + tencentMap.moveCamera(camera); + final ArrayList markerClusters = new ArrayList<>(); + + uiSettings = tencentMap.getUiSettings(); + tencentMap.setIndoorEnabled(true); + //设置室内蒙层颜色 sdk版本4.3.5新增接口 + tencentMap.setIndoorMaskColor(R.color.color_C71585); + //设置室内图状态变化监听 + tencentMap.setOnIndoorStateChangeListener(this); + tencentMap.setMapType(TencentMap.MAP_TYPE_DARK); + //设置是否隐藏楼层控件 + uiSettings.setIndoorLevelPickerEnabled(false); + indoorFloorView.setOnIndoorFloorListener(new MyIndoorViewAdapter()); + ClusterManager markerClusterClusterManager = new ClusterManager(this, tencentMap); + NonHierarchicalDistanceBasedAlgorithm nba = new NonHierarchicalDistanceBasedAlgorithm<>(this); + nba.setMaxDistanceAtZoom(15); + markerClusterClusterManager.setAlgorithm(nba); + DefaultClusterRenderer renderer = new DefaultClusterRenderer<>(this, tencentMap, markerClusterClusterManager); + renderer.setMinClusterSize(2); + renderer.setBuckets(new int[]{5, 10, 20}); + markerClusterClusterManager.setRenderer(renderer); + //添加室内图marker + tencentMap.setOnMapPoiClickListener(new TencentMap.OnMapPoiClickListener() { + @Override + public void onClicked(MapPoi mapPoi) { + LatLng position = mapPoi.getPosition(); + MarkerOptions markerOptions = new MarkerOptions().position(position).title(mapPoi.name).infoWindowEnable(true); + if (!TextUtils.isEmpty("F3")) { + markerOptions.indoorInfo(new IndoorInfo("11000023805", "F3")); + + } + Marker marker = tencentMap.addMarker(markerOptions); + LatLng position1 = mapPoi.getPosition(); + markerClusters.add(new MarkerCluster(position1.getLatitude(), position1.getLongitude())); + + } + }); + tencentMap.setOnCameraChangeListener(markerClusterClusterManager); + + } + + @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 onDestroy() { + super.onDestroy(); + mapView.onDestroy(); + } + + @Override + public boolean onIndoorBuildingFocused() { + Log.d(TAG, "onIndoorBuildingFocused: 室内图场景激活回调"); + return false; + } + + @Override + public boolean onIndoorLevelActivated(final IndoorBuilding indoorBuilding) { + if (indoorBuilding != null) { + handler.post(new Runnable() { + @Override + public void run() { + indoorFloorView.setVisible(true); + if (mIndoorBuilding == null || !mIndoorBuilding.getBuidlingId().equals(indoorBuilding.getBuidlingId())) { + List levels = indoorBuilding.getLevels(); + String[] activedIndoorFloorNames1 = tencentMap.getActivedIndoorFloorNames(); + indoorFloorView.setItems(activedIndoorFloorNames1); + for (int i = 0; i < levels.size(); i++) { + floorName = levels.get(i).getName(); + indoorFloorView.setSeletion(floorName); + } + } + mIndoorBuilding = indoorBuilding; + } + }); + } else { + indoorFloorView.setVisible(false); + } + return false; + } + + @Override + public boolean onIndoorBuildingDeactivated() { + Log.d(TAG, "onIndoorBuildingDeactivated: 当前室内图处于无效状态"); + return false; + } + + IndoorBuilding mIndoorBuilding = null; + + private class MyIndoorViewAdapter implements IndoorFloorView.OnIndoorFloorListener { + + @Override + public void onSelected(int selectedIndex) { + if (mIndoorBuilding != null) { + + List levels = mIndoorBuilding.getLevels(); + String activedIndoorFloorName = tencentMap.getActivedIndoorFloorNames()[selectedIndex]; + String name = levels.get(selectedIndex).getName(); + name = activedIndoorFloorName; + String buidlingId = mIndoorBuilding.getBuidlingId(); + tencentMap.setIndoorFloor(buidlingId, name); + } + } + } +} + +class MarkerCluster implements ClusterItem { + + private final LatLng latLng; + + public MarkerCluster(double lat, double longitude) { + latLng = new LatLng(lat, longitude); + } + + @Override + public LatLng getPosition() { + + return latLng; + } +} \ No newline at end of file diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/MapRenderLayerActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/MapRenderLayerActivity.java similarity index 95% rename from positions/src/main/java/cc/winboll/studio/positions/demo/basic/MapRenderLayerActivity.java rename to positions/src/main/java/com/tencent/map/vector/demo/basic/MapRenderLayerActivity.java index 4246c25..de4b063 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/MapRenderLayerActivity.java +++ b/positions/src/main/java/com/tencent/map/vector/demo/basic/MapRenderLayerActivity.java @@ -1,4 +1,4 @@ -package cc.winboll.studio.positions.demo.basic; +package com.tencent.map.vector.demo.basic; import androidx.appcompat.app.AppCompatActivity; diff --git a/positions/src/main/java/com/tencent/map/vector/demo/basic/MapStyleDemoActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/MapStyleDemoActivity.java new file mode 100644 index 0000000..d8a94e0 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/basic/MapStyleDemoActivity.java @@ -0,0 +1,195 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.tencent.map.vector.demo.basic; + +import android.annotation.SuppressLint; +import android.graphics.PorterDuff; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.CompoundButton; +import android.widget.RadioGroup; +import android.widget.Spinner; +import android.widget.Switch; +import android.widget.TextView; + + +import androidx.fragment.app.FragmentActivity; + +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.MapView; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; + +/** + * Demonstrates the different base layers of a map. + */ +@SuppressLint("NewApi") +public class MapStyleDemoActivity extends FragmentActivity implements TencentMap.OnCameraChangeListener { + private MapView mMapView; + private TextView mTextView; + private TencentMap mTencentMap; + private Switch mSwitch; + private Spinner mSpinner; + + private String[] styles = new String[]{"style1", "style2", "style3", "style4", "style5", + "normal", "traffic_navi", "traffic_navi_night", "satellite", "night", "navi", "night", "eagle_day", "eagle_night"}; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_map_style); + mMapView = findViewById(R.id.map_view); + mTextView = findViewById(R.id.tv_level); + mSwitch=findViewById(R.id.switch_open); + mTencentMap = mMapView.getMap(); + CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(39.901268, 116.403854), 11f, 0f, 0f)); + mTencentMap.moveCamera(cameraUpdate); + //mTencentMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(39.901268, 116.403854))); //移动地图 + mTencentMap.setOnCameraChangeListener(this); + mSpinner = findViewById(R.id.sp_style); + ArrayAdapter adapter = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_spinner_dropdown_item, styles); + mSpinner.setAdapter(adapter); + mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + if (position < 5) { + mTencentMap.setMapStyle(position + 1); + } + switch (position) { + case 5: + mTencentMap.setMapStyle(TencentMap.MAP_TYPE_NORMAL); + break; + case 6: + mTencentMap.setMapStyle(TencentMap.MAP_TYPE_TRAFFIC_NAVI); + break; + case 7: + mTencentMap.setMapStyle(TencentMap.MAP_TYPE_TRAFFIC_NIGHT); + break; + case 8: + mTencentMap.setMapStyle(TencentMap.MAP_TYPE_SATELLITE); + break; + case 9: + mTencentMap.setMapStyle(TencentMap.MAP_TYPE_NIGHT); + break; + case 10: + mTencentMap.setMapStyle(TencentMap.MAP_TYPE_NAVI); + break; + case 11: + mTencentMap.setMapStyle(13 + 1000); + break; + case 12: + mTencentMap.setMapStyle(14 + 1000); + break; + case 13: + mTencentMap.setMapStyle(15 + 1000); + break; + } + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + + RadioGroup rg = findViewById(R.id.rg_map_type); + rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(RadioGroup group, int checkedId) { + switch (checkedId) { + case R.id.rb_normal_type: + if (mTencentMap != null) { + mTencentMap.setMapType(TencentMap.MAP_TYPE_NORMAL); + } + break; + case R.id.rb_dark_type: + if (mTencentMap != null) { + mTencentMap.setMapType(TencentMap.MAP_TYPE_DARK); + } + break; + case R.id.rb_sagellite_type: + if (mTencentMap != null) { + mTencentMap.setMapType(TencentMap.MAP_TYPE_SATELLITE); + } + break; + } + } + }); + mTencentMap.getUiSettings().setCompassEnabled(true); + mTencentMap.getUiSettings().setMyLocationButtonEnabled(true); + mSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + PorterDuff.Mode buttonTintMode = compoundButton.getButtonTintMode(); + if(b){ + mTencentMap.setBuildingEnable(true); + }else{ + mTencentMap.setBuildingEnable(false); + } + } + }); + } + + @Override + protected void onResume() { + super.onResume(); + mMapView.onResume(); + } + + @Override + protected void onPause() { + super.onPause(); + mMapView.onPause(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mMapView.onDestroy(); + } + + + @Override + protected void onStart() { + super.onStart(); + mMapView.onStart(); + } + + @Override + protected void onStop() { + super.onStop(); + mMapView.onStop(); + } + + @Override + public void onCameraChange(CameraPosition cameraPosition) { + Log.i("TAG","地图滑动了"); + mTextView.setText("当前缩放级别为:" + cameraPosition.zoom); + } + + @Override + public void onCameraChangeFinished(CameraPosition cameraPosition) { + Log.i("TAG","地图滑动了"); + mTextView.setText("当前缩放级别为:" + cameraPosition.zoom); + } +} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/MapViewActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/MapViewActivity.java similarity index 93% rename from positions/src/main/java/cc/winboll/studio/positions/demo/basic/MapViewActivity.java rename to positions/src/main/java/com/tencent/map/vector/demo/basic/MapViewActivity.java index f1762de..b7ef6d0 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/MapViewActivity.java +++ b/positions/src/main/java/com/tencent/map/vector/demo/basic/MapViewActivity.java @@ -1,4 +1,4 @@ -package cc.winboll.studio.positions.demo.basic; +package com.tencent.map.vector.demo.basic; import androidx.appcompat.app.AppCompatActivity; @@ -8,7 +8,7 @@ import android.util.Log; import android.view.View; import cc.winboll.studio.positions.R; -import cc.winboll.studio.positions.demo.heatoverlay.ScatterPlotOverlayActivity; +import com.tencent.map.vector.demo.heatoverlay.ScatterPlotOverlayActivity; import com.tencent.tencentmap.mapsdk.maps.MapView; import com.tencent.tencentmap.mapsdk.maps.TencentMap; import com.tencent.tencentmap.mapsdk.maps.TencentMapOptions; diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/OfflineMapActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/OfflineMapActivity.java similarity index 99% rename from positions/src/main/java/cc/winboll/studio/positions/demo/basic/OfflineMapActivity.java rename to positions/src/main/java/com/tencent/map/vector/demo/basic/OfflineMapActivity.java index 153b96d..d7180eb 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/OfflineMapActivity.java +++ b/positions/src/main/java/com/tencent/map/vector/demo/basic/OfflineMapActivity.java @@ -1,4 +1,4 @@ -//package cc.winboll.studio.positions.demo.basic; +//package com.tencent.map.vector.demo.basic; // //import androidx.annotation.NonNull; //import androidx.annotation.Nullable; diff --git a/positions/src/main/java/com/tencent/map/vector/demo/basic/OverseaMapActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/OverseaMapActivity.java new file mode 100644 index 0000000..da85478 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/basic/OverseaMapActivity.java @@ -0,0 +1,91 @@ +package com.tencent.map.vector.demo.basic; + +import android.content.res.AssetManager; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.os.Bundle; + +import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.TencentMapContext; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.Language; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.OverSeaTileProvider; + +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Locale; + +public class OverseaMapActivity extends SupportMapFragmentActivity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + //纽约时代广场海外地图,需Key开通海外位置服务权限 + CameraUpdate cameraSigma = + CameraUpdateFactory.newCameraPosition(new CameraPosition( + new LatLng(40.75797, -73.985542), + 11, + 0f, + 0f)); + //移动地图 + tencentMap.moveCamera(cameraSigma); + //设置自定义海外图源 + tencentMap.setOverSeaTileProvider(new CustomOverSeaTileProvider(tencentMap.getMapContext())); + } + + class CustomOverSeaTileProvider extends OverSeaTileProvider { + boolean mIsZhLanguage; + boolean mIsNight; + + /** + * 创建海外图源供应 + */ + public CustomOverSeaTileProvider(TencentMapContext context){ + //设置名称和版本号 + super("custom", 1, context); + } + + @Override + public URL getTileUrl(int x, int y, int zoom) { + String url = "https://xxxx.com/x=%d&y=%d&z=%d&s=%s&l=&s"; + String formatUrl = String.format(Locale.ENGLISH, url, x, y, zoom, mIsNight ? "dark" : "day", mIsZhLanguage ? "zh" : "en"); + try { + return new URL(formatUrl); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + return null; + } + + @Override + public boolean onDayNightChange(boolean dayNight) { + mIsNight = dayNight; + return true; + } + + public boolean onLanguageChange(Language language) { + mIsZhLanguage = (language == Language.zh); + return true; + } + + @Override + public Bitmap getLogo(boolean isNight) { + AssetManager assetManager = getAssets(); + Bitmap iBitmap = null; + InputStream is = null; + try { + is = assetManager.open("logo.png"); + iBitmap = BitmapFactory.decodeStream(is); + } catch (Exception e) { + return null; + } catch (OutOfMemoryError ignored) { + } finally { + // IO.safeClose(is); + } + return iBitmap; + } + } +} + diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/RecyclerListActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/RecyclerListActivity.java similarity index 95% rename from positions/src/main/java/cc/winboll/studio/positions/demo/basic/RecyclerListActivity.java rename to positions/src/main/java/com/tencent/map/vector/demo/basic/RecyclerListActivity.java index 1710e35..100b835 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/basic/RecyclerListActivity.java +++ b/positions/src/main/java/com/tencent/map/vector/demo/basic/RecyclerListActivity.java @@ -1,4 +1,4 @@ -package cc.winboll.studio.positions.demo.basic; +package com.tencent.map.vector.demo.basic; import androidx.annotation.NonNull; import androidx.fragment.app.FragmentActivity; diff --git a/positions/src/main/java/com/tencent/map/vector/demo/basic/SetMapTypeActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/SetMapTypeActivity.java new file mode 100644 index 0000000..464facb --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/basic/SetMapTypeActivity.java @@ -0,0 +1,51 @@ +package com.tencent.map.vector.demo.basic; + +import android.os.Bundle; +import android.view.View; +import android.widget.RadioGroup; + +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; + + +public class SetMapTypeActivity extends SupportMapFragmentActivity implements RadioGroup.OnCheckedChangeListener { + private RadioGroup radioGroup; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + initView(); + } + + private void initView() { + radioGroup = findViewById(R.id.lay_map_type); + radioGroup.setVisibility(View.VISIBLE); + radioGroup.setOnCheckedChangeListener(this); + } + + @Override + public void onCheckedChanged(RadioGroup radioGroup, int i) { + switch (i) { + case R.id.btn_normal: //普通地图-默认地图类型 + tencentMap.setMapType(TencentMap.MAP_TYPE_NORMAL); + break; + case R.id.btn_satellite: //卫星地图 + tencentMap.setMapType(TencentMap.MAP_TYPE_SATELLITE); + break; + case R.id.btn_dark: //暗色地图 + tencentMap.setMapType(TencentMap.MAP_TYPE_DARK); + break; + case R.id.btn_traffic: + tencentMap.setTrafficEnabled(true); + break; + case R.id.style_map: + /*TencentMapOptions mapOptions = new TencentMapOptions(); + //将本地资源打包到apk的asset目录中 + mapOptions.setCustomAssetsPath("myMapStyle"); + //参数1对应的是“我的样式”中的序号 + tencentMap.setMapStyle(1); + MapView mMapView = new MapView(SetMapTypeActivity.this, mapOptions);*/ + break; + } + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/basic/SupportMapFragmentActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/SupportMapFragmentActivity.java new file mode 100644 index 0000000..472e707 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/basic/SupportMapFragmentActivity.java @@ -0,0 +1,50 @@ +package com.tencent.map.vector.demo.basic; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; + +import androidx.fragment.app.FragmentManager; + +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.SupportMapFragment; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.UiSettings; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; + +public class SupportMapFragmentActivity extends AppCompatActivity { + + /** + * SDK提供了SupportMapFragment这个类来加载地图,这个类的方便之处就在于不用手动管理内存 + */ + + private FragmentManager fm; + protected TencentMap tencentMap; + private SupportMapFragment supportMapFragment; + protected UiSettings mapUiSettings; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_support_map_fragment); + + //创建tencentMap地图对象,可以完成对地图的几乎所有操作 + fm = getSupportFragmentManager(); + supportMapFragment = (SupportMapFragment) fm.findFragmentById(R.id.map_frag); + tencentMap = supportMapFragment.getMap(); + mapUiSettings = tencentMap.getUiSettings(); + //对地图操作类进行操作 + CameraUpdate cameraSigma = + CameraUpdateFactory.newCameraPosition(new CameraPosition( + new LatLng(39.984066, 116.307548), + 15, + 0f, + 0f)); + //移动地图 + tencentMap.moveCamera(cameraSigma); + + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/basic/UiSettingsActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/UiSettingsActivity.java new file mode 100644 index 0000000..890682e --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/basic/UiSettingsActivity.java @@ -0,0 +1,86 @@ +package com.tencent.map.vector.demo.basic; + +import android.os.Bundle; +import android.view.View; +import android.widget.CompoundButton; +import android.widget.Switch; + +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.TencentMapOptions; + +public class UiSettingsActivity extends SupportMapFragmentActivity { + + + private Switch logoControl; + private Switch compassControl; + private Switch scaleViewControl; + + @Override + protected void onCreate(Bundle savedInstanceState) { + + super.onCreate(savedInstanceState); + initView(); + } + private void initView(){ + + logoControl = findViewById(R.id.switch_logo); + compassControl = findViewById(R.id.switch_compass); + scaleViewControl = findViewById(R.id.switch_scale_view); + logoControl.setVisibility(View.VISIBLE); + logoControl.setText("logo位置"); + compassControl.setVisibility(View.VISIBLE); + compassControl.setText("指南针"); + scaleViewControl.setVisibility(View.VISIBLE); + scaleViewControl.setText("比例尺"); + + //打开缩放 + mapUiSettings.setZoomControlsEnabled(true); + //打开位置标志 + mapUiSettings.setMyLocationButtonEnabled(true); + + + logoControl.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + if (b){ + //logo左下角 + mapUiSettings.setLogoPosition(TencentMapOptions.LOGO_POSITION_BOTTOM_LEFT); + }else{ + //logo右上角 + mapUiSettings.setLogoPosition(TencentMapOptions.LOGO_POSITION_TOP_RIGHT); + } + + } + }); + + compassControl.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + if (b){ + //显示指南针 + mapUiSettings.setCompassEnabled(true); + }else{ + //隐藏指南针 + mapUiSettings.setCompassEnabled(false); + } + } + }); + + scaleViewControl.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + if (b){ + //打开比例尺 + mapUiSettings.setScaleViewEnabled(true); + }else{ + //关闭比例尺 + mapUiSettings.setScaleViewEnabled(false); + } + } + }); + + + + + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/camera/MapAnchorZoomActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/camera/MapAnchorZoomActivity.java new file mode 100644 index 0000000..3c2a501 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/camera/MapAnchorZoomActivity.java @@ -0,0 +1,54 @@ +package com.tencent.map.vector.demo.camera; + +import android.os.Bundle; + +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.Projection; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds; +import com.tencent.tencentmap.mapsdk.maps.model.Marker; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; +import com.tencent.tencentmap.mapsdk.maps.model.RestrictBoundsFitMode; +import com.tencent.tencentmap.mapsdk.maps.model.VisibleRegion; + +public class MapAnchorZoomActivity extends SupportMapFragmentActivity { + private Marker marker; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + LatLng latLng = new LatLng(39.984108,116.307557); + + CameraUpdate cameraSigma = + CameraUpdateFactory.newCameraPosition(new CameraPosition( + latLng, + 15, + 0f, + 0f)); + //移动地图 + tencentMap.moveCamera(cameraSigma); + Projection projection = tencentMap.getProjection(); + + VisibleRegion region = projection.getVisibleRegion(); + + tencentMap.setRestrictBounds(new LatLngBounds(region.farRight, region.nearLeft), RestrictBoundsFitMode.FIT_HEIGHT); + tencentMap.setRestrictBounds(new LatLngBounds(region.farRight, region.nearLeft), RestrictBoundsFitMode.FIT_WIDTH); + setMarker(latLng); + } + /** + * 设置标注 + */ + private void setMarker(LatLng latLng){ + + MarkerOptions options = new MarkerOptions().position(latLng); + + //设置infowindow + options.title("锚点"); + marker = tencentMap.addMarker(options); + marker.setInfoWindowEnable(true); + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/camera/MapBoundActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/camera/MapBoundActivity.java new file mode 100644 index 0000000..9d7a878 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/camera/MapBoundActivity.java @@ -0,0 +1,54 @@ +package com.tencent.map.vector.demo.camera; + +import android.os.Bundle; +import android.view.View; +import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.RadioGroup; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds; +import com.tencent.tencentmap.mapsdk.maps.model.RestrictBoundsFitMode; + +public class MapBoundActivity extends SupportMapFragmentActivity { + private RadioGroup radioGroup; + private CheckBox fitHeight; + private CheckBox fitWidth; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + final LatLng northeastLatLng = new LatLng(39.984066, 116.307548); + final LatLng southwestLatLng = new LatLng(39.974066, 116.297548); + radioGroup = findViewById(R.id.lay_map_bound); + radioGroup.setVisibility(View.VISIBLE); + fitWidth = findViewById(R.id.btn_fit_width); + fitWidth.setText("适应宽度"); + fitHeight = findViewById(R.id.btn_fit_height); + fitHeight.setText("适应高度"); + fitHeight.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + if (b){ + tencentMap.setRestrictBounds(new LatLngBounds(northeastLatLng, southwestLatLng), RestrictBoundsFitMode.FIT_HEIGHT); + }else{ + + } + } + }); + + fitWidth.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + if (b){ + tencentMap.setRestrictBounds(new LatLngBounds(northeastLatLng, southwestLatLng), RestrictBoundsFitMode.FIT_WIDTH); + }else{ + + } + } + }); + } + + +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/camera/MapCameraCenterActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/camera/MapCameraCenterActivity.java new file mode 100644 index 0000000..91d3cd5 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/camera/MapCameraCenterActivity.java @@ -0,0 +1,54 @@ +package com.tencent.map.vector.demo.camera; + +import android.os.Bundle; +import android.view.View; +import android.widget.TextView; +import android.widget.Toast; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; + +public class MapCameraCenterActivity extends SupportMapFragmentActivity implements TencentMap.OnCameraChangeListener, TencentMap.OnMapClickListener { + private TextView textView; + private String info; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + textView = findViewById(R.id.tv_info); + textView.setVisibility(View.VISIBLE); + tencentMap.setOnCameraChangeListener(this); + tencentMap.setOnMapClickListener(this); + } + + + /** + * 地图视图改变回调 + * @param cameraPosition + */ + @Override + public void onCameraChange(CameraPosition cameraPosition) { + //获取当前地图视图信息 + info = "经纬度:"+cameraPosition.target.latitude+","+cameraPosition.target.longitude+";zoom:"+cameraPosition.zoom; + textView.setText(info); + } + + @Override + public void onCameraChangeFinished(CameraPosition cameraPosition) { + //获取当前地图视图信息 + info = "经纬度:"+cameraPosition.target.latitude+","+cameraPosition.target.longitude+";zoom:"+cameraPosition.zoom; + Toast.makeText(MapCameraCenterActivity.this,info,Toast.LENGTH_SHORT).show(); + textView.setText(info); + + } + + @Override + public void onMapClick(LatLng latLng) { + tencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(latLng,15f, 0, 0))); + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/circle/ArcActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/circle/ArcActivity.java new file mode 100644 index 0000000..c503d58 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/circle/ArcActivity.java @@ -0,0 +1,126 @@ +package com.tencent.map.vector.demo.circle; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import android.graphics.Color; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; + +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.MapView; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.Arc; +import com.tencent.tencentmap.mapsdk.maps.model.ArcOptions; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.Marker; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerCollisionItem; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; + +public class ArcActivity extends AppCompatActivity { + + private MapView mapView; + private TencentMap tencentMap; + private boolean mMarkerAdded; + private Arc arc; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_arc); + init(); + } + + private void init() { + mapView = findViewById(R.id.mapView); + tencentMap = mapView.getMap(); + CameraUpdate cameraSigma = + CameraUpdateFactory.newCameraPosition(new CameraPosition( + new LatLng(32.059352, 118.796623), + 5, + 0f, + 0f)); + //移动地图 + tencentMap.moveCamera(cameraSigma); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.markercol, menu); + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + menu.findItem(R.id.menu_open_collisionsmap).setVisible(!mMarkerAdded); + menu.findItem(R.id.menu_close_collisionsmap).setVisible(mMarkerAdded); + return super.onPrepareOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(@NonNull MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_open_collisionsmap: + mMarkerAdded = true; + LatLng startLat = new LatLng(39.89491, 116.322056); + LatLng endtLat = new LatLng(22.547, 114.085947); + LatLng passLat = new LatLng(32.059352, 118.796623); + ArcOptions arcOptions = new ArcOptions(); + arcOptions.points(startLat, endtLat); + arcOptions.pass(passLat); + //设置起点到终点,与起点外切线逆时针旋转的夹角角度 + arcOptions.angle(30); + //设置线宽,默认5 + arcOptions.width(2); + //设置线颜色,默认黑色 + arcOptions.color(Color.BLUE); + arc = tencentMap.addArc(arcOptions); + break; + case R.id.menu_close_collisionsmap: + mMarkerAdded = false; + arc.remove(); + break; + } + + supportInvalidateOptionsMenu(); + return super.onOptionsItemSelected(item); + } + + @Override + protected void onResume() { + super.onResume(); + mapView.onResume(); + } + + @Override + protected void onPause() { + super.onPause(); + mapView.onPause(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mapView.onDestroy(); + } + + + @Override + protected void onStart() { + super.onStart(); + mapView.onStart(); + } + + @Override + protected void onStop() { + super.onStop(); + mapView.onStop(); + } +} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/circle/CircleOptionsActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/circle/CircleOptionsActivity.java new file mode 100644 index 0000000..d1ec760 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/circle/CircleOptionsActivity.java @@ -0,0 +1,35 @@ +package com.tencent.map.vector.demo.circle; + +import android.os.Bundle; + +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.model.Circle; +import com.tencent.tencentmap.mapsdk.maps.model.CircleOptions; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; + +public class CircleOptionsActivity extends SupportMapFragmentActivity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Circle circle = tencentMap.addCircle(circleOptions); + Circle newCircle = tencentMap.addCircle(newCircleOptions); + newCircle.setCenter(new LatLng(39.98408, 116.30701)); //重新设置圆心 + newCircle.setOptions(newCircleOptions); //重新设置圆形属性 + } + + /** + * 圆形选项 + */ + private CircleOptions circleOptions = new CircleOptions() //圆形选项 + .center(new LatLng(39.9849, 116.3977)) //圆心位置 + .clickable(true) //支持点击 + .fillColor((128 << 24) + (100 << 16) + (50 << 8) + 120) //设置填充颜色RGBA + .radius(110d) //设置半径 + .visible(true) //设置是否可见 + .zIndex(1) //设置堆叠顺序,越大优先级越高 + .strokeWidth(1) //描边宽度 + .strokeColor((128 << 24) + (128 << 16) + (128 << 8) + 128); //描边颜色 + + + private CircleOptions newCircleOptions = new CircleOptions().center(new LatLng(39.121, 116.454)).radius(90d).fillColor(0xff00ff00); +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/circle/DrawCircleActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/circle/DrawCircleActivity.java new file mode 100644 index 0000000..f9a1cf3 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/circle/DrawCircleActivity.java @@ -0,0 +1,24 @@ +package com.tencent.map.vector.demo.circle; + +import android.os.Bundle; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.model.Circle; +import com.tencent.tencentmap.mapsdk.maps.model.CircleOptions; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; + +public class DrawCircleActivity extends SupportMapFragmentActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + LatLng latLng = new LatLng(39.984059,116.307771); + Circle circle = tencentMap.addCircle(new CircleOptions(). + center(latLng). + radius(100d). + fillColor(getResources().getColor(R.color.style)). + strokeColor(getResources().getColor(R.color.colorPrimary)). + strokeWidth(1)); + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/gesture/GestureSettingsActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/gesture/GestureSettingsActivity.java new file mode 100644 index 0000000..80e0942 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/gesture/GestureSettingsActivity.java @@ -0,0 +1,80 @@ +package com.tencent.map.vector.demo.gesture; + +import android.os.Bundle; +import android.view.View; +import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.RadioGroup; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; + +public class GestureSettingsActivity extends SupportMapFragmentActivity { + + private CheckBox scrollBox; + private CheckBox zoomBox; + private CheckBox rotateBox; + private CheckBox tiltBox; + private RadioGroup radioGroup; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + radioGroup = findViewById(R.id.lay_checkbox); + radioGroup.setVisibility(View.VISIBLE); + initView(); + } + + private void initView(){ + scrollBox = findViewById(R.id.btn_scroll); + zoomBox = findViewById(R.id.btn_zoom); + rotateBox = findViewById(R.id.btn_rotate); + tiltBox = findViewById(R.id.btn_slope); + + + scrollBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + if (b){ + mapUiSettings.setScrollGesturesEnabled(true); + }else{ + mapUiSettings.setScrollGesturesEnabled(false); + } + } + }); + + + zoomBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + if (b){ + mapUiSettings.setZoomGesturesEnabled(true); + }else{ + mapUiSettings.setZoomGesturesEnabled(false); + } + } + }); + + rotateBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + if (b){ + mapUiSettings.setRotateGesturesEnabled(true); + }else{ + mapUiSettings.setRotateGesturesEnabled(false); + } + } + }); + + tiltBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + if (b){ + mapUiSettings.setTiltGesturesEnabled(true); + }else{ + mapUiSettings.setTiltGesturesEnabled(false); + } + } + }); + } + +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/gesture/MapGestureListenActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/gesture/MapGestureListenActivity.java new file mode 100644 index 0000000..046074c --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/gesture/MapGestureListenActivity.java @@ -0,0 +1,82 @@ +package com.tencent.map.vector.demo.gesture; + +import android.os.Bundle; +import android.view.View; +import android.widget.TextView; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.TencentMapGestureListener; + +public class MapGestureListenActivity extends SupportMapFragmentActivity implements TencentMapGestureListener { + + private TextView textView; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + textView = findViewById(R.id.tv_info); + textView.setVisibility(View.VISIBLE); + tencentMap.setTencentMapGestureListener(this); + } + + @Override + public boolean onDoubleTap(float v, float v1) { + textView.setText("单指双击"); + return true; + } + + @Override + public boolean onSingleTap(float v, float v1) { + textView.setText("单指单击"); + return true; + } + + @Override + public boolean onFling(float v, float v1) { + textView.setText("单指惯性滑动"); + return true; + } + + @Override + public boolean onScroll(float v, float v1) { + textView.setText("单指滑动"); + return true; + } + + @Override + public boolean onLongPress(float v, float v1) { + textView.setText("长按"); + return true; + } + + @Override + public boolean onDown(float v, float v1) { + textView.setText("单指按下"); + return true; + } + + @Override + public boolean onUp(float v, float v1) { + textView.setText("单指抬起"); + return true; + } + + @Override + public boolean onTwoFingerMoveAgainst(TwoFingerMoveAgainstStatus twoFingerMoveAgainstStatus, CameraPosition cameraPosition) { + textView.setText("双指捏合"); + return false; + } + + @Override + public void onMapStable() { + textView.setText("地图稳定"); + return; + } + + @Override + public void onMapStableBy(CameraPosition.Trigger trigger) { + textView.setText("地图稳定 by " + trigger.name()); + return; + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/gesture/MapListenActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/gesture/MapListenActivity.java new file mode 100644 index 0000000..8bb6f50 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/gesture/MapListenActivity.java @@ -0,0 +1,30 @@ +package com.tencent.map.vector.demo.gesture; + +import android.os.Bundle; +import android.view.View; +import android.widget.TextView; +import android.widget.Toast; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; + +public class MapListenActivity extends SupportMapFragmentActivity implements TencentMap.OnMapClickListener { + private TextView textView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + textView = findViewById(R.id.tv_info); + textView.setVisibility(View.VISIBLE); + tencentMap.setOnMapClickListener(this); + } + + @Override + public void onMapClick(LatLng latLng) { + String info = "经纬度:" + latLng.latitude + "," + latLng.longitude; + Toast.makeText(MapListenActivity.this, info, Toast.LENGTH_SHORT).show(); + textView.setText(info); + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/gesture/MapLongClickActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/gesture/MapLongClickActivity.java new file mode 100644 index 0000000..f1cc9c4 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/gesture/MapLongClickActivity.java @@ -0,0 +1,63 @@ +package com.tencent.map.vector.demo.gesture; + +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Matrix; +import android.os.Bundle; +import android.view.View; +import android.widget.TextView; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; + +public class MapLongClickActivity extends SupportMapFragmentActivity implements TencentMap.OnMapLongClickListener { + private TextView textView; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + textView = findViewById(R.id.tv_info); + textView.setVisibility(View.VISIBLE); + tencentMap.setOnMapLongClickListener(this); + } + + @Override + public void onMapLongClick(LatLng latLng) { + String info = "经纬度:"+latLng.latitude+","+latLng.longitude; + textView.setText(info); + setMarker(latLng); + } + + /** + * 长按添加标注 + */ + private void setMarker(LatLng latLng){ + + BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.marker)); + MarkerOptions options = new MarkerOptions().position(latLng).icon(bitmapDescriptor); + tencentMap.clear(); + tencentMap.addMarker(options); + + } + + + private Bitmap getBitMap(int resourceId){ + Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId); + int width = bitmap.getWidth(); + int height = bitmap.getHeight(); + int newWidth = 100; + int newHeight = 100; + float widthScale = ((float)newWidth)/width; + float heightScale = ((float)newHeight)/height; + Matrix matrix = new Matrix(); + matrix.postScale(widthScale, heightScale); + bitmap = Bitmap.createBitmap(bitmap,0,0,width,height,matrix,true); + return bitmap; + } + + +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/AggregationOverlayActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/AggregationOverlayActivity.java new file mode 100644 index 0000000..cab7cf7 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/AggregationOverlayActivity.java @@ -0,0 +1,197 @@ +package com.tencent.map.vector.demo.heatoverlay; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import android.graphics.Color; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.widget.CompoundButton; +import android.widget.Switch; + +import com.tencent.map.sdk.utilities.visualization.aggregation.AggregationOverlay; +import com.tencent.map.sdk.utilities.visualization.aggregation.AggregationOverlayProvider; +import com.tencent.map.sdk.utilities.visualization.aggregation.HoneyCombVectorOverlayProvider; +import com.tencent.map.sdk.utilities.visualization.datamodels.WeightedLatLng; +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.MapView; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; + +public class AggregationOverlayActivity extends AppCompatActivity { + private MapView mMapView; + private TencentMap mTencentMap; + private AggregationOverlay aggregationOverlay; + private AggregationOverlayProvider aggregationOverlayProvider; + private Switch btnSwitch3D; + + boolean mIsSelected; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_aggregation_overlay_design); + init(); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.vectorheatmap, menu); + return true; + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + menu.findItem(R.id.menu_open_vectorheatmap).setVisible(!mIsSelected); + menu.findItem(R.id.menu_close_vectorheatmap).setVisible(mIsSelected); + return super.onPrepareOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(@NonNull MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_open_vectorheatmap: + addAggregation(); + break; + case R.id.menu_close_vectorheatmap: + mIsSelected = false; + if (aggregationOverlay != null) { + aggregationOverlay.remove(); + aggregationOverlay = null; + } + break; + } + + supportInvalidateOptionsMenu(); + return super.onOptionsItemSelected(item); + } + + @Override + protected void onResume() { + super.onResume(); + mMapView.onResume(); + } + + @Override + protected void onPause() { + super.onPause(); + mMapView.onPause(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mMapView.onDestroy(); + } + + + @Override + protected void onStart() { + super.onStart(); + mMapView.onStart(); + } + + @Override + protected void onStop() { + super.onStop(); + mMapView.onStop(); + } + + private void init() { + mMapView = findViewById(R.id.mapView); + mTencentMap = mMapView.getMap(); + mTencentMap.setMapStyle(3); + mTencentMap.moveCamera(CameraUpdateFactory.zoomTo(10f)); + btnSwitch3D = (Switch) findViewById(R.id.btn_switch_3D); + bindListener(); + } + + + private void bindListener() { + + CompoundButton.OnCheckedChangeListener onCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() { + + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + switch (compoundButton.getId()) { + case R.id.btn_switch_3D: + if (aggregationOverlay != null) { + if (compoundButton.isChecked()) { + aggregationOverlayProvider.enable3D(true); + aggregationOverlayProvider.enable3D(true).setAnimateDuration(3000); + } else { + aggregationOverlayProvider.enable3D(false); + } + mTencentMap.updateVectorOverlay(aggregationOverlay, aggregationOverlayProvider); + } + break; + default: + break; + } + } + }; + + + btnSwitch3D.setOnCheckedChangeListener(onCheckedChangeListener); + + } + + protected void addAggregation() { + mIsSelected = true; + if (aggregationOverlay != null) { + return; + } + // mTencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(39.961629, 116.355343), 12, 0, 0))); + mTencentMap.setBuildingEnable(false); + mTencentMap.setPoisEnabled(false); + BufferedReader br = null; + try { + ArrayList nodes = new ArrayList(); + br = new BufferedReader(new InputStreamReader(getResources().getAssets().open("data2k"))); + String line = null; + while ((line = br.readLine()) != null) { + String[] lines = line.split("\t"); + if (lines.length == 3) { + double value = Double.parseDouble(lines[2]); + LatLng latLng = new LatLng((Double.parseDouble(lines[1])), (Double.parseDouble(lines[0]))); + nodes.add(new WeightedLatLng(latLng, value)); + } + } + + int[] colors = { + Color.argb(255, 0x01, 0x2C, 0x4B), + Color.argb(255, 0x17, 0x3E, 0x59), + Color.argb(255, 0x3A, 0x73, 0x78), + Color.argb(255, 0x98, 0xCD, 0x9A), + Color.argb(255, 0xF6, 0xFB, 0xB6) + }; + double[] startPoints = {0.f, 0.1f, 0.15f, 0.3f, 0.5f}; + + + aggregationOverlayProvider = new HoneyCombVectorOverlayProvider() + .nodes(nodes.toArray(new WeightedLatLng[0])) + .setHeightRange(0, 4000); + aggregationOverlayProvider.colors(colors, startPoints); + aggregationOverlay = mTencentMap.addVectorOverlay(aggregationOverlayProvider); + + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (br != null) { + try { + br.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } +} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/ArcLineLayerActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/ArcLineLayerActivity.java new file mode 100644 index 0000000..24d1bc8 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/ArcLineLayerActivity.java @@ -0,0 +1,182 @@ +package com.tencent.map.vector.demo.heatoverlay; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import android.graphics.Color; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.Button; +import android.widget.CompoundButton; +import android.widget.Switch; + +import com.tencent.map.sdk.utilities.visualization.datamodels.FromToLatLng; +import com.tencent.map.sdk.utilities.visualization.od.ArcLineOverlay; +import com.tencent.map.sdk.utilities.visualization.od.ArcLineOverlayProvider; +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.MapView; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.VectorOverlay; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; + +public class ArcLineLayerActivity extends AppCompatActivity { + private MapView mMapView; + private TencentMap mTencentMap; + private VectorOverlay vectorOverlay; + private ArcLineOverlayProvider options; + private Switch btnSwitch3D; + boolean mIsSelected; + private Switch btnani3D; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_arc_line_layer_design); + init(); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.vectorheatmap, menu); + return true; + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + menu.findItem(R.id.menu_open_vectorheatmap).setVisible(!mIsSelected); + menu.findItem(R.id.menu_close_vectorheatmap).setVisible(mIsSelected); + return super.onPrepareOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(@NonNull MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_open_vectorheatmap: + btnSwitch3D.setVisibility(View.VISIBLE); + addArcLineLayer(); + break; + case R.id.menu_close_vectorheatmap: + mIsSelected = false; + if (vectorOverlay != null) { + vectorOverlay.remove(); + vectorOverlay = null; + } + break; + } + + supportInvalidateOptionsMenu(); + return super.onOptionsItemSelected(item); + } + + @Override + protected void onResume() { + super.onResume(); + mMapView.onResume(); + } + + @Override + protected void onPause() { + super.onPause(); + mMapView.onPause(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mMapView.onDestroy(); + } + + + @Override + protected void onStart() { + super.onStart(); + mMapView.onStart(); + } + + @Override + protected void onStop() { + super.onStop(); + mMapView.onStop(); + } + + private void init() { + mMapView = findViewById(R.id.mapView); + mTencentMap = mMapView.getMap(); + mTencentMap.moveCamera(CameraUpdateFactory.zoomTo(5f)); + btnSwitch3D = (Switch) findViewById(R.id.btn_switch_3D); + bindListener(); + + } + + private void bindListener() { + CompoundButton.OnCheckedChangeListener onCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() { + + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + switch (compoundButton.getId()) { + case R.id.btn_switch_3D: + if (vectorOverlay != null) { + if (compoundButton.isChecked()) { + options.enable3D(true); + } else { + options.enable3D(false); + } + + mTencentMap.updateVectorOverlay(vectorOverlay, options); + } + break; + + default: + break; + } + } + }; + + btnSwitch3D.setOnCheckedChangeListener(onCheckedChangeListener); + } + + private void addArcLineLayer() { + mIsSelected = true; + if (vectorOverlay == null) { + // mTencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(39.9229731, 116.422880668), 8, 0f, 0f))); + mTencentMap.setMapStyle(3); + + int color = Color.argb(255, 0, 255, 170); + BufferedReader br = null; + final ArrayList nodes = new ArrayList(); + try { + br = new BufferedReader(new InputStreamReader(getResources().getAssets().open("arc.dat"))); + String line = null; + while ((line = br.readLine()) != null) { + String[] lines = line.split(" "); + if (lines.length == 5) { + double arc = Double.parseDouble(lines[4]); + LatLng startLatLng = new LatLng((Double.parseDouble(lines[0])), (Double.parseDouble(lines[1]))); + LatLng endLatLng = new LatLng((Double.parseDouble(lines[2])), (Double.parseDouble(lines[3]))); + nodes.add(new FromToLatLng(startLatLng, endLatLng)); + //nodes.add(new FromToLatLng(startLatLng, endLatLng, arc)); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + int[] colors = { + Color.argb(255, 0, 0xd4, 0xff), + Color.argb((int) (255 * 0.3), 0, 0xd4, 0xff), + Color.argb(255, 0, 0xd4, 0xff) + }; + options = new ArcLineOverlayProvider().data(nodes).opacity(2f).width(4).gradient(colors).setAnimateDuration(3000).setHighlightDuration(200).animateColor(Color.argb(255, 0xff, 0xff, 0xff)); + vectorOverlay = mTencentMap.addVectorOverlay(options); + mTencentMap.setPoisEnabled(false); + + } + } +} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/DrawHeatOverlayActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/DrawHeatOverlayActivity.java new file mode 100644 index 0000000..20e246e --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/DrawHeatOverlayActivity.java @@ -0,0 +1,126 @@ +package com.tencent.map.vector.demo.heatoverlay; + +import android.graphics.Color; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.map.sdk.utilities.heatmap.Gradient; +import com.tencent.map.sdk.utilities.heatmap.HeatMapTileProvider; +import com.tencent.map.sdk.utilities.heatmap.WeightedLatLng; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.TileOverlay; +import com.tencent.tencentmap.mapsdk.maps.model.TileOverlayOptions; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; + +public class DrawHeatOverlayActivity extends SupportMapFragmentActivity implements HeatMapTileProvider.OnHeatMapReadyListener{ + + private TileOverlay mHeatmapTileOverlay; + private HeatMapTileProvider mProvider; + //热力图半径 + private static final int ALT_HEATMAP_RADIUS = HeatMapTileProvider.DEFAULT_RADIUS; + //热力图透明度 + private static final double ALT_HEATMAP_OPACITY = HeatMapTileProvider.DEFAULT_OPACITY; + //热力图渐变方案 + public static final Gradient ALT_HEATMAP_GRADIENT = HeatMapTileProvider.DEFAULT_GRADIENT; + + private static final int[] CUSTOM_GRADIENT_COLORS = { + Color.argb(0,0, 225, 225), + Color.rgb(102, 125, 200), + Color.rgb(255, 0, 0) + }; + + private static final float[] CUSTOM_GRADIENT_START_POINTS = { + 0.0f, 0.2f, 1f + }; + + public static final Gradient CUSTOM_HEATMAP_GRADIENT = new Gradient(CUSTOM_GRADIENT_COLORS, + CUSTOM_GRADIENT_START_POINTS); + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setUpMap(); + Button first = findViewById(R.id.btn_bottom); + first.setVisibility(View.VISIBLE); + first.setText("自定义热力图"); + first.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + mProvider.setHeatTileGenerator(new HeatMapTileProvider.HeatTileGenerator() { + @Override + public double[] generateKernel(int radius) { + double[] kernel = new double[radius * 2 + 1]; + for (int i = -radius; i <= radius; i++) { + kernel[i + radius] = Math.exp(-i * i / (2 * (radius / 2f) * (radius / 2f))); + } + return kernel; + } + + @Override + public int[] generateColorMap(double opacity) { + return CUSTOM_HEATMAP_GRADIENT.generateColorMap(opacity); + } + }); + mHeatmapTileOverlay.clearTileCache(); + mHeatmapTileOverlay.reload(); + } + }); + + } + private void setUpMap() { + tencentMap.moveCamera(CameraUpdateFactory.newLatLngZoom( + new com.tencent.tencentmap.mapsdk.maps.model.LatLng(39.917128, 116.399266), + 7.946870f)); + initHeatMap(); + } + private void initHeatMap() { + BufferedReader br = null; + try { + ArrayList nodes = new ArrayList<>(); + br = new BufferedReader(new InputStreamReader( + getResources().getAssets().open("data2k"))); + String line; + while ((line = br.readLine()) != null) { + String[] lines = line.split("\t"); + if (lines.length == 3) { + double value = Double.parseDouble(lines[2]); + LatLng latLng = new LatLng((Double.parseDouble(lines[1])), + (Double.parseDouble(lines[0]))); + nodes.add(new WeightedLatLng(latLng, value)); + } + } + + mProvider = new HeatMapTileProvider.Builder() + .weightedData(nodes) + .gradient(ALT_HEATMAP_GRADIENT) + .opacity(ALT_HEATMAP_OPACITY) + .radius(ALT_HEATMAP_RADIUS) + .readyListener(this) + .build(tencentMap); + mHeatmapTileOverlay = tencentMap.addTileOverlay(new TileOverlayOptions().tileProvider(mProvider)); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (br != null) { + try { + br.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + @Override + public void onHeatMapReady() { + mHeatmapTileOverlay.clearTileCache(); + mHeatmapTileOverlay.reload(); + } +} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/DrawOldVersionHeatOverlayActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/DrawOldVersionHeatOverlayActivity.java similarity index 97% rename from positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/DrawOldVersionHeatOverlayActivity.java rename to positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/DrawOldVersionHeatOverlayActivity.java index fd40d64..d84558f 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/heatoverlay/DrawOldVersionHeatOverlayActivity.java +++ b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/DrawOldVersionHeatOverlayActivity.java @@ -1,6 +1,6 @@ -package cc.winboll.studio.positions.demo.heatoverlay; +package com.tencent.map.vector.demo.heatoverlay; -import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; public class DrawOldVersionHeatOverlayActivity extends SupportMapFragmentActivity { diff --git a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/GLModelActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/GLModelActivity.java new file mode 100644 index 0000000..466e5d5 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/GLModelActivity.java @@ -0,0 +1,166 @@ +package com.tencent.map.vector.demo.heatoverlay; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Spinner; + +import com.tencent.map.sdk.utilities.visualization.glmodel.GLModelOverlay; +import com.tencent.map.sdk.utilities.visualization.glmodel.GLModelOverlayProvider; +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.MapView; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.TencentMapOptions; +import com.tencent.tencentmap.mapsdk.maps.model.GeneralTranslateAnimator; +import com.tencent.tencentmap.mapsdk.maps.model.IAnimatorModel; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds; +import com.tencent.tencentmap.mapsdk.maps.model.Polyline; +import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; + +import java.io.File; +import java.util.Arrays; + +import static com.tencent.map.sdk.utilities.visualization.glmodel.GLModelOverlayProvider.CoordType.GeoGraphicType; +import static com.tencent.map.sdk.utilities.visualization.glmodel.GLModelOverlayProvider.CoordType.PixelType; + +public class GLModelActivity extends AppCompatActivity { + + /** + * 和其他覆盖物相同三维模型图也可控制图层的Level和zIndex + * 可通过 GLModelOverlayProvider的displayLevel和zIndex进行设置 + * displayLevel - 默认层级为POI之下 OverlayLevel.OverlayLevelAboveBuildings + * 相同Level内的显示层级关系通过zIndex(int)来控制,zIndex越大越靠上显示。 Level优先级高于zIndex displayLevel必须为如下值之一,否则不生效 + */ + + private MapView mapView; + protected TencentMap tencentMap; + private String mResourcePath; + private GLModelOverlay vectorOverlay; + private final String mLine = "39.98409,116.30804,39.98409,116.3081,39.98409,116.3081,39.98397,116.30809,39.9823,116.30809,39.9811,116.30817,39.9811,116.30817,39.97918,116.308266,39.97918,116.308266,39.9791,116.30827,39.9791,116.30827,39.979008,116.3083,39.978756,116.3084,39.978386,116.3086,39.977867,116.30884,39.977547,116.308914,39.976845,116.308914,39.975826,116.308945,39.975826,116.308945,39.975666,116.30901,39.975716,116.310486,39.975716,116.310486,39.975754,116.31129,39.975754,116.31129,39.975784,116.31241,39.975822,116.31327,39.97581,116.31352,39.97588,116.31591,39.97588,116.31591,39.97591,116.31735,39.97591,116.31735,39.97593,116.31815,39.975967,116.31879,39.975986,116.32034,39.976055,116.32211,39.976086,116.323395,39.976105,116.32514,39.976173,116.32631,39.976254,116.32811,39.976265,116.3288,39.976345,116.33123,39.976357,116.33198,39.976418,116.33346,39.976418,116.33346,39.97653,116.333755,39.97653,116.333755,39.978157,116.333664,39.978157,116.333664,39.978195,116.33509,39.978195,116.33509,39.978226,116.33625,39.978226,116.33625,39.97823,116.33656,39.97823,116.33656,39.978256,116.33791,39.978256,116.33791,39.978016,116.33789,39.977047,116.33791,39.977047,116.33791,39.97706,116.33768,39.97706,116.33768,39.976967,116.33706,39.976967,116.33697"; + private LatLng[] mCarLatLngArray; + private GeneralTranslateAnimator animator; + private Polyline polyline; + private Spinner mSpinner; + private String[] glmodelAnimator = new String[]{"开启平滑移动", "开启骨骼动画", "关闭骨骼动画"}; + private GLModelOverlayProvider provider; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_g_l_model); + mapView = findViewById(R.id.mapView); + tencentMap = this.mapView.getMap(); + String[] linePointsStr = mLine.split(","); + mCarLatLngArray = new LatLng[linePointsStr.length / 4]; + + for (int i = 0; i < mCarLatLngArray.length; i++) { + double latitude = Double.parseDouble(linePointsStr[i * 4]); + double longitude = Double.parseDouble(linePointsStr[i * 4 + 1]); + mCarLatLngArray[i] = new LatLng(latitude, longitude); + } + polyline = tencentMap.addPolyline(new PolylineOptions().add(mCarLatLngArray).color(R.color.colorAccent).arrow(true)); + tencentMap.animateCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder().include(Arrays.asList(mCarLatLngArray)).build(), 50)); + creatglmode(); + init(); + } + + private void creatglmode() { + //gltf格式三维模型文件在assets内 + String file = "BrainStem.gltf"; + String SKELETON_PATH = "gltf-BrainStem"; + //获取外部存储 + mResourcePath = getExternalFilesDir(null).getAbsolutePath() + File.separator + SKELETON_PATH; + provider = new GLModelOverlayProvider( + mResourcePath + File.separator + file, + new LatLng(39.98409, 116.30804)).coordType(PixelType) + .pixelBounds(400, 1200).rotationX(90).rotationY(0).rotationZ(0).setClickEnable(true); + vectorOverlay = tencentMap.addVectorOverlay(provider); + } + + private void init() { + mSpinner = findViewById(R.id.sp_glmode); + ArrayAdapter adapter = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_spinner_dropdown_item, glmodelAnimator); + mSpinner.setAdapter(adapter); + mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + switch (position) { + //开启骨骼动画 + case 0: + animator = new GeneralTranslateAnimator.Builder(vectorOverlay, 6000, + mCarLatLngArray).rotateEnabled(true).initRotate(180).modelType(GeneralTranslateAnimator.ModelType.MODEL_OVERLAY).build(); + animator.startAnimation(); + animator.addAnimatorEndListener(new IAnimatorModel.IAnimatorEndListener() { + @Override + public void onAnimatorEnd() { + Log.i("TransformActivity", "onAnimatorEnd"); + } + }); + break; + //停止骨骼动画 + case 1: + vectorOverlay.playSkeletonAnimation(0, 1, true); + break; + //模型平移 + case 2: + vectorOverlay.stopSkeletonAnimation(); + break; + } + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + + } + + /** + * mapview的生命周期管理 + */ + @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 onDestroy() { + super.onDestroy(); + mapView.onDestroy(); + vectorOverlay.remove(); + + } + + @Override + protected void onRestart() { + super.onRestart(); + mapView.onRestart(); + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/HeatMapVectorOverlayActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/HeatMapVectorOverlayActivity.java new file mode 100644 index 0000000..0036536 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/HeatMapVectorOverlayActivity.java @@ -0,0 +1,171 @@ +package com.tencent.map.vector.demo.heatoverlay; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import android.graphics.Color; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.Button; + +import com.tencent.map.sdk.utilities.visualization.datamodels.WeightedLatLng; +import com.tencent.map.sdk.utilities.visualization.heatmap.GradientVectorOverlay; +import com.tencent.map.sdk.utilities.visualization.heatmap.GradientVectorOverlayProvider; +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.MapView; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; + +public class HeatMapVectorOverlayActivity extends AppCompatActivity { + private MapView mMapView; + private TencentMap mTencentMap; + private GradientVectorOverlay heatTileOverlay; + private GradientVectorOverlayProvider heatMapTileProvider; + boolean mIsSelected; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_heat_map_vector_overlay_design); + init(); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.vectorheatmap, menu); + return true; + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + menu.findItem(R.id.menu_open_vectorheatmap).setVisible(!mIsSelected); + menu.findItem(R.id.menu_close_vectorheatmap).setVisible(mIsSelected); + return super.onPrepareOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(@NonNull MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_open_vectorheatmap: + addHeatMap(); + break; + case R.id.menu_close_vectorheatmap: + mIsSelected = false; + if (heatTileOverlay != null) { + heatTileOverlay.remove(); + heatTileOverlay = null; + } + break; + } + + supportInvalidateOptionsMenu(); + return super.onOptionsItemSelected(item); + } + + @Override + protected void onResume() { + super.onResume(); + mMapView.onResume(); + } + + @Override + protected void onPause() { + super.onPause(); + mMapView.onPause(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mMapView.onDestroy(); + } + + + @Override + protected void onStart() { + super.onStart(); + mMapView.onStart(); + } + + @Override + protected void onStop() { + super.onStop(); + mMapView.onStop(); + } + + private void init() { + mMapView = findViewById(R.id.mapView); + mTencentMap = mMapView.getMap(); + mTencentMap.setMapStyle(3); + CameraUpdate cameraSigma = + CameraUpdateFactory.newCameraPosition(new CameraPosition( + new LatLng(31.085414, 111.024319), + 4, + 20f, + 1f)); + mTencentMap.moveCamera(cameraSigma); + } + + + private void addHeatMap() { + mIsSelected = true; + if (heatTileOverlay != null) { + return; + } + mTencentMap.setBuildingEnable(false); + mTencentMap.setPoisEnabled(false); + BufferedReader br = null; + try { + ArrayList nodes = new ArrayList(); + br = new BufferedReader(new InputStreamReader(getResources().getAssets().open("data2k"))); + String line = null; + while ((line = br.readLine()) != null) { + String[] lines = line.split("\t"); + if (lines.length == 3) { + double value = Double.parseDouble(lines[2]); + LatLng latLng = new LatLng((Double.parseDouble(lines[1])), (Double.parseDouble(lines[0]))); + nodes.add(new WeightedLatLng(latLng, value)); + } + } + + // 通用配色1 + int[] colors = { + Color.argb(255, 77, 111, 255), + Color.argb(255, 0, 238, 227), + Color.argb(255, 113, 236, 80), + Color.argb(255, 255, 176, 0), + Color.argb(255, 255, 72, 0) + }; + float[] startPoints = {0.1f, 0.185f, 0.3571f, 0.6142f, 1f}; + + + heatMapTileProvider = new GradientVectorOverlayProvider() + .weightedData(nodes).enable3D(true) + .radius(56).setMaxHeight(500).setAnimateDuration(3000); + heatMapTileProvider.opacity(0.95f); + heatMapTileProvider.gradient(colors, startPoints); + heatTileOverlay = mTencentMap.addVectorOverlay(heatMapTileProvider); + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (br != null) { + try { + br.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } +} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/ScatterPlotOverlayActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/ScatterPlotOverlayActivity.java new file mode 100644 index 0000000..d56cc37 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/ScatterPlotOverlayActivity.java @@ -0,0 +1,180 @@ +package com.tencent.map.vector.demo.heatoverlay; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import android.graphics.Color; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.CompoundButton; +import android.widget.Spinner; +import android.widget.Switch; + +import com.tencent.map.sdk.utilities.visualization.datamodels.ScatterLatLng; +import com.tencent.map.sdk.utilities.visualization.scatterplot.BitmapScatterPlotOverlayProvider; +import com.tencent.map.sdk.utilities.visualization.scatterplot.DotScatterPlotOverlayProvider; +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.MapView; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; +import com.tencent.tencentmap.mapsdk.maps.model.VectorOverlay; + +import java.io.BufferedReader; +import java.util.ArrayList; +import java.util.Random; + +public class ScatterPlotOverlayActivity extends AppCompatActivity { + private MapView mMapView; + private TencentMap mTencentMap; + private VectorOverlay vectorOverlay; + boolean mIsSelected; + private DotScatterPlotOverlayProvider dotScatterPlotOverlayProvider; + private BitmapScatterPlotOverlayProvider provider; + private String[] styles = new String[]{"添加点散点", "添加图片散点"}; + private Spinner mSpinner; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_scatter_plot_overlay); + init(); + } + + + @Override + protected void onResume() { + super.onResume(); + mMapView.onResume(); + } + + @Override + protected void onPause() { + super.onPause(); + mMapView.onPause(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mMapView.onDestroy(); + } + + + @Override + protected void onStart() { + super.onStart(); + mMapView.onStart(); + } + + @Override + protected void onStop() { + super.onStop(); + mMapView.onStop(); + } + + private void init() { + mMapView = findViewById(R.id.mapView); + mTencentMap = mMapView.getMap(); + mTencentMap.moveCamera(CameraUpdateFactory.zoomTo(5f)); + mTencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(40.040219, 116.273348), 20, 0, 0))); + mSpinner = findViewById(R.id.sp_style); + ArrayAdapter adapter = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_spinner_dropdown_item, styles); + mSpinner.setAdapter(adapter); + mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + switch (position) { + case 0: + if (vectorOverlay != null) { + vectorOverlay.remove(); + vectorOverlay = null; + } + addDotVectorOverlay(); + mTencentMap.updateVectorOverlay(vectorOverlay, dotScatterPlotOverlayProvider); + break; + case 1: + if (vectorOverlay != null) { + vectorOverlay.remove(); + vectorOverlay = null; + } + addBitmapVectorOverlay(); + mTencentMap.updateVectorOverlay(vectorOverlay, provider); + break; + } + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + + } + + + private void addDotVectorOverlay() { + mIsSelected = true; + if (vectorOverlay == null) { + BufferedReader br = null; + final ArrayList nodes = new ArrayList(); + double lat = 40.040219; + double lng = 116.273348; + double value = 100; + Random r = new Random(); + for (int i = 0; i < 2000; i++) { + double a = r.nextInt(10) * 1E-5; + double b = r.nextInt(10) * 1E-5; + LatLng latLng = new LatLng(lat + a, lng + b); + nodes.add(new ScatterLatLng(latLng, value)); + } + int[] colors = { + Color.argb(255, 0, 0xd4, 0xff), + Color.argb((int) (255 * 0.3), 0, 0xd4, 0xff), + Color.argb(255, 0, 0xd4, 0xff) + }; + + dotScatterPlotOverlayProvider = new DotScatterPlotOverlayProvider().data(nodes).opacity(2f).radius(2).animate(true).colors(colors); + + vectorOverlay = mTencentMap.addVectorOverlay(dotScatterPlotOverlayProvider); + + } + + } + + private void addBitmapVectorOverlay() { + mIsSelected = true; + if (vectorOverlay == null) { + final ArrayList nodes = new ArrayList(); + double lat = 40.040219; + double lng = 116.273348; + double value = 10; + Random r = new Random(); + for (int i = 0; i < 1000; i++) { + double a = r.nextInt(10) * 1E-5; + double b = r.nextInt(10) * 1E-5; + LatLng latLng = new LatLng(lat + a, lng + b); + nodes.add(new ScatterLatLng(latLng, value)); + } + BitmapDescriptor[] bitmaps = { + BitmapDescriptorFactory.fromAsset("21.jpg"), + BitmapDescriptorFactory.fromAsset("22.jpg"), + BitmapDescriptorFactory.fromAsset("23.jpg"), + BitmapDescriptorFactory.fromAsset("24.jpg"), + BitmapDescriptorFactory.fromAsset("25.jpg"), + BitmapDescriptorFactory.fromAsset("26.jpg"), + }; + provider = new BitmapScatterPlotOverlayProvider().data(nodes).bitmaps(bitmaps).opacity(2f).scale(20, 10); + vectorOverlay = mTencentMap.addVectorOverlay(provider); + } + + } +} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/TrailOverlayActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/TrailOverlayActivity.java new file mode 100644 index 0000000..5ca3dfe --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/TrailOverlayActivity.java @@ -0,0 +1,147 @@ +package com.tencent.map.vector.demo.heatoverlay; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import android.graphics.Color; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; + +import com.tencent.map.sdk.utilities.visualization.datamodels.TimeLatLng; +import com.tencent.map.sdk.utilities.visualization.datamodels.TrailLatLng; +import com.tencent.map.sdk.utilities.visualization.trails.TrailOverlayProvider; +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.MapView; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.VectorOverlay; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; + +public class TrailOverlayActivity extends AppCompatActivity { + private MapView mMapView; + private TencentMap mTencentMap; + private VectorOverlay vectorOverlay; + boolean mIsSelected; + private TrailOverlayProvider trailOverlayProvider; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_trail_overlay); + init(); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.vectorheatmap, menu); + return true; + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + menu.findItem(R.id.menu_open_vectorheatmap).setVisible(!mIsSelected); + menu.findItem(R.id.menu_close_vectorheatmap).setVisible(mIsSelected); + return super.onPrepareOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(@NonNull MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_open_vectorheatmap: + addArcLineLayer(); + break; + case R.id.menu_close_vectorheatmap: + mIsSelected = false; + if (vectorOverlay != null) { + vectorOverlay.remove(); + vectorOverlay = null; + } + break; + } + + supportInvalidateOptionsMenu(); + return super.onOptionsItemSelected(item); + } + + @Override + protected void onResume() { + super.onResume(); + mMapView.onResume(); + } + + @Override + protected void onPause() { + super.onPause(); + mMapView.onPause(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mMapView.onDestroy(); + } + + + @Override + protected void onStart() { + super.onStart(); + mMapView.onStart(); + } + + @Override + protected void onStop() { + super.onStop(); + mMapView.onStop(); + } + + private void init() { + mMapView = findViewById(R.id.mapView); + mTencentMap = mMapView.getMap(); + mTencentMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(39.942117, 116.33668), 11)); + } + + private void addArcLineLayer() { + mIsSelected = true; + if (vectorOverlay == null) { + + mTencentMap.setPoisEnabled(false); + BufferedReader br = null; + long currentTime = System.currentTimeMillis(); + List startLats = new ArrayList<>(); + try { + br = new BufferedReader(new InputStreamReader(getResources().getAssets().open("trailData.dat"))); + + String line = null; + while ((line = br.readLine()) != null) { + String[] oneDot = line.split(","); + TimeLatLng[] timeLatLngs = new TimeLatLng[oneDot.length]; + int i = 0; + for (String timeLatLng : oneDot) { + String[] values = timeLatLng.split("\t"); + LatLng latlng = new LatLng((Double.parseDouble(values[0])), (Double.parseDouble(values[1]))); + int timeStamp = Integer.parseInt(values[2]); + timeLatLngs[i++] = new TimeLatLng(latlng, timeStamp); + } + TrailLatLng tmp = new TrailLatLng(timeLatLngs); + startLats.add(tmp); + } + } catch (Exception e) { + e.printStackTrace(); + } + int[] colors = {Color.argb(0xff, 0x00, 0x00, 0xff), + Color.argb(0x00, 0xff, 0xff, 0x00)}; + + trailOverlayProvider = new TrailOverlayProvider().type(TrailOverlayProvider.TrailOverlayType.Trail).data(startLats).opacity(2f).width(10).gradient(colors).setHighlightDuration(8000).setAnimateStartTime(0, 25000); + vectorOverlay = mTencentMap.addVectorOverlay(trailOverlayProvider); + + + } + + } +} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/VectorHeatMapActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/VectorHeatMapActivity.java new file mode 100644 index 0000000..d62ab21 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/VectorHeatMapActivity.java @@ -0,0 +1,182 @@ +package com.tencent.map.vector.demo.heatoverlay; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.FragmentActivity; + +import android.os.Bundle; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.widget.CompoundButton; +import android.widget.ToggleButton; + +import com.tencent.map.sdk.utilities.heatmap.WeightedLatLng; +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.MapView; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.VectorHeatAggregationUnit; +import com.tencent.tencentmap.mapsdk.maps.model.VectorHeatOverlay; +import com.tencent.tencentmap.mapsdk.maps.model.VectorHeatOverlayOptions; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; + +/** + * 蜂窝热力图 + */ +public class VectorHeatMapActivity extends SupportMapFragmentActivity { + + MapView mMapView; + TencentMap mTencentMap; + VectorHeatOverlay mOverlay; + boolean mIsSelected; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_vector_heat_map); + mMapView = findViewById(R.id.map_view); + mTencentMap = mMapView.getMap(); + mTencentMap.moveCamera(CameraUpdateFactory.newLatLngZoom( + new LatLng(36.139985, 120.402243), + 11)); + + mTencentMap.setOnMapClickListener(new TencentMap.OnMapClickListener() { + @Override + public void onMapClick(LatLng latlng) { + if (mOverlay == null) { + return; + } + VectorHeatAggregationUnit unit = mOverlay.getUnit(latlng); + if (unit == null) { + Log.e("VectorHeatMapActivity", "no unit found"); + return; + } + Log.e("VectorHeatMapActivity", "unit center:" + unit.getCenter() + + ", intensity:" + unit.getIntensity() + + ", size:" + unit.getNodes().length); + } + }); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.vectorheatmap, menu); + return true; + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + menu.findItem(R.id.menu_open_vectorheatmap).setVisible(!mIsSelected); + menu.findItem(R.id.menu_close_vectorheatmap).setVisible(mIsSelected); + return super.onPrepareOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(@NonNull MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_open_vectorheatmap: + addVectorHeatMap(); + break; + case R.id.menu_close_vectorheatmap: + removeVectorHeatMap(); + break; + } + + supportInvalidateOptionsMenu(); + return super.onOptionsItemSelected(item); + } + + private ArrayList getHeatNodes() { + BufferedReader br = null; + ArrayList nodes = null; + try { + nodes = new ArrayList<>(); + br = new BufferedReader(new InputStreamReader( + getResources().getAssets().open("honeycomb.txt"))); + String line; + while ((line = br.readLine()) != null) { + String[] lines = line.split("\t"); + if (lines.length == 3) { + double value = Double.parseDouble(lines[2]); + LatLng latLng = new LatLng((Double.parseDouble(lines[1])), + (Double.parseDouble(lines[0]))); + nodes.add(new WeightedLatLng(latLng, 1)); + } + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (br != null) { + try { + br.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return nodes; + } + } + + @Override + protected void onResume() { + super.onResume(); + if (mMapView != null) { + mMapView.onResume(); + } + } + + @Override + protected void onPause() { + super.onPause(); + if (mMapView != null) { + mMapView.onPause(); + } + } + + @Override + protected void onStop() { + super.onStop(); + if (mMapView != null) { + mMapView.onStop(); + } + } + + @Override + protected void onDestroy() { + super.onDestroy(); + if (mMapView != null) { + mMapView.onDestroy(); + } + } + + private void addVectorHeatMap() { + mIsSelected = true; + if (mOverlay != null) { + return; + } + WeightedLatLng[] nodes = getHeatNodes().toArray(new WeightedLatLng[0]); + VectorHeatOverlayOptions options = new VectorHeatOverlayOptions() + .nodes(nodes) + .size(2000) + .gap(100) + .colors(new int[]{0x45fa4b14, 0x99fa4b14, 0xd9fa4b14}) + .startPoints(new double[]{0, 0.6, 0.8}); + mOverlay = mTencentMap.addVectorHeatOverlay(options); + } + + public void removeVectorHeatMap() { + mIsSelected = false; + if (mOverlay == null) { + return; + } + mOverlay.remove(); + mOverlay = null; + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/location/LocationLayerActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/location/LocationLayerActivity.java new file mode 100644 index 0000000..aeb6339 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/location/LocationLayerActivity.java @@ -0,0 +1,251 @@ +package com.tencent.map.vector.demo.location; + +import android.Manifest; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Matrix; +import android.location.Location; +import android.os.Looper; + +import androidx.annotation.NonNull; + +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.RadioGroup; +import android.widget.Toast; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.google.gson.Gson; +import com.tencent.map.geolocation.TencentLocation; +import com.tencent.map.geolocation.TencentLocationListener; +import com.tencent.map.geolocation.TencentLocationManager; +import com.tencent.map.geolocation.TencentLocationRequest; +import com.tencent.tencentmap.mapsdk.maps.LocationSource; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle; + +import java.util.List; + +import pub.devrel.easypermissions.EasyPermissions; + +public class LocationLayerActivity extends SupportMapFragmentActivity implements EasyPermissions.PermissionCallbacks, LocationSource, TencentLocationListener, TencentMap.OnMapLongClickListener, RadioGroup.OnCheckedChangeListener { + + private OnLocationChangedListener locationChangedListener; + + private TencentLocationManager locationManager; + private TencentLocationRequest locationRequest; + private MyLocationStyle locationStyle; + private RadioGroup radioGroup; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + + //定位需要申请的权限 + String[] perms = { + Manifest.permission.ACCESS_FINE_LOCATION, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_PHONE_STATE + }; + + if (EasyPermissions.hasPermissions(this, perms)) {//检查是否获取该权限 + Log.i("location", "已获取权限"); + } else { + EasyPermissions.requestPermissions(this, "必要的权限", 0, perms); + } + //设置显示定位的图标 + mapUiSettings.setMyLocationButtonEnabled(true); + tencentMap.setOnMapLongClickListener(this); + + radioGroup = findViewById(R.id.location_type); + radioGroup.setVisibility(View.VISIBLE); + radioGroup.setOnCheckedChangeListener(this); + + //建立定位 + initLocation(); + //SDK版本4.3.5新增内置定位标点击回调监听 + tencentMap.setMyLocationClickListener(new TencentMap.OnMyLocationClickListener() { + @Override + public boolean onMyLocationClicked(LatLng latLng) { + Toast.makeText(LocationLayerActivity.this, "内置定位标点击回调", Toast.LENGTH_SHORT).show(); + return true; + } + }); + } + + /** + * 定位的一些初始化设置 + */ + private void initLocation() { + //用于访问腾讯定位服务的类, 周期性向客户端提供位置更新 + locationManager = TencentLocationManager.getInstance(this); + //设置坐标系 + locationManager.setCoordinateType(TencentLocationManager.COORDINATE_TYPE_GCJ02); + //创建定位请求 + locationRequest = TencentLocationRequest.create(); + //设置定位周期(位置监听器回调周期)为3s + locationRequest.setInterval(3000); + + //地图上设置定位数据源 + tencentMap.setLocationSource(this); + //设置当前位置可见 + tencentMap.setMyLocationEnabled(true); + //设置定位图标样式 + setLocMarkerStyle(); + tencentMap.setMyLocationStyle(locationStyle); + } + + /** + * 设置定位图标样式 + */ + private void setLocMarkerStyle() { + locationStyle = new MyLocationStyle(); + //创建图标 + BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.location_icon)); + locationStyle.icon(bitmapDescriptor); + //设置定位圆形区域的边框宽度 + locationStyle.strokeWidth(3); + //设置圆区域的颜色 + locationStyle.fillColor(R.color.style); + } + + private Bitmap getBitMap(int resourceId) { + Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId); + int width = bitmap.getWidth(); + int height = bitmap.getHeight(); + int newWidth = 55; + int newHeight = 55; + float widthScale = ((float) newWidth) / width; + float heightScale = ((float) newHeight) / height; + Matrix matrix = new Matrix(); + matrix.postScale(widthScale, heightScale); + bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); + return bitmap; + } + + /** + * 实现位置监听 + * + * @param tencentLocation + * @param i + * @param s + */ + @Override + public void onLocationChanged(TencentLocation tencentLocation, int i, String s) { + + if (i == TencentLocation.ERROR_OK && locationChangedListener != null) { + Location location = new Location(tencentLocation.getProvider()); + //设置经纬度以及精度 + location.setLatitude(tencentLocation.getLatitude()); + location.setLongitude(tencentLocation.getLongitude()); + location.setAccuracy(tencentLocation.getAccuracy()); + locationChangedListener.onLocationChanged(location); + + //显示回调的实时位置信息 + runOnUiThread(new Runnable() { + @Override + public void run() { + //打印tencentLocation的json字符串 +// Toast.makeText(getApplicationContext(), new Gson().toJson(location), Toast.LENGTH_LONG).show(); + } + }); + } + } + + @Override + public void onStatusUpdate(String s, int i, String s1) { + //GPS, WiFi, Radio 等状态发生变化 + Log.v("State changed", s + "===" + s1); + } + + + @Override + public void activate(OnLocationChangedListener onLocationChangedListener) { + locationChangedListener = onLocationChangedListener; + + int err = locationManager.requestLocationUpdates(locationRequest, this, Looper.myLooper()); + switch (err) { + case 1: + Toast.makeText(this, "设备缺少使用腾讯定位服务需要的基本条件", Toast.LENGTH_SHORT).show(); + break; + case 2: + Toast.makeText(this, "manifest 中配置的 key 不正确", Toast.LENGTH_SHORT).show(); + break; + case 3: + Toast.makeText(this, "自动加载libtencentloc.so失败", Toast.LENGTH_SHORT).show(); + break; + + default: + break; + } + } + + @Override + public void deactivate() { + locationManager.removeUpdates(this); + locationManager = null; + locationRequest = null; + locationChangedListener = null; + } + + @Override + public void onPermissionsGranted(int requestCode, @NonNull List perms) { + Log.e("location quest: ", "success"); + } + + @Override + public void onPermissionsDenied(int requestCode, @NonNull List perms) { + Log.e("location quest: ", "failed"); + } + + @Override + public void onMapLongClick(LatLng latLng) { + Location location = new Location("LongPressLocationProvider"); + location.setLatitude(latLng.latitude); + location.setLongitude(latLng.longitude); + location.setAccuracy(20); + locationChangedListener.onLocationChanged(location); + Log.i("long click", new Gson().toJson(latLng)); + } + + @Override + public void onCheckedChanged(RadioGroup radioGroup, int i) { + switch (i) { + //连续定位,但不会移动到地图中心点,并且会跟随设备移动 + case R.id.btn_follow_no_center: + + initLocation(); + locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_FOLLOW_NO_CENTER); + tencentMap.setMyLocationStyle(locationStyle); + break; + //连续定位,且将视角移动到地图中心,定位点依照设备方向旋转,并且会跟随设备移动,默认是此种类型 + case R.id.btn_location_rotate: + + initLocation(); + locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE); + tencentMap.setMyLocationStyle(locationStyle); + break; + //连续定位,但不会移动到地图中心点,定位点依照设备方向旋转,并且跟随设备移动 + case R.id.btn_location_rotate_no_center: + + initLocation(); + locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER); + tencentMap.setMyLocationStyle(locationStyle); + break; + //连续定位,但不会移动到地图中心点,地图依照设备方向旋转,并且会跟随设备移动 + case R.id.btn_map_rotate_no_center: + + initLocation(); + locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_MAP_ROTATE_NO_CENTER); + tencentMap.setMyLocationStyle(locationStyle); + break; + } + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/location/LocationPointActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/location/LocationPointActivity.java new file mode 100644 index 0000000..b841353 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/location/LocationPointActivity.java @@ -0,0 +1,190 @@ +package com.tencent.map.vector.demo.location; + +import android.Manifest; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Matrix; +import android.location.Location; +import android.os.Bundle; +import android.os.Looper; +import androidx.annotation.NonNull; +import android.util.Log; +import android.widget.Toast; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.map.geolocation.TencentLocation; +import com.tencent.map.geolocation.TencentLocationListener; +import com.tencent.map.geolocation.TencentLocationManager; +import com.tencent.map.geolocation.TencentLocationRequest; +import com.tencent.tencentmap.mapsdk.maps.LocationSource; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; +import com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle; + +import java.util.List; + +import pub.devrel.easypermissions.EasyPermissions; + +public class LocationPointActivity extends SupportMapFragmentActivity implements EasyPermissions.PermissionCallbacks,LocationSource, TencentLocationListener{ + private LocationSource.OnLocationChangedListener locationChangedListener; + + private TencentLocationManager locationManager; + private TencentLocationRequest locationRequest; + private MyLocationStyle locationStyle; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + + //定位需要申请的权限 + String[] perms = { + Manifest.permission.ACCESS_FINE_LOCATION, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_PHONE_STATE + }; + + if (EasyPermissions.hasPermissions(this, perms)) {//检查是否获取该权限 + Log.i("location", "已获取权限"); + } else { + EasyPermissions.requestPermissions(this, "必要的权限", 0, perms); + } + //设置显示定位的图标 + TencentLocationManager.setUserAgreePrivacy(true); + //建立定位 + initLocation(); + } + + + /** + * 设置定位图标样式 + */ + private void setLocMarkerStyle(){ + locationStyle = new MyLocationStyle(); + //创建图标 + BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.marker)); + locationStyle.icon(bitmapDescriptor); + //设置定位圆形区域的边框宽度 + locationStyle.strokeWidth(3); + //设置圆区域的颜色 + locationStyle.fillColor(R.color.style); + + tencentMap.setMyLocationStyle(locationStyle); + } + + + + private Bitmap getBitMap(int resourceId){ + Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId); + int width = bitmap.getWidth(); + int height = bitmap.getHeight(); + int newWidth = 55; + int newHeight = 55; + float widthScale = ((float)newWidth)/width; + float heightScale = ((float)newHeight)/height; + Matrix matrix = new Matrix(); + matrix.postScale(widthScale, heightScale); + bitmap = Bitmap.createBitmap(bitmap,0,0,width,height,matrix,true); + return bitmap; + } + + + + /** + * 定位的一些初始化设置 + */ + private void initLocation(){ + //用于访问腾讯定位服务的类, 周期性向客户端提供位置更新 + locationManager = TencentLocationManager.getInstance(this); + //设置坐标系 + locationManager.setCoordinateType(TencentLocationManager.COORDINATE_TYPE_GCJ02); + //创建定位请求 + locationRequest = TencentLocationRequest.create(); + //设置定位周期(位置监听器回调周期)为3s + locationRequest.setInterval(3000); + + //地图上设置定位数据源 + tencentMap.setLocationSource(this); + //设置当前位置可见 + tencentMap.setMyLocationEnabled(true); + //设置定位图标样式 + setLocMarkerStyle(); +// locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE); + tencentMap.setMyLocationStyle(locationStyle); + } + /** + * 实现位置监听 + * @param tencentLocation + * @param i + * @param s + */ + @Override + public void onLocationChanged(TencentLocation tencentLocation, int i, String s) { + + if(i == TencentLocation.ERROR_OK && locationChangedListener != null){ + Location location = new Location(tencentLocation.getProvider()); + //设置经纬度以及精度 + location.setLatitude(tencentLocation.getLatitude()); + location.setLongitude(tencentLocation.getLongitude()); + location.setAccuracy(tencentLocation.getAccuracy()); + locationChangedListener.onLocationChanged(location); + + //显示回调的实时位置信息 + runOnUiThread(new Runnable() { + @Override + public void run() { + //打印tencentLocation的json字符串 +// Toast.makeText(getApplicationContext(), new Gson().toJson(location), Toast.LENGTH_LONG).show(); + } + }); + } + } + + @Override + public void onStatusUpdate(String s, int i, String s1) { + //GPS, WiFi, Radio 等状态发生变化 + Log.v("State changed", s +"===" + s1); + } + + + @Override + public void activate(OnLocationChangedListener onLocationChangedListener) { + locationChangedListener = onLocationChangedListener; + + int err = locationManager.requestLocationUpdates(locationRequest, this, Looper.myLooper()); + switch (err) { + case 1: + Toast.makeText(this,"设备缺少使用腾讯定位服务需要的基本条件",Toast.LENGTH_SHORT).show(); + break; + case 2: + Toast.makeText(this,"manifest 中配置的 key 不正确",Toast.LENGTH_SHORT).show(); + break; + case 3: + Toast.makeText(this,"自动加载libtencentloc.so失败",Toast.LENGTH_SHORT).show(); + break; + + default: + break; + } + } + + @Override + public void deactivate() { + locationManager.removeUpdates(this); + locationManager = null; + locationRequest = null; + locationChangedListener=null; + } + + @Override + public void onPermissionsGranted(int requestCode, @NonNull List perms) { + Log.e("location quest: ","success"); + } + + @Override + public void onPermissionsDenied(int requestCode, @NonNull List perms) { + Log.e("location quest: ","failed"); + } + +} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/AoiLayerActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/AoiLayerActivity.java similarity index 98% rename from positions/src/main/java/cc/winboll/studio/positions/demo/marker/AoiLayerActivity.java rename to positions/src/main/java/com/tencent/map/vector/demo/marker/AoiLayerActivity.java index 5839c73..d9479b3 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/AoiLayerActivity.java +++ b/positions/src/main/java/com/tencent/map/vector/demo/marker/AoiLayerActivity.java @@ -1,4 +1,4 @@ -package cc.winboll.studio.positions.demo.marker; +package com.tencent.map.vector.demo.marker; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/CustomRenderActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/CustomRenderActivity.java new file mode 100644 index 0000000..576efa5 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/marker/CustomRenderActivity.java @@ -0,0 +1,281 @@ +package com.tencent.map.vector.demo.marker; + +import androidx.appcompat.app.AppCompatActivity; + +import android.graphics.PointF; +import android.opengl.GLES20; +import android.os.Bundle; +import android.util.Log; + +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.CustomRender; +import com.tencent.tencentmap.mapsdk.maps.MapView; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; +import java.nio.ShortBuffer; + +/** + * OpenGL绘制 + */ +public class CustomRenderActivity extends AppCompatActivity { + + private static final String TAG = CustomRenderActivity.class.getSimpleName(); + + // 标识是否第一次绘制3D立方体 + private boolean mIsFirstDraw3DCube = true; + + // 立方体8个顶点坐标 + private float[] mVertices = { + -1, -1, -0, + 1, -1, -0, + 1, 1, -0, + -1, 1, -0, + -1, -1, 1, + 1, -1, 1, + 1, 1, 1, + -1, 1, 1, + }; + + // 3D立方体顶点绘制顺序列表 + private short[] mDrawIndices = { + 5, 4, 0, 1, 5, 0, 6, 5, 1, 2, 6, 1, + 7, 6, 2, 3, 7, 2, 4, 7, 3, 0, 4, 3, + 6, 7, 4, 5, 6, 4, 1, 0, 3, 2, 1, 3 + }; + + // 3D立方体8个顶点颜色值 + private float[] mVertexColors = { + 1f, 1f, 0f, 1f, + 0f, 1f, 1f, 1f, + 1f, 0f, 1f, 1f, + 0f, 0f, 0f, 1f, + 1f, 1f, 1f, 1f, + 1f, 0f, 0f, 1f, + 0f, 1f, 0f, 1f, + 0f, 0f, 1f, 1f + }; + + // 立方体顶点坐标Buffer + private FloatBuffer mVertexBuffer; + + // 顶点绘制顺序Buffer + private ShortBuffer mIndexBuffer; + + // 立方体顶点颜色Buffer + private FloatBuffer mColorBuffer; + + // 3D立方体着色器 + private CubeShader mCubeShader; + + private MapView mapView; + + private TencentMap mMap; + + private LatLng latlng = new LatLng(40.04199816,116.27479076); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_custom_render); + mapView = findViewById(R.id.map_view); + mMap = mapView.getMap(); + mMap.addOnMapLoadedCallback(new TencentMap.OnMapLoadedCallback() { + @Override + public void onMapLoaded() { + mMap.setCustomRender(new CubeRender()); + mMap.removeOnMapLoadedCallback(this); + } + }); + + mMap.moveCamera(CameraUpdateFactory.newCameraPosition(CameraPosition.builder() + .target(latlng).zoom(16).tilt(45).build())); + + + } + + @Override + protected void onResume() { + // TODO Auto-generated method stub + super.onResume(); + mapView.onResume(); + } + + @Override + protected void onDestroy() { + // TODO Auto-generated method stub + super.onDestroy(); + mapView.onDestroy(); + } + + private class CubeRender implements CustomRender { + + private void initCubeData(float width, float height, float depth) { + // 对标地图坐标 + initVertices(mVertices, width, height, depth); + + // 立方体顶点数据Buffer + mVertexBuffer = ByteBuffer.allocateDirect(mVertices.length * 4) + .order(ByteOrder.nativeOrder()) + .asFloatBuffer(); + mVertexBuffer.put(mVertices).position(0); + + // 立方体顶点绘制顺序Buffer + ByteBuffer byteBuffer = ByteBuffer.allocateDirect(mDrawIndices.length * 4); + byteBuffer.order(ByteOrder.nativeOrder()); + mIndexBuffer = byteBuffer.asShortBuffer(); + mIndexBuffer.put(mDrawIndices); + mIndexBuffer.position(0); + + // 立方体顶点颜色Buffer + ByteBuffer byteBuffer1 = ByteBuffer.allocateDirect(mVertexColors.length * 4); + byteBuffer1.order(ByteOrder.nativeOrder()); + mColorBuffer = byteBuffer1.asFloatBuffer(); + mColorBuffer.put(mVertexColors); + mColorBuffer.position(0); + } + + private void initCubeShader() { + mCubeShader = new CubeShader(); + mCubeShader.init(); + } + + private void initVertices(float[] vertices, float width, float height, float depth) { + for (int i = 0; i < vertices.length / 3; i++) { + int m = i * 3; + vertices[m] = vertices[m] * width; + vertices[m + 1] = vertices[m + 1] * height; + vertices[m + 2] = vertices[m + 2] * depth; + } + } + + @Override + public void onDrawFrame() { + drawCube(); + } + + private void drawCube() { + + if (mIsFirstDraw3DCube) { + float cubeWidth = 0.2f * 10000 / 2; + float cubeHeight = 0.2f * 10000 / 2; + float cubeDepth = 0.4f * 10000 / 2; + initCubeData(cubeWidth, cubeHeight, cubeDepth); + initCubeShader(); + mIsFirstDraw3DCube = false; + } + + if (null == mCubeShader) { + return; + } + + // 绑定地图移动 + PointF p1f = mMap.getProjection().glVertexForCoordinate(latlng); + float[] mvpMatrix = mMap.getProjection().glModelMatrix(p1f, 1); + + // Step2 开始绘制设置 + GLES20.glUseProgram(mCubeShader.mProgram); + checkGlError("glUseProgram"); + + GLES20.glEnable(GLES20.GL_DEPTH_TEST); + checkGlError("glEnable"); + + //对齐矩阵 + GLES20.glUniformMatrix4fv(mCubeShader.mMvpMatrix, 1, false, mvpMatrix, 0); + checkGlError("glUniformMatrix4fv"); + + GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); + // 顶点指针 + GLES20.glEnableVertexAttribArray(mCubeShader.mVertex); + checkGlError("glEnableVertexAttribArray"); + GLES20.glVertexAttribPointer(mCubeShader.mVertex, 3, GLES20.GL_FLOAT, false, 0, mVertexBuffer); + checkGlError("glVertexAttribPointer"); + + // 颜色指针 + GLES20.glEnableVertexAttribArray(mCubeShader.mColor); + checkGlError("glEnableVertexAttribArray"); + GLES20.glVertexAttribPointer(mCubeShader.mColor, 4, GLES20.GL_FLOAT, false, 0, mColorBuffer); + checkGlError("glVertexAttribPointer"); + + GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0); + // 开始画 + GLES20.glDrawElements(GLES20.GL_TRIANGLES, mDrawIndices.length, GLES20.GL_UNSIGNED_SHORT, mIndexBuffer); + checkGlError("glDrawElements"); + + GLES20.glDisableVertexAttribArray(mCubeShader.mVertex); + checkGlError("glDisableVertexAttribArray"); + + GLES20.glDisable(GLES20.GL_DEPTH_TEST); + checkGlError("glDisable"); + } + } + + private static class CubeShader { + int mVertex; + int mMvpMatrix; + int mColor; + int mProgram; + + String vertexShader = "precision mediump float;\n" + + " attribute vec3 mVertex;//顶点数组,三维坐标\n" + + " attribute vec4 mColor;//颜色数组,三维坐标\n" + + " uniform mat4 mMvpMatrix;//mvp矩阵\n" + + " varying vec4 color;//\n" + + " void main(){\n" + + " gl_Position = mMvpMatrix * vec4(mVertex, 1.0);\n" + + " color = mColor;\n" + + " }"; + + String fragmentShader = "//有颜色 没有纹理\n" + + " precision mediump float;\n" + + " varying vec4 color;//\n" + + " void main(){\n" + + " gl_FragColor = color;\n" + + " }"; + + public void init() { + int vertexLocation = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER); + GLES20.glShaderSource(vertexLocation, vertexShader); + checkGlError("glShaderSource"); + GLES20.glCompileShader(vertexLocation); + checkGlError("glCompileShader"); + int fragmentLocation = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER); + GLES20.glShaderSource(fragmentLocation, fragmentShader); + checkGlError("glShaderSource"); + GLES20.glCompileShader(fragmentLocation); + checkGlError("glCompileShader"); + + mProgram = GLES20.glCreateProgram(); + GLES20.glAttachShader(mProgram, vertexLocation); + GLES20.glAttachShader(mProgram, fragmentLocation); + GLES20.glLinkProgram(mProgram); + int[] linked = new int[1]; + GLES20.glGetProgramiv(mProgram, GLES20.GL_LINK_STATUS, linked, 0); + checkGlError("glLinkProgram"); + if (linked[0] != GLES20.GL_TRUE) { + Log.e(TAG, "Could not link program: "); + Log.e(TAG, GLES20.glGetProgramInfoLog(mProgram)); + GLES20.glDeleteProgram(mProgram); + mProgram = 0; + } + + + mVertex = GLES20.glGetAttribLocation(mProgram, "mVertex"); + mMvpMatrix = GLES20.glGetUniformLocation(mProgram, "mMvpMatrix"); + mColor = GLES20.glGetAttribLocation(mProgram, "mColor"); + } + + } + + static void checkGlError(String op) { + int error; + while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { + Log.e(TAG, op + ": glError " + error); + } + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/GroundOverlayActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/GroundOverlayActivity.java new file mode 100644 index 0000000..8f50b24 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/marker/GroundOverlayActivity.java @@ -0,0 +1,129 @@ +package com.tencent.map.vector.demo.marker; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.FragmentActivity; + +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.Button; +import android.widget.RadioGroup; + + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.MapView; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; +import com.tencent.tencentmap.mapsdk.maps.model.GroundOverlay; +import com.tencent.tencentmap.mapsdk.maps.model.GroundOverlayOptions; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds; +import com.tencent.tencentmap.mapsdk.maps.model.OverlayLevel; + +import java.util.ArrayList; + +public class GroundOverlayActivity extends SupportMapFragmentActivity { + + private MapView mMapView; + private TencentMap mTencentMap; + private GroundOverlay groundOverlay; + GroundOverlayOptions groundOverlayOptions; + private boolean mIsSelected; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_ground_overlay); + mMapView = findViewById(R.id.map_view); + mTencentMap = mMapView.getMap(); + mTencentMap.setIndoorEnabled(true); + } + + + @Override + protected void onResume() { + super.onResume(); + mMapView.onResume(); + } + + @Override + protected void onPause() { + super.onPause(); + mMapView.onPause(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mMapView.onDestroy(); + } + + + @Override + protected void onStart() { + super.onStart(); + mMapView.onStart(); + } + + @Override + protected void onStop() { + super.onStop(); + mMapView.onStop(); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.marker_groundoverlay, menu); + return true; + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + menu.findItem(R.id.menu_add_groundoverlay).setVisible(!mIsSelected); + menu.findItem(R.id.menu_remove_groundoverlay).setVisible(mIsSelected); + return super.onPrepareOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(@NonNull MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_add_groundoverlay: + addGroundOverlays(); + break; + case R.id.menu_remove_groundoverlay: + removeGroundOverlays(); + break; + } + + supportInvalidateOptionsMenu(); + return super.onOptionsItemSelected(item); + } + + public void addGroundOverlays() { + mIsSelected = true; + LatLngBounds lb = new LatLngBounds( + new LatLng(40.045226, 116.280069), + new LatLng(40.038918, 116.271873)); + groundOverlayOptions = new GroundOverlayOptions() + .bitmap(BitmapDescriptorFactory + .fromAsset("groundoverlay.jpg")) + .latLngBounds(lb) + .alpha(10); + groundOverlay = mTencentMap.addGroundOverlay(groundOverlayOptions); + mTencentMap.moveCamera(CameraUpdateFactory.newLatLngBounds(lb, 300)); + + } + + public void removeGroundOverlays() { + mIsSelected = false; + if (groundOverlay != null) { + groundOverlay.remove(); + groundOverlay = null; + } + } + +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerActivity.java new file mode 100644 index 0000000..5e6338e --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerActivity.java @@ -0,0 +1,74 @@ +package com.tencent.map.vector.demo.marker; + +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Matrix; +import android.os.Bundle; +import android.view.View; +import android.widget.CompoundButton; +import android.widget.Switch; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.Marker; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; + +public class MarkerActivity extends SupportMapFragmentActivity { + public Marker marker; + public Switch aSwitch; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + aSwitch = findViewById(R.id.switch_map); + aSwitch.setVisibility(View.VISIBLE); + aSwitch.setText("添加标注"); + setMarker(); + aSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if(isChecked){ + setMarker(); + }else { + if(marker!=null){ + marker.remove(); + } + } + } + }); + + } + + /** + * 设置标注 + */ + private void setMarker(){ + LatLng latLng = new LatLng(39.984108,116.307557); + BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.marker)); + MarkerOptions options = new MarkerOptions().position(latLng).icon(bitmapDescriptor); + + //设置infowindow + options.title("地址"); + options.snippet("中国技术交易大厦"); + marker = tencentMap.addMarker(options); + marker.setInfoWindowEnable(true); + } + + + private Bitmap getBitMap(int resourceId){ + Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId); + int width = bitmap.getWidth(); + int height = bitmap.getHeight(); + int newWidth = 100; + int newHeight = 100; + float widthScale = ((float)newWidth)/width; + float heightScale = ((float)newHeight)/height; + Matrix matrix = new Matrix(); + matrix.postScale(widthScale, heightScale); + bitmap = Bitmap.createBitmap(bitmap,0,0,width,height,matrix,true); + return bitmap; + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerAnimation.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerAnimation.java new file mode 100644 index 0000000..22fe233 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerAnimation.java @@ -0,0 +1,235 @@ +package com.tencent.map.vector.demo.marker; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Matrix; +import android.graphics.Point; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.animation.AccelerateDecelerateInterpolator; +import android.view.animation.Interpolator; + +import androidx.annotation.Nullable; + +import com.tencent.map.vector.demo.AbsMapActivity; +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.AnimationListener; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.IAlphaAnimation; +import com.tencent.tencentmap.mapsdk.maps.model.IAnimationSet; +import com.tencent.tencentmap.mapsdk.maps.model.IRotateAnimation; +import com.tencent.tencentmap.mapsdk.maps.model.IScaleAnimation; +import com.tencent.tencentmap.mapsdk.maps.model.ITranslateAnimation; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.Marker; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; +import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; + +import java.util.ArrayList; +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; + +public class MarkerAnimation extends AbsMapActivity { + + private int rotate = 0; + private int scale = 1; + private int alpha = 2; + private int translate = 3; + private int set = 4; + private boolean mHasAdded; + private Marker marker; + private IRotateAnimation rotateAnimation; + private IScaleAnimation scaleAnimation; + private IAlphaAnimation alphaAnimation; + private ITranslateAnimation translateAnimation; + private TencentMap tencentMap; + private IAnimationSet animationSet; + private LatLng latLng; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState, TencentMap mTencentMap) { + super.onCreate(savedInstanceState, mTencentMap); + tencentMap = mTencentMap; + tencentMap.moveCamera(CameraUpdateFactory.zoomTo(15)); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.marker_animation, menu); + return true; + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + menu.findItem(R.id.menu_add_marker).setVisible(!mHasAdded); + menu.findItem(R.id.menu_delete_marker).setVisible(mHasAdded); + return super.onPrepareOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_add_marker_rotate: + tencentMap.clear(); + marker = tencentMap.addMarker(setMarkerAnimation(rotate)); + mHasAdded = true; + marker.setAnimation(rotateAnimation); + marker.startAnimation(); + break; + + case R.id.menu_add_marker_scale: + tencentMap.clear(); + marker = tencentMap.addMarker(setMarkerAnimation(scale)); + mHasAdded = true; + marker.setAnimation(scaleAnimation); + marker.startAnimation(); + scaleAnimation.setAnimationListener(new AnimationListener() { + @Override + public void onAnimationStart() { + + } + + @Override + public void onAnimationEnd() { + marker.startAnimation(); + } + }); + + + break; + case R.id.menu_add_marker_alpha: + tencentMap.clear(); + marker = tencentMap.addMarker(setMarkerAnimation(alpha)); + mHasAdded = true; + marker.setAnimation(alphaAnimation); + marker.startAnimation(); + break; + case R.id.menu_add_marker_translate: + tencentMap.clear(); + marker = tencentMap.addMarker(setMarkerAnimation(translate)); + mHasAdded = true; + Point screenLocation = tencentMap.getProjection().toScreenLocation(latLng); + + marker.setFixingPoint(screenLocation.x, screenLocation.y); + + marker.setAnimation(translateAnimation); + marker.startAnimation(); + + translateAnimation.setAnimationListener(new AnimationListener() { + @Override + public void onAnimationStart() { + + } + + @Override + public void onAnimationEnd() { + marker.setFixingPointEnable(false); + + } + }); + break; + case R.id.menu_add_marker_set: + tencentMap.clear(); + marker = tencentMap.addMarker(setMarkerAnimation(set)); + mHasAdded = true; + marker.setAnimation(animationSet); + marker.startAnimation(); + break; + + case R.id.menu_delete_marker: + if (marker != null) { + marker.remove(); + marker = null; + mHasAdded = false; + } + break; + } + return super.onOptionsItemSelected(item); + } + + private MarkerOptions setMarkerAnimation(int type) { + latLng = new LatLng(39.984108, 116.307557); + BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.marker)); + MarkerOptions position = new MarkerOptions().position(latLng).icon(bitmapDescriptor); + switch (type) { + case 0: + //旋转动画 + rotateAnimation = tencentMap.getMapContext().createRotateAnimation(0, 360, 0, 0, 0); + rotateAnimation.setDuration(2000); + break; + case 1: + //缩放动画 + scaleAnimation = tencentMap.getMapContext().createScaleAnimation(0.0f, 1f, 0.0f, 1f); + scaleAnimation.setDuration(2000); + scaleAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); + + case 2: + //渐变 + alphaAnimation = tencentMap.getMapContext().createAlphaAnimation(0f, 1f); + alphaAnimation.setDuration(2000); + alphaAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); + + break; + case 3: + //平移 + Point point = tencentMap.getProjection().toScreenLocation(latLng); + point.y -= dip2px(this, 250); + LatLng target = tencentMap.getProjection().fromScreenLocation(point); + translateAnimation = tencentMap.getMapContext().createTranslateAnimation(target); + translateAnimation.setInterpolator(new Interpolator() { + @Override + public float getInterpolation(float v) { + if (v <= 0.5f) { + return (float) (0.5f - 2 * (0.5 - v) * (0.5 - v)); + } else { + return (float) (0.5f - Math.sqrt((v - 0.5f) * (1.5f - v))); + } + } + }); + translateAnimation.setDuration(2000); + break; + case 4: + //组合动画 + animationSet = tencentMap.getMapContext().createAnimationSet(true); + if (rotateAnimation != null || scaleAnimation != null || alphaAnimation != null) { + animationSet.addAnimation(rotateAnimation); + animationSet.addAnimation(scaleAnimation); + animationSet.addAnimation(alphaAnimation); + } + + break; + + default: + throw new IllegalStateException("Unexpected value: " + type); + } + return position; + } + + private static int dip2px(Context context, float dpValue) { + final float scale = context.getResources().getDisplayMetrics().density; + return (int) (dpValue * scale + 1.5f); + } + + private Bitmap getBitMap(int resourceId) { + Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId); + int width = bitmap.getWidth(); + int height = bitmap.getHeight(); + int newWidth = 100; + int newHeight = 100; + float widthScale = ((float) newWidth) / width; + float heightScale = ((float) newHeight) / height; + Matrix matrix = new Matrix(); + matrix.postScale(widthScale, heightScale); + bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); + return bitmap; + } + +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerClickActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerClickActivity.java new file mode 100644 index 0000000..a6ddacf --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerClickActivity.java @@ -0,0 +1,25 @@ +package com.tencent.map.vector.demo.marker; + +import android.os.Bundle; +import android.view.View; +import android.widget.Toast; + +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.Marker; + +public class MarkerClickActivity extends MarkerActivity implements TencentMap.OnMarkerClickListener{ + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + marker.setInfoWindowEnable(false); + aSwitch.setVisibility(View.GONE); + tencentMap.setOnMarkerClickListener(this); + } + + @Override + public boolean onMarkerClick(Marker marker) { + Toast.makeText(getApplicationContext(),"您点击了标注", Toast.LENGTH_SHORT).show(); + return false; + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerClusterActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerClusterActivity.java new file mode 100644 index 0000000..b2b71f8 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerClusterActivity.java @@ -0,0 +1,387 @@ +package com.tencent.map.vector.demo.marker; + +import android.annotation.TargetApi; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.Color; +import android.graphics.Point; +import android.os.Bundle; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.view.animation.AccelerateDecelerateInterpolator; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.Nullable; + +import com.tencent.map.vector.demo.AbsMapActivity; +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.utils.CoordinateActivity; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.IAlphaAnimation; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds; +import com.tencent.tencentmap.mapsdk.maps.model.Marker; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; +import com.tencent.tencentmap.mapsdk.maps.model.PolygonOptions; +import com.tencent.tencentmap.mapsdk.maps.model.VisibleRegion; +import com.tencent.tencentmap.mapsdk.vector.utils.clustering.Cluster; +import com.tencent.tencentmap.mapsdk.vector.utils.clustering.ClusterItem; +import com.tencent.tencentmap.mapsdk.vector.utils.clustering.ClusterManager; +import com.tencent.tencentmap.mapsdk.vector.utils.clustering.algo.NonHierarchicalDistanceBasedAlgorithm; +import com.tencent.tencentmap.mapsdk.vector.utils.clustering.view.ClusterRenderer; +import com.tencent.tencentmap.mapsdk.vector.utils.clustering.view.DefaultClusterRenderer; +import com.tencent.tencentmap.mapsdk.vector.utils.ui.IconGenerator; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; + +public class MarkerClusterActivity extends AbsMapActivity { + private TencentMap tencentMap; + private boolean mHasAdded; + //点聚合坐标数据集合 + private List generalItemList = new ArrayList<>(); + private ClusterManager markerClusterItemClusterManager; + private int i = 8; + //自定义聚合 + private ClusterManager petaItemClusterManager; + private ArrayList petaItems; + private ArrayList latLngs; + private NonHierarchicalDistanceBasedAlgorithm ndba; + private DefaultClusterRenderer markerClusterItemDefaultClusterRenderer; + private String TAG="MarkerClusterActivity"; + + @Override + + protected void onCreate(@Nullable Bundle savedInstanceState, TencentMap mTencentMap) { + super.onCreate(savedInstanceState, mTencentMap); + tencentMap = mTencentMap; + //tencentMap.enableMultipleInfowindow(true); + tencentMap.moveCamera(CameraUpdateFactory.zoomTo(15)); + //默认聚合管理 + configDefaultCluterManger(); + configCustomCluterManger(); + petaItemClusterManager.setOnClusterClickListener(new ClusterManager.OnClusterClickListener() { + @Override + public boolean onClusterClick(Cluster cluster) { + Collection items = cluster.getItems(); + + return false; + } + }); + tencentMap.setOnCameraChangeListener(new TencentMap.OnCameraChangeListener() { + @Override + public void onCameraChange(CameraPosition cameraPosition) { + + } + + @Override + public void onCameraChangeFinished(CameraPosition cameraPosition) { + float zoom = cameraPosition.zoom; + if (zoom < 6) { + tencentMap.setOnCameraChangeListener(markerClusterItemClusterManager); + markerClusterItemClusterManager.addItems(getMassiveCoords()); + // tencentMap.animateCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder().include(latLngs).build(), 20)); + markerClusterItemClusterManager.cluster(); + + } else { + markerClusterItemClusterManager.cancel(); + } + Log.d(TAG, "onCameraChangeFinished: " + zoom); + } + }); + } + + public class PetaItem implements ClusterItem { + private final LatLng mLatLng; + private int mDrawableResourceId; + + public PetaItem(double lat, double lon, int resourceId) { + mLatLng = new LatLng(lat, lon); + mDrawableResourceId = resourceId; + } + + @Override + public LatLng getPosition() { + return mLatLng; + } + + public int getDrawableResourceId() { + return mDrawableResourceId; + } + } + + //聚合设置 + private void configDefaultCluterManger() { + //实例化点聚合管理者 + markerClusterItemClusterManager = new ClusterManager<>(this, tencentMap); + //默认聚合策略,调用时不用添加,如果需要其它聚合策略可以按以下修改 + ndba = new NonHierarchicalDistanceBasedAlgorithm<>(this); + //设置点聚合距离 + ndba.setMaxDistanceAtZoom(35); + //设置策略 + markerClusterItemClusterManager.setAlgorithm(ndba); + //设置聚合渲染器,按照需要设置 + markerClusterItemDefaultClusterRenderer = new DefaultClusterRenderer<>(this, tencentMap, markerClusterItemClusterManager); + //设置最小聚合数量,默认是4 + markerClusterItemDefaultClusterRenderer.setMinClusterSize(5); + //定义聚合的分段,例如:当超过5个不满足10个数据,显示5+ + markerClusterItemDefaultClusterRenderer.setBuckets(new int[]{5, 10, 20, 50}); + markerClusterItemClusterManager.setRenderer(markerClusterItemDefaultClusterRenderer); + + + } + + //自定义聚合样式设置 + private void configCustomCluterManger() { + petaItemClusterManager = new ClusterManager<>(this, tencentMap); + CustomIconClusterRenderer customIconClusterRender = new CustomIconClusterRenderer(this, tencentMap, petaItemClusterManager); + customIconClusterRender.setMinClusterSize(3); + petaItemClusterManager.setRenderer(customIconClusterRender); + + } + + + //普通聚合 + private Collection getGeneralCoords() { + if (generalItemList == null || generalItemList.size() == 0) { + generalItemList = getItemWithFileName("cluster_new"); + } + return generalItemList; + } + + //海量聚合 + private Collection getMassiveCoords() { + if (generalItemList == null || generalItemList.size() == 0) { + generalItemList = getItemWithFileName("datab"); + } + return generalItemList; + } + + private List getItemWithFileName(String cluster_new) { + ArrayList arrayList = new ArrayList<>(); + latLngs = new ArrayList<>(); + try { + InputStream inputStream = getAssets().open(cluster_new); + InputStreamReader inputStreamReader = new InputStreamReader(inputStream); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader); + String line; + while ((line = bufferedReader.readLine()) != null) { + String[] data = line.split("\t"); + double longitue = Double.parseDouble(data[0]); + double latitue = Double.parseDouble(data[1]); + arrayList.add(new MarkerClusterItem(latitue, longitue)); + latLngs.add(new LatLng(latitue, longitue)); + } + inputStream.close(); + inputStreamReader.close(); + bufferedReader.close(); + return arrayList; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.marker_cluster, menu); + return true; + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + menu.findItem(R.id.menu_add_marker).setVisible(!mHasAdded); + menu.findItem(R.id.menu_delete_marker).setVisible(mHasAdded); + return super.onPrepareOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + tencentMap.setInfoWindowAdapter(new TencentMap.InfoWindowAdapter() { + @Override + public View getInfoWindow(Marker marker) { + LinearLayout inflate = (LinearLayout) View.inflate(getApplicationContext(), R.layout.custom_infowindow, null); + TextView title = inflate.findViewById(R.id.tv_title); + Point point = tencentMap.getProjection().toScreenLocation(marker.getPosition()); + title.setText("\t\t\t\t\t\t\t\t自定义View弹窗:\n点在屏幕位置:" + point); + return inflate; + } + + @Override + public View getInfoContents(Marker marker) { + return null; + } + }); + final IAlphaAnimation alphaAnimation_custom = tencentMap.getMapContext().createAlphaAnimation(0f, 1f); + alphaAnimation_custom.setDuration(1000); + alphaAnimation_custom.setInterpolator(new AccelerateDecelerateInterpolator()); + tencentMap.setOnMarkerClickListener(new TencentMap.OnMarkerClickListener() { + @Override + public boolean onMarkerClick(Marker marker) { + Point point = tencentMap.getProjection().toScreenLocation(marker.getPosition()); + marker.setTitle(point.toString()); + marker.setAnimation(alphaAnimation_custom); + marker.startAnimation(); + return false; + } + }); + switch (item.getItemId()) { + case R.id.menu_add_marker_general: + mHasAdded = true; + //markerClusterItemClusterManager.cancel(); + tencentMap.setOnCameraChangeListener(markerClusterItemClusterManager); + markerClusterItemClusterManager.addItems(getGeneralCoords()); + LatLng position = generalItemList.get(6).getPosition(); + CameraUpdate cameraUpdate; + if (i < 16) { + i++; + cameraUpdate = CameraUpdateFactory.newLatLngZoom(position, i); + } else { + i = 6; + cameraUpdate = CameraUpdateFactory.newLatLngZoom(position, i); + } + tencentMap.animateCamera(cameraUpdate); + markerClusterItemClusterManager.cluster(); + + break; + case R.id.menu_add_marker_massive: + mHasAdded = true; + tencentMap.setOnCameraChangeListener(markerClusterItemClusterManager); + markerClusterItemClusterManager.addItems(getMassiveCoords()); + + LatLng position_massive = generalItemList.get(60).getPosition(); + CameraUpdate cameraUpdate_massive; + if (i < 16) { + i++; + cameraUpdate_massive = CameraUpdateFactory.newLatLngZoom(position_massive, i); + } else { + i = 6; + cameraUpdate_massive = CameraUpdateFactory.newLatLngZoom(position_massive, i); + } + tencentMap.animateCamera(cameraUpdate_massive); + markerClusterItemClusterManager.cluster(); + break; + case R.id.menu_add_marker_custom: + mHasAdded = true; + tencentMap.setOnCameraChangeListener(petaItemClusterManager); + addCustomClusterItem(); + tencentMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(39.971595, 116.314316), 15)); + petaItemClusterManager.cluster(); + break; + case R.id.menu_delete_marker: + mHasAdded = false; + clusterReMove(); + break; + + } + return super.onOptionsItemSelected(item); + } + + private void addCustomClusterItem() { + + petaItemClusterManager.addItem(new PetaItem(39.971595, 116.294747, R.mipmap.petal_blue)); + + petaItemClusterManager.addItem(new PetaItem(39.971595, 116.314316, R.mipmap.petal_red)); + + petaItemClusterManager.addItem(new PetaItem(39.967385, 116.317063, R.mipmap.petal_green)); + + petaItemClusterManager.addItem(new PetaItem(39.951596, 116.302300, R.mipmap.petal_yellow)); + + petaItemClusterManager.addItem(new PetaItem(39.970543, 116.290627, R.mipmap.petal_orange)); + + petaItemClusterManager.addItem(new PetaItem(39.966333, 116.311569, R.mipmap.petal_purple)); + } + + //移除聚合数据 + private void clusterReMove() { + markerClusterItemClusterManager.cancel(); + markerClusterItemClusterManager.cluster(); + generalItemList.clear(); + petaItemClusterManager.cancel(); + petaItemClusterManager.cluster(); + tencentMap.clearAllOverlays(); + + } + + class CustomIconClusterRenderer extends DefaultClusterRenderer { + + private IconGenerator mIconGenerator = new IconGenerator(getApplicationContext()); + private IconGenerator mClusterIconGenerator = new IconGenerator(getApplicationContext()); + private ImageView mItemImageView = new ImageView(getApplicationContext()); + private ImageView mClusterImageView = new ImageView(getApplicationContext()); + + public CustomIconClusterRenderer( + Context context, TencentMap map, ClusterManager clusterManager) { + super(context, map, clusterManager); + mItemImageView.setLayoutParams( + new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT)); + mIconGenerator.setContentView(mItemImageView); + + mClusterImageView.setLayoutParams( + new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT)); + mClusterIconGenerator.setContentView(mClusterImageView); + + setMinClusterSize(1); + } + + @Override + public void onBeforeClusterRendered( + Cluster cluster, MarkerOptions markerOptions) { + int[] resources = new int[cluster.getItems().size()]; + int i = 0; + for (PetaItem item : cluster.getItems()) { + resources[i++] = item.getDrawableResourceId(); + } + + PetalDrawable drawable = new PetalDrawable(getApplicationContext(), resources); + mClusterImageView.setImageDrawable(drawable); + Bitmap icon = mClusterIconGenerator.makeIcon(); + markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon)); + } + + @Override + public void onBeforeClusterItemRendered(PetaItem item, MarkerOptions markerOptions) { + mItemImageView.setImageResource(item.getDrawableResourceId()); + Bitmap icon = mIconGenerator.makeIcon(); + markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon)); + } + } + + class MarkerClusterItem implements ClusterItem { + private final LatLng mLatLng; + + public MarkerClusterItem(double lat, double lon) { + mLatLng = new LatLng(lat, lon); + } + + @Override + public LatLng getPosition() { + return mLatLng; + } + } +} + + diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerCollisions.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerCollisions.java new file mode 100644 index 0000000..3a272c7 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerCollisions.java @@ -0,0 +1,116 @@ +package com.tencent.map.vector.demo.marker; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; + +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.MapView; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.MapPoi; +import com.tencent.tencentmap.mapsdk.maps.model.Marker; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerCollisionItem; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; + +public class MarkerCollisions extends AppCompatActivity { + + private MapView mapView; + private TencentMap tencentMap; + private boolean mMarkerAdded; + private Marker mMarker; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_marker_collisions); + intit(); + } + + private void intit() { + mapView = findViewById(R.id.mapView); + tencentMap = mapView.getMap(); + CameraUpdate cameraSigma = + CameraUpdateFactory.newCameraPosition(new CameraPosition( + new LatLng(39.984066, 116.307548), + 15, + 0f, + 0f)); + //移动地图 + tencentMap.moveCamera(cameraSigma); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.markercol, menu); + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + menu.findItem(R.id.menu_open_collisionsmap).setVisible(!mMarkerAdded); + menu.findItem(R.id.menu_close_collisionsmap).setVisible(mMarkerAdded); + return super.onPrepareOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(@NonNull MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_open_collisionsmap: + mMarkerAdded = true; + BitmapDescriptor custom = BitmapDescriptorFactory.fromResource(R.drawable.marker); + MarkerOptions options = new MarkerOptions().position(new LatLng(39.984066, 116.307548)); + options.icon(custom); + mMarker = tencentMap.addMarker(options); + mMarker.setCollisions(MarkerCollisionItem.POI); + break; + case R.id.menu_close_collisionsmap: + mMarkerAdded = false; + mMarker.remove(); + break; + } + + supportInvalidateOptionsMenu(); + return super.onOptionsItemSelected(item); + } + + @Override + protected void onResume() { + super.onResume(); + mapView.onResume(); + } + + @Override + protected void onPause() { + super.onPause(); + mapView.onPause(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mapView.onDestroy(); + } + + + @Override + protected void onStart() { + super.onStart(); + mapView.onStart(); + } + + @Override + protected void onStop() { + super.onStop(); + mapView.onStop(); + } +} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerDragActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerDragActivity.java new file mode 100644 index 0000000..d45c5ef --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerDragActivity.java @@ -0,0 +1,45 @@ +package com.tencent.map.vector.demo.marker; + +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.TextView; +import android.widget.Toast; + +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.Marker; + +public class MarkerDragActivity extends MarkerActivity implements TencentMap.OnMarkerDragListener{ + private TextView textView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + marker.setInfoWindowEnable(false); + aSwitch.setVisibility(View.GONE); + + textView = findViewById(R.id.tv_info); + textView.setText("长按标记开始拖动"); + textView.setVisibility(View.VISIBLE); + + marker.setDraggable(true); + tencentMap.setOnMarkerDragListener(this); + } + + @Override + public void onMarkerDragStart(Marker marker) { + Log.e("marker:","drag"); + Toast.makeText(this, "拖拽开始", Toast.LENGTH_SHORT).show(); + } + + @Override + public void onMarkerDrag(Marker marker) { + + } + + @Override + public void onMarkerDragEnd(Marker marker) { + Toast.makeText(this, "拖拽结束", Toast.LENGTH_SHORT).show(); + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerInfoWindowActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerInfoWindowActivity.java new file mode 100644 index 0000000..efc419e --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerInfoWindowActivity.java @@ -0,0 +1,254 @@ +package com.tencent.map.vector.demo.marker; + +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.LinearLayout; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.Nullable; + +import com.tencent.map.vector.demo.AbsMapActivity; +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.Marker; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; + +public class MarkerInfoWindowActivity extends AbsMapActivity { + + + private static final int TYPE_BITMAP = 0; + private static final int TYPE_VIEW = 1; + + private static final int STYLE_NO_FRAME = 1; + private static final int STYLE_FRAME = 2; + + private Marker mMarker; + private Marker mAnotherMarker; + private TencentMap mTencentMap; + private int mInfoWindowAdapterStyle; + private int mInfoWindowType = TYPE_BITMAP; + private LinearLayout mCustomInfoWindowView; + + /** + * 自定义信息窗 + */ + private TencentMap.InfoWindowAdapter mInfoWindowAdapter = new TencentMap.InfoWindowAdapter() { + + TextView tvTitle; + + //返回View为信息窗自定义样式,返回null时为默认信息窗样式 + @Override + public View getInfoWindow(final Marker marker) { + if (mInfoWindowAdapterStyle == 1 && marker.equals(mMarker)) { + return createCustomInfoView(marker); + } + return null; + } + + //返回View为信息窗内容自定义样式,返回null时为默认信息窗样式 + @Override + public View getInfoContents(Marker marker) { + if (mInfoWindowAdapterStyle == 2 && marker.equals(mMarker)) { + return createCustomInfoView(marker); + } + return null; + } + + private View createCustomInfoView(Marker marker) { + mCustomInfoWindowView = (LinearLayout) View.inflate( + getApplicationContext(), R.layout.custom_infowindow, null); + tvTitle = mCustomInfoWindowView.findViewById(R.id.tv_title); + //设置自定义信息窗的内容 + tvTitle.setText("我是自定义信息窗口:"); + tvTitle.append("\n" + marker.getTitle()); + tvTitle.append("\n" + marker.getSnippet()); + return mCustomInfoWindowView; + } + }; + private boolean mMultEnable; + + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState, TencentMap pTencentMap) { + super.onCreate(savedInstanceState, pTencentMap); + mTencentMap = pTencentMap; + mMarker = createMarker(); + pTencentMap.setOnMarkerClickListener(new TencentMap.OnMarkerClickListener() { + @Override + public boolean onMarkerClick(Marker marker) { + invalidateOptionsMenu(); + return false; + } + }); + pTencentMap.setOnInfoWindowClickListener(new TencentMap.OnInfoWindowClickListener() { + @Override + public void onInfoWindowClick(Marker marker) { + Toast.makeText(getApplicationContext(), "信息窗被点击", Toast.LENGTH_SHORT).show(); + } + + @Override + public void onInfoWindowClickLocation(int i, int i1, int i2, int i3) { + Toast.makeText(getApplicationContext(), + "尺寸:" + i + "x" + i1 + " 位置:" + i2 + "," + i3, Toast.LENGTH_SHORT).show(); + } + }); + } + + private Marker createMarker() { + if (mTencentMap == null) { + return null; + } + if (mMarker != null) { + mMarker.remove(); + mMarker = null; + } + LatLng position = new LatLng(39.908710, 116.397499); + MarkerOptions options = new MarkerOptions(position); + options.infoWindowEnable(true);//默认为true + options.title("天安门")//标注的InfoWindow的标题 + .snippet("地址: 北京市东城区东长安街")//标注的InfoWindow的内容 + .anchor(0.5f, 1) + .viewInfoWindow(mInfoWindowType == TYPE_VIEW) + .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker));//设置自定义Marker图标 + mTencentMap.moveCamera(CameraUpdateFactory.newLatLngZoom(position, 15)); + return mTencentMap.addMarker(options); + } + + private Marker createMultMarker() { + if (mTencentMap == null) { + return null; + } + if (mAnotherMarker != null) { + mAnotherMarker.remove(); + mAnotherMarker = null; + } + LatLng position = new LatLng(39.902500,116.397750); + MarkerOptions options = new MarkerOptions(position); + options.infoWindowEnable(true);//默认为true + options.title("毛主席纪念堂")//标注的InfoWindow的标题 + .snippet("地址: 北京市东城区前门东大街11号")//标注的InfoWindow的内容 + .anchor(0.5f, 1) + .viewInfoWindow(mInfoWindowType == TYPE_VIEW) + .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker));//设置自定义Marker图标 + return mTencentMap.addMarker(options); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.infowindow, menu); + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + String typeName = null; + if (mInfoWindowType == TYPE_VIEW) { + typeName = "View类型"; + } else if (mInfoWindowType == TYPE_BITMAP) { + typeName = "Bitmap类型"; + } + if (typeName != null) { + menu.findItem(R.id.menu_type).setTitle(typeName) + .setVisible(!mMarker.isInfoWindowShown()); + } + menu.findItem(R.id.menu_mult).setTitle(mMultEnable ? "开启多窗口" : "关闭多窗口") + .setVisible(!mMarker.isInfoWindowShown()); + menu.findItem(R.id.menu_add).setVisible(!mMarker.isInfoWindowShown()); + menu.findItem(R.id.menu_play).setVisible(mMarker.isInfoWindowShown()); + menu.findItem(R.id.menu_delete).setVisible(mMarker.isInfoWindowShown()); + return super.onPrepareOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_mult_enable: + mMultEnable = true; + initMarkers(); + hideInfoWindow(); + break; + case R.id.menu_mult_close: + mMultEnable = false; + if (mAnotherMarker != null) { + mAnotherMarker.remove(); + mAnotherMarker = null; + } + + hideInfoWindow(); + break; + case R.id.menu_type_bitmap: + mInfoWindowType = TYPE_BITMAP; + initMarkers(); + hideInfoWindow(); + break; + case R.id.menu_type_view: + mInfoWindowType = TYPE_VIEW; + initMarkers(); + hideInfoWindow(); + break; + case R.id.menu_add_infowindow_default: + showInfoWindow(); + break; + case R.id.menu_add_infowindow_custom_1: + mInfoWindowAdapterStyle = STYLE_NO_FRAME; + mTencentMap.setInfoWindowAdapter(mInfoWindowAdapter); + showInfoWindow(); + break; + case R.id.menu_add_infowindow_custom_2: + mInfoWindowAdapterStyle = STYLE_FRAME; + mTencentMap.setInfoWindowAdapter(mInfoWindowAdapter); + showInfoWindow(); + break; + case R.id.menu_play: + animationPlay(); + break; + case R.id.menu_delete: + hideInfoWindow(); + break; + } + + mTencentMap.enableMultipleInfowindow(mMultEnable); + return super.onOptionsItemSelected(item); + } + + private void initMarkers() { + mMarker = createMarker(); + if (mMultEnable) { + mAnotherMarker = createMultMarker(); + } + } + + private void showInfoWindow() { + if (mMarker != null) { + mMarker.showInfoWindow(); + } + + if (mAnotherMarker != null && mMultEnable) { + mAnotherMarker.showInfoWindow(); + } + } + + private void hideInfoWindow() { + if (mMarker != null) { + mMarker.hideInfoWindow(); + } + + if (mAnotherMarker != null && mMultEnable) { + mAnotherMarker.hideInfoWindow(); + } + mTencentMap.setInfoWindowAdapter(null); + } + + private void animationPlay() { + + if (mInfoWindowType == TYPE_VIEW) { + //TODO :动画 + } + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerOptionsActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerOptionsActivity.java new file mode 100644 index 0000000..b4a17c7 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerOptionsActivity.java @@ -0,0 +1,54 @@ +package com.tencent.map.vector.demo.marker; + +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Matrix; +import android.os.Bundle; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; +import com.tencent.tencentmap.mapsdk.maps.model.CircleOptions; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; + +public class MarkerOptionsActivity extends SupportMapFragmentActivity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + options.fastLoad(true); //设置是否快速加载 + options.icon(BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.marker))); //加载图标 + options.tag(tencentMap.addCircle(new CircleOptions().center(new LatLng(39.984059, 116.305756)))); //设置标签对象 + tencentMap.addMarker(options); + } + + private LatLng latLng = new LatLng(39.984864, 116.305756); + + private Bitmap getBitMap(int resourceId){ + Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId); + int width = bitmap.getWidth(); + int height = bitmap.getHeight(); + int newWidth = 100; + int newHeight = 100; + float widthScale = ((float)newWidth)/width; + float heightScale = ((float)newHeight)/height; + Matrix matrix = new Matrix(); + matrix.postScale(widthScale, heightScale); + bitmap = Bitmap.createBitmap(bitmap,0,0,width,height,matrix,true); + return bitmap; + } + + + private MarkerOptions options = new MarkerOptions(latLng). //坐标设置 + anchor(0.5f, 0.5f). //标注的锚点 + clockwise(true). //旋转角度顺时针 + draggable(true). //标注可被拖动 + flat(true). //设置3D标注 + infoWindowEnable(true). //弹出infowindow + infoWindowAnchor(0.5f, 0.5f). //标注信息infowindow锚点 + rotation(90f). //旋转角度 + snippet("气泡infowindow内容"). //设置infowindow内容 + title("标题内容"). //infowindow标题内容 + visible(true). //标注是否可见 + zIndex(0); //堆叠顺序,越大优先级越高 +} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/PetalDrawable.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/PetalDrawable.java similarity index 95% rename from positions/src/main/java/cc/winboll/studio/positions/demo/marker/PetalDrawable.java rename to positions/src/main/java/com/tencent/map/vector/demo/marker/PetalDrawable.java index 5f83559..ad6a67e 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/marker/PetalDrawable.java +++ b/positions/src/main/java/com/tencent/map/vector/demo/marker/PetalDrawable.java @@ -1,4 +1,4 @@ -package cc.winboll.studio.positions.demo.marker; +package com.tencent.map.vector.demo.marker; import android.content.Context; import android.graphics.Bitmap; diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/SimpleMarkerActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/SimpleMarkerActivity.java new file mode 100644 index 0000000..aa0a96b --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/marker/SimpleMarkerActivity.java @@ -0,0 +1,107 @@ +package com.tencent.map.vector.demo.marker; + +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; + +import androidx.annotation.Nullable; + +import com.tencent.map.vector.demo.AbsMapActivity; +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.AlphaAnimation; +import com.tencent.tencentmap.mapsdk.maps.model.Animation; +import com.tencent.tencentmap.mapsdk.maps.model.AnimationListener; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.Marker; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; + +public class SimpleMarkerActivity extends AbsMapActivity { + + private TencentMap mTencentMap; + private Marker mSimpleMarker; + private Marker mCustomMarker; + + private boolean mMarkerAdded; + @Override + protected void onCreate(@Nullable Bundle savedInstanceState, TencentMap pTencentMap) { + super.onCreate(savedInstanceState, pTencentMap); + mTencentMap = pTencentMap; + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.simple_marker, menu); + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + menu.findItem(R.id.menu_add).setVisible(!mMarkerAdded); + menu.findItem(R.id.menu_delete).setVisible(mMarkerAdded); + return super.onPrepareOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_add_marker_simple: + if (mSimpleMarker == null) { + LatLng position = new LatLng(40.011313,116.391907); + mSimpleMarker = mTencentMap.addMarker(new MarkerOptions(position)); + mTencentMap.moveCamera(CameraUpdateFactory.newLatLng(position)); + mMarkerAdded = true; + } + break; + case R.id.menu_add_marker_custom: + + if (mCustomMarker == null) { + LatLng position = new LatLng(40.011313,116.391907); + BitmapDescriptor custom = BitmapDescriptorFactory.fromResource(R.drawable.marker); + mCustomMarker = mTencentMap.addMarker(new MarkerOptions(position) + .icon(custom) + .alpha(0.7f) + .flat(true) + .clockwise(false) + .rotation(30) + ); + + Animation animation = new AlphaAnimation(0.7f, 0f); + animation.setDuration(2000); + animation.setAnimationListener(new AnimationListener() { + @Override + public void onAnimationStart() { + + } + + @Override + public void onAnimationEnd() { + mCustomMarker.setAlpha(1); + } + }); + mCustomMarker.setAnimation(animation); + mCustomMarker.startAnimation(); + mTencentMap.moveCamera(CameraUpdateFactory.newLatLng(position)); + mMarkerAdded = true; + } + break; + case R.id.menu_delete: + if (mSimpleMarker != null) { + mSimpleMarker.remove(); + mSimpleMarker = null; + } + + if (mCustomMarker != null) { + mCustomMarker.remove(); + mCustomMarker = null; + } + + mMarkerAdded = false; + break; + } + return super.onOptionsItemSelected(item); + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/poi/PoiClickActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/poi/PoiClickActivity.java new file mode 100644 index 0000000..b73ac77 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/poi/PoiClickActivity.java @@ -0,0 +1,59 @@ +package com.tencent.map.vector.demo.poi; + +import android.os.Bundle; +import android.view.View; +import android.widget.CompoundButton; +import android.widget.Switch; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.MapPoi; +import com.tencent.tencentmap.mapsdk.maps.model.Marker; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; + +public class PoiClickActivity extends SupportMapFragmentActivity implements TencentMap.OnMapPoiClickListener { + private Switch poiSwitch; + private Marker marker; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + poiSwitch = findViewById(R.id.switch_poi); + poiSwitch.setVisibility(View.VISIBLE); + poiSwitch.setText("Poi显示"); + tencentMap.setOnMapPoiClickListener(this); + poiSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + if (b){ + tencentMap.setPoisEnabled(true); + }else{ + tencentMap.setPoisEnabled(false); + if (marker != null) + marker.remove(); + } + } + }); + } + + @Override + public void onClicked(MapPoi mapPoi) { + setMarker(mapPoi.getPosition(), mapPoi.getName()); + } + + /** + * 设置标注 + */ + private void setMarker(LatLng latLng, String name){ + + if(marker != null) + marker.remove(); + MarkerOptions options = new MarkerOptions().position(latLng); + //设置infowindow + options.title("地址:"); + options.snippet(name); + marker = tencentMap.addMarker(options); + marker.showInfoWindow(); + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/polygon/DrawPolygonActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/polygon/DrawPolygonActivity.java new file mode 100644 index 0000000..479d2c5 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/polygon/DrawPolygonActivity.java @@ -0,0 +1,38 @@ +package com.tencent.map.vector.demo.polygon; + +import android.os.Bundle; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.Polygon; +import com.tencent.tencentmap.mapsdk.maps.model.PolygonOptions; + +public class DrawPolygonActivity extends SupportMapFragmentActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + LatLng[] latLngs = { + new LatLng(39.984864, 116.305756), + new LatLng(39.983618, 116.305848), + new LatLng(39.982347, 116.305966), + new LatLng(39.982412, 116.308111), + new LatLng(39.984122, 116.308224), + new LatLng(39.984955, 116.308099), + new LatLng(39.984864, 116.305756) + }; + Polygon polygon = tencentMap.addPolygon(new PolygonOptions(). + add(latLngs). + fillColor(getResources().getColor(R.color.style)). + strokeColor(getResources().getColor(R.color.colorPrimary)). + strokeWidth(1)); + tencentMap.setOnPolygonClickListener(new TencentMap.OnPolygonClickListener() { + @Override + public void onPolygonClick(Polygon polygon, LatLng latLng) { + + } + }); + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/polygon/PolylonOptionsActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/polygon/PolylonOptionsActivity.java new file mode 100644 index 0000000..a47ccd4 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/polygon/PolylonOptionsActivity.java @@ -0,0 +1,73 @@ +package com.tencent.map.vector.demo.polygon; + +import android.os.Bundle; + +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; +import com.tencent.tencentmap.mapsdk.maps.model.Polygon; +import com.tencent.tencentmap.mapsdk.maps.model.PolygonOptions; + +import java.util.ArrayList; +import java.util.List; + +public class PolylonOptionsActivity extends SupportMapFragmentActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Polygon polygon = tencentMap.addPolygon(polygonOptions); + polygon.setPoints(transferArrayToList(latLngs)); //Options中设置顶点 + Polygon newPolygon = tencentMap.addPolygon(newPolygonOptions); + newPolygon.setOptions(newPolygonOptions); //重新设置Options + newPolygon.setClickable(true); //设置可点击 + newPolygon.setFillColor(0xaa324354); + newPolygon.setPoints(transferArrayToList(newLatLngs)); //设置坐标 + newPolygon.setTag(tencentMap.addMarker(new MarkerOptions().position(new LatLng(39.984866, 116.305759)).title("设置标注").draggable(true))); + + + } + + private List transferArrayToList(LatLng[] latLngs){ //坐标数组与List转换 + List list = new ArrayList<>(); + if (latLngs == null) + return list; + for (int i = 0; i < latLngs.length; i++) + list.add(latLngs[i]); + + return list; + + } + private LatLng[] latLngs = { + new LatLng(39.984864, 116.305756), + new LatLng(39.983618, 116.305848), + new LatLng(39.982347, 116.305966), + new LatLng(39.982412, 116.308111), + new LatLng(39.984122, 116.308224), + new LatLng(39.984955, 116.308099), + new LatLng(39.984864, 116.305756) + }; + + private LatLng[] newLatLngs = { + new LatLng(39.984864, 116.305756), + new LatLng(39.983618, 116.305848), + new LatLng(39.982347, 116.305966), + new LatLng(39.982412, 116.308111), + new LatLng(39.984122, 116.308224), + new LatLng(39.984955, 116.308099), + new LatLng(39.984864, 116.305756) + }; + + + private PolygonOptions polygonOptions = new PolygonOptions(). + add(latLngs). // 添加图形坐标点 + fillColor(0x56643313). //填充颜色 + strokeColor(0xfa349012). //描边颜色 + strokeWidth(1). //描边宽度 + visible(true). //是否可见 + zIndex(0). //堆叠顺序,越大优先级越高 + clickable(true); // 是否可点击 + + private PolygonOptions newPolygonOptions = new PolygonOptions(). + addAll(transferArrayToList(newLatLngs)); //设置批量添加顶点 +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/polygon/TileOverlayActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/polygon/TileOverlayActivity.java new file mode 100644 index 0000000..09544c6 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/polygon/TileOverlayActivity.java @@ -0,0 +1,178 @@ +package com.tencent.map.vector.demo.polygon; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; + +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.MapView; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerCollisionItem; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; +import com.tencent.tencentmap.mapsdk.maps.model.Tile; +import com.tencent.tencentmap.mapsdk.maps.model.TileOverlay; +import com.tencent.tencentmap.mapsdk.maps.model.TileOverlayOptions; +import com.tencent.tencentmap.mapsdk.maps.model.TileProvider; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + +public class TileOverlayActivity extends AppCompatActivity { + private MapView mapView; + private TencentMap tencentMap; + private boolean mMarkerAdded; + private TileOverlay mTileOverlay; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_tile_overlay); + initView(); + } + + private void initView() { + mapView = findViewById(R.id.mapView); + tencentMap = mapView.getMap(); + CameraUpdate cameraSigma = + CameraUpdateFactory.newCameraPosition(new CameraPosition( + new LatLng(39.917505, 116.397657), + 15, + 0f, + 0f)); + //移动地图 + tencentMap.moveCamera(cameraSigma); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.markercol, menu); + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + menu.findItem(R.id.menu_open_collisionsmap).setVisible(!mMarkerAdded); + menu.findItem(R.id.menu_close_collisionsmap).setVisible(mMarkerAdded); + return super.onPrepareOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(@NonNull MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_open_collisionsmap: + mMarkerAdded = true; + if (mTileOverlay == null) { + mTileOverlay = tencentMap.addTileOverlay( + new TileOverlayOptions(). + tileProvider(new LocalTileProvider())); + } + + break; + case R.id.menu_close_collisionsmap: + mMarkerAdded = false; + if (mTileOverlay != null) { + mTileOverlay.clearTileCache(); + mTileOverlay.remove(); + mTileOverlay = null; + } + break; + } + + supportInvalidateOptionsMenu(); + return super.onOptionsItemSelected(item); + } + + class LocalTileProvider implements TileProvider { + + @Override + public Tile getTile(int x, int y, int zoom) { + LatLng latLng = new LatLng(39.917505, 116.397657); + int iZ = 16; + double n = Math.pow(2, iZ); + int iX = (int) (((latLng.getLongitude() + 180) / 360) * n); + int iY = (int) ((1 - (Math.log(Math.tan(Math.toRadians(latLng.getLatitude())) + + (1 / Math.cos(Math.toRadians(latLng.getLatitude())))) / Math.PI)) / 2 * n); + if (iX == x && iY == y && iZ == zoom) { + Log.e("tile", "zoom:" + zoom + " x:" + x + " y:" + y); + return new Tile(256, 256, tileData()); + } + return TileProvider.NO_TILE; + } + + byte[] tileData() { + InputStream is = null; + ByteArrayOutputStream baos = null; + try { + is = getApplicationContext().getAssets().open("gugong.jpg"); + baos = new ByteArrayOutputStream(); + byte[] byteBuffer = new byte[1024]; + int count = 0; + while ((count = is.read(byteBuffer)) != -1) { + baos.write(byteBuffer, 0, count); + } + return baos.toByteArray(); + } catch (IOException e) { + e.printStackTrace(); + return null; + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (baos != null) { + try { + baos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + } + + @Override + protected void onResume() { + super.onResume(); + mapView.onResume(); + } + + @Override + protected void onPause() { + super.onPause(); + mapView.onPause(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mapView.onDestroy(); + } + + + @Override + protected void onStart() { + super.onStart(); + mapView.onStart(); + } + + @Override + protected void onStop() { + super.onStop(); + mapView.onStop(); + } +} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/polyline/DrawLineActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/polyline/DrawLineActivity.java new file mode 100644 index 0000000..1783595 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/polyline/DrawLineActivity.java @@ -0,0 +1,194 @@ +package com.tencent.map.vector.demo.polyline; + +import android.graphics.Color; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; + +import androidx.annotation.Nullable; + +import com.tencent.map.vector.demo.AbsMapActivity; +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.Polyline; +import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; + +import java.util.ArrayList; +import java.util.List; + +public class DrawLineActivity extends AbsMapActivity { + private int typeSimple = 0; + private int typeImage = 1; + private int typeColor = 2; + private int typeArrow = 3; + private int typeGradient = 4; + + private TencentMap mTencentMap; + private boolean mHasAdded; + private boolean mHasEnableText; + private Polyline polyline; + private PolylineOptions.Text mPolylineText; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState, TencentMap tencentMap) { + super.onCreate(savedInstanceState, tencentMap); + mTencentMap = tencentMap; + tencentMap.moveCamera(CameraUpdateFactory.zoomTo(15)); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.polyline, menu); + return true; + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + menu.findItem(R.id.menu_add).setVisible(!mHasAdded); + menu.findItem(R.id.menu_text).setTitle(mHasEnableText ? "关闭路名" : "开启路名").setVisible(mHasAdded); + menu.findItem(R.id.menu_delete).setVisible(mHasAdded); + return super.onPrepareOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_add_line_simple: + mTencentMap.clear(); + polyline = mTencentMap.addPolyline(setLineStyle(typeSimple)); + mHasAdded = true; + break; + + case R.id.menu_add_line_dash: + mTencentMap.clear(); + polyline = mTencentMap.addPolyline(setLineStyle(typeImage)); + mHasAdded = true; + break; + case R.id.menu_add_line_segment: + mTencentMap.clear(); + polyline = mTencentMap.addPolyline(setLineStyle(typeColor)); + int[] color = {0, 1, 2, 3, 4}; + int[] index = {0, 1, 2, 3, 4, 5}; + polyline.setColors(color, index); + mHasAdded = true; + break; + case R.id.menu_add_line_texture: + mTencentMap.clear(); + polyline = mTencentMap.addPolyline(setLineStyle((typeArrow))); + mHasAdded = true; + break; + case R.id.menu_add_line_gradient: + mTencentMap.clear(); + polyline = mTencentMap.addPolyline(setLineStyle((typeGradient))); + int[] indexes = {0, 1, 2, 3, 4}; +// 设置每段索引之间的颜色,这个颜色同样支持纹理颜色,即 PolylineOptions.Colors 中定义的 [0, 10] 值 + int[] colors = { + 0xff00ff00, // 线上点 [0, 1] 之间为绿色 + 0xffffff00, // 线上点 [1, 2] 之间为黄色 + 0xffff0000, // 线上点 [2, 3] 之间为红色 + 0xff131313, // 线上点 [3, 4] 之间为黄色 + 0xff1033f6 // 线上点 [4, 最后一个点] 之间为绿色 + }; + polyline.setColors(colors, indexes); + mHasAdded = true; + break; + case R.id.menu_text: + mHasEnableText = !mHasEnableText; + if (mHasEnableText) { + if (mPolylineText == null) { + mPolylineText = generateText(); + //设置显示优先级,可选项有HIGH或NORMAL + mPolylineText.setPriority(PolylineOptions.TextPriority.HIGH); + //设置字体大小 + mPolylineText.setTextSize(10); + //设置填充颜色 + mPolylineText.setStrokeColor(Color.WHITE); + //设置文字颜色 + mPolylineText.setTextColor(Color.BLACK); + } + + polyline.setText(mPolylineText); + } else { + polyline.setText(null); + } + + break; + + case R.id.menu_delete: + if (polyline != null) { + polyline.remove(); + polyline = null; + mHasAdded = false; + mHasEnableText = false; + + } + break; + } + return super.onOptionsItemSelected(item); + } + + private PolylineOptions setLineStyle(int type) { + PolylineOptions polylineOptions = new PolylineOptions().addAll(getLatlons()).lineCap(true); + switch (type) { + case 0: + //设置折线颜色、宽度 + polylineOptions + .color(0xff00ff00) + .width(5f); + break; + case 1: + List list = new ArrayList<>(); + list.add(35); + list.add(20); + polylineOptions + .lineType(PolylineOptions.LineType.LINE_TYPE_IMAGEINARYLINE) + .width(10) + .pattern(list); + break; + case 2: + //线路颜色值纹理图片里的颜色索引 + polylineOptions + .colorType(PolylineOptions.ColorType.LINE_COLOR_TEXTURE) + .color(PolylineOptions.Colors.GREEN) + .colorTexture(BitmapDescriptorFactory.fromAsset("color_texture.png")); + break; + case 3: + polylineOptions + .arrow(true) + .arrowSpacing(30) + .arrowTexture(BitmapDescriptorFactory.fromAsset("color_arrow_texture.png")); + break; + case 4: + polylineOptions + .gradient(true) + .lineType(PolylineOptions.LineType.LINE_TYPE_MULTICOLORLINE) + .width(20); + break; + + } + return polylineOptions; + } + + private PolylineOptions.Text generateText() { + List segmentTexts = new ArrayList<>(); + //参数分别表示坐标路径数组起点index,终点index,动态路名文字 + segmentTexts.add(new PolylineOptions.SegmentText(0, 1, "苏州街")); + segmentTexts.add(new PolylineOptions.SegmentText(1, 2, "北四环西路辅路")); + segmentTexts.add(new PolylineOptions.SegmentText(2, 4, "彩和坊路")); + return new PolylineOptions.Text.Builder(segmentTexts).build(); + } + + private List getLatlons() { + List latLngs = new ArrayList(); + latLngs.add(new LatLng(39.984864, 116.305756)); + latLngs.add(new LatLng(39.983618, 116.305848)); + latLngs.add(new LatLng(39.982347, 116.305966)); + latLngs.add(new LatLng(39.982412, 116.308111)); + latLngs.add(new LatLng(39.984122, 116.308224)); + latLngs.add(new LatLng(39.984955, 116.308099)); + return latLngs; + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/polyline/LineTextActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/polyline/LineTextActivity.java new file mode 100644 index 0000000..1fda4de --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/polyline/LineTextActivity.java @@ -0,0 +1,132 @@ +package com.tencent.map.vector.demo.polyline; + +import android.graphics.Color; +import android.os.Bundle; +import android.view.View; +import android.widget.CompoundButton; +import android.widget.Switch; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.Polyline; +import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; + +import java.util.ArrayList; +import java.util.List; + +public class LineTextActivity extends SupportMapFragmentActivity { + private Polyline polyline; + private static List mPoints = new ArrayList<>(); + private Switch switch_style; + private Switch switch_off; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + initView(); + tencentMap.moveCamera(CameraUpdateFactory.zoomTo(16)); + switch_style.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + if (polyline == null) { + return; + } + + PolylineOptions.Text text = polyline.getText(); + removeText(); + if (checked) { + //设置显示优先级,可选项有HIGH或NORMAL + text.setPriority(PolylineOptions.TextPriority.HIGH); + //设置字体大小 + text.setTextSize(10); + //设置填充颜色 + text.setStrokeColor(Color.WHITE); + //设置文字颜色 + text.setTextColor(Color.BLACK); + } else { + //设置显示优先级,可选项有HIGH或NORMAL + text.setPriority(PolylineOptions.TextPriority.NORMAL); + //设置字体大小 + text.setTextSize(8); + //设置填充颜色 + text.setStrokeColor(Color.WHITE); + //设置文字颜色 + text.setTextColor(Color.GRAY); + + } + + polyline.setText(text); + } + }); + + switch_off.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + if (checked) { + polyline = createLineWithText(); + } else { + removeText(); + polyline.remove(); + polyline = null; + } + } + }); + } + + + private void initView() { + //文字 + switch_style = (Switch) findViewById(R.id.switch_style); + switch_style.setVisibility(View.VISIBLE); + switch_off = (Switch) findViewById(R.id.switch_off); + switch_off.setVisibility(View.VISIBLE); + } + + public Polyline addLine() { + Polyline polyline = tencentMap.addPolyline(new PolylineOptions().addAll(mPoints).color(0x22ff0000)); + + return polyline; + } + + + //生成坐标点路径 + private List generateLatLngs() { + if (mPoints.size() != 0) + mPoints = new ArrayList<>(); + //苏州街 + mPoints.add(new LatLng(39.982382, 116.305883)); + //北四环西路辅路 + mPoints.add(new LatLng(39.984914, 116.305690)); + //彩和坊路 + mPoints.add(new LatLng(39.985045, 116.308136)); + mPoints.add(new LatLng(39.983570, 116.308088)); + mPoints.add(new LatLng(39.980063, 116.308297)); + return mPoints; + } + + private PolylineOptions.Text generateText() { + List segmentTexts = new ArrayList<>(); + //参数分别表示坐标路径数组起点index,终点index,动态路名文字 + segmentTexts.add(new PolylineOptions.SegmentText(0, 1, "苏州街")); + segmentTexts.add(new PolylineOptions.SegmentText(1, 2, "北四环西路辅路")); + segmentTexts.add(new PolylineOptions.SegmentText(2, 4, "彩和坊路")); + + return new PolylineOptions.Text.Builder(segmentTexts).build(); + } + + + private Polyline createLineWithText() { + Polyline polyline = tencentMap.addPolyline(new PolylineOptions().addAll(generateLatLngs()).text(generateText())); + PolylineOptions.Text text = polyline.getText(); + return polyline; + } + + + private void removeText() { + polyline.setText(null); + } + +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/polyline/MutablePolylineActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/polyline/MutablePolylineActivity.java new file mode 100644 index 0000000..678ce1d --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/polyline/MutablePolylineActivity.java @@ -0,0 +1,291 @@ +package com.tencent.map.vector.demo.polyline; + +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.view.Menu; +import android.view.MenuItem; +import android.view.SubMenu; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.Polyline; +import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; + +import java.util.ArrayList; +import java.util.List; + +import androidx.annotation.NonNull; + +/** + * @version v1.0 + * @since 2020/6/11 + */ +public class MutablePolylineActivity extends SupportMapFragmentActivity { + private boolean mIsAdd; + private Polyline mPolyline; + + private final static Object[][] sData = { + {"更新1"}, + {"更新2"}, + {"重置"}, + {"删除"}, + }; + + private List mAppendPoints = new ArrayList<>(); + private int mAppendIndex; + + private Handler sHandler = new Handler(Looper.getMainLooper()) { + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + + if (msg.what == 1 && mPolyline != null && mAppendIndex < mAppendPoints.size()) { + mPolyline.appendPoint(mAppendPoints.get(mAppendIndex)); + mAppendIndex++; + + sendEmptyMessageDelayed(1, 300); + } + } + }; + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_polyline_items, menu); + + MenuItem actionMenu = menu.findItem(R.id.menu_actions); + SubMenu actionSubMenu = actionMenu.getSubMenu(); + + for (int i = 0; i < sData.length; i++) { + Object[] indoor = sData[i]; + actionSubMenu.add(0, i, 0, String.valueOf(indoor[0])); + } + return true; + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + menu.findItem(R.id.menu_actions).setVisible(mIsAdd); + return super.onPrepareOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(@NonNull MenuItem item) { + + int itemId = item.getItemId(); + + if (mPolyline != null && itemId >= 0 && itemId < sData.length) { + if (itemId == 3) { + mPolyline.remove(); + mIsAdd = false; + mAppendIndex = 0; + invalidateOptionsMenu(); + } else if (itemId == 2) { + mPolyline.setPoints(getPoints(itemId)); + } else { + mPolyline.appendPoints(getPoints(itemId)); + } + return true; + } + + List pattern = new ArrayList<>(); + pattern.add(35); + pattern.add(20); + + PolylineOptions options = new PolylineOptions() + .addAll(getCreatePoints()) + .width(15); + + switch (item.getItemId()) { + case R.id.menu_add: + if (mIsAdd) { + break; + } + mIsAdd = true; + mPolyline = tencentMap.addPolyline(options); + break; + case R.id.menu_add_anim: + if (mIsAdd) { + break; + } + mIsAdd = true; + + mPolyline = tencentMap.addPolyline(options); + + sHandler.sendEmptyMessage(1); + break; + + } + invalidateOptionsMenu(); + return super.onOptionsItemSelected(item); + } + + private static List getCreatePoints() { + List listPoints = new ArrayList<>(); + addLine(listPoints); + return listPoints; + } + + private static List getPoints(int itemId) { + List listPoints = new ArrayList(); + if (itemId == 0) { + addLine1(listPoints); + } else if (itemId == 1) { + addLine2(listPoints); + } else if (itemId == 2) { + addLine(listPoints); + } + + return listPoints; + } + + private static void addLine(List listPoints) { + listPoints.add(new LatLng(39.981787, 116.306649)); + listPoints.add(new LatLng(39.982021, 116.306739)); + listPoints.add(new LatLng(39.982351, 116.306883)); + listPoints.add(new LatLng(39.98233, 116.306047)); + listPoints.add(new LatLng(39.982324, 116.305867)); + listPoints.add(new LatLng(39.981918, 116.305885)); + listPoints.add(new LatLng(39.981298, 116.305921)); + listPoints.add(new LatLng(39.981091, 116.305939)); + listPoints.add(new LatLng(39.980506, 116.305975)); + listPoints.add(new LatLng(39.980148, 116.306002)); + listPoints.add(new LatLng(39.980121, 116.306002)); + listPoints.add(new LatLng(39.979708, 116.306038)); + listPoints.add(new LatLng(39.979205, 116.306074)); + listPoints.add(new LatLng(39.979205, 116.306074)); + listPoints.add(new LatLng(39.978813, 116.306101)); + listPoints.add(new LatLng(39.978015, 116.306182)); + listPoints.add(new LatLng(39.977299, 116.306227)); + listPoints.add(new LatLng(39.976996, 116.306245)); + listPoints.add(new LatLng(39.976913, 116.306245)); + listPoints.add(new LatLng(39.97597, 116.306308)); + listPoints.add(new LatLng(39.97575, 116.306326)); + listPoints.add(new LatLng(39.97564, 116.306335)); + listPoints.add(new LatLng(39.975178, 116.306371)); + listPoints.add(new LatLng(39.975185, 116.306514)); + listPoints.add(new LatLng(39.97564, 116.306272)); + listPoints.add(new LatLng(39.975633, 116.306272)); + listPoints.add(new LatLng(39.975715, 116.307997)); + listPoints.add(new LatLng(39.975819, 116.311545)); + listPoints.add(new LatLng(39.975936, 116.314878)); + listPoints.add(new LatLng(39.975998, 116.317528)); + listPoints.add(new LatLng(39.976025, 116.318785)); + listPoints.add(new LatLng(39.976108, 116.321714)); + listPoints.add(new LatLng(39.976259, 116.326843)); + listPoints.add(new LatLng(39.976328, 116.328622)); + listPoints.add(new LatLng(39.976397, 116.330356)); + listPoints.add(new LatLng(39.9765, 116.333967)); + listPoints.add(new LatLng(39.976459, 116.341019)); + listPoints.add(new LatLng(39.976473, 116.341674)); + listPoints.add(new LatLng(39.976473, 116.341944)); + listPoints.add(new LatLng(39.976473, 116.342546)); + listPoints.add(new LatLng(39.976479, 116.345295)); + listPoints.add(new LatLng(39.976197, 116.353829)); + listPoints.add(new LatLng(39.976459, 116.369926)); + listPoints.add(new LatLng(39.97672, 116.381353)); + } + + private static void addLine2(List listPoints) { + listPoints.add(new LatLng(39.91254, 116.41786)); + listPoints.add(new LatLng(39.911258, 116.417905)); + listPoints.add(new LatLng(39.910459, 116.417923)); + listPoints.add(new LatLng(39.908557, 116.418049)); + listPoints.add(new LatLng(39.908337, 116.418058)); + listPoints.add(new LatLng(39.90824, 116.418067)); + listPoints.add(new LatLng(39.90669, 116.418148)); + listPoints.add(new LatLng(39.904795, 116.418283)); + listPoints.add(new LatLng(39.903416, 116.418265)); + listPoints.add(new LatLng(39.901218, 116.418408)); + listPoints.add(new LatLng(39.900805, 116.418417)); + listPoints.add(new LatLng(39.900805, 116.418426)); + listPoints.add(new LatLng(39.901335, 116.417968)); + listPoints.add(new LatLng(39.901342, 116.417968)); + listPoints.add(new LatLng(39.901342, 116.418004)); + listPoints.add(new LatLng(39.901197, 116.418193)); + listPoints.add(new LatLng(39.901204, 116.418426)); + listPoints.add(new LatLng(39.901218, 116.418552)); + listPoints.add(new LatLng(39.901087, 116.418624)); + listPoints.add(new LatLng(39.901053, 116.41884)); + listPoints.add(new LatLng(39.901004, 116.419028)); + listPoints.add(new LatLng(39.900922, 116.419388)); + listPoints.add(new LatLng(39.900839, 116.419774)); + listPoints.add(new LatLng(39.900749, 116.420043)); + listPoints.add(new LatLng(39.900722, 116.420178)); + listPoints.add(new LatLng(39.900667, 116.42034)); + listPoints.add(new LatLng(39.900619, 116.420519)); + listPoints.add(new LatLng(39.900557, 116.420744)); + listPoints.add(new LatLng(39.900515, 116.420915)); + listPoints.add(new LatLng(39.900488, 116.421067)); + listPoints.add(new LatLng(39.900467, 116.421274)); + listPoints.add(new LatLng(39.900467, 116.421301)); + listPoints.add(new LatLng(39.900467, 116.421301)); + listPoints.add(new LatLng(39.900674, 116.428856)); + listPoints.add(new LatLng(39.900681, 116.429287)); + listPoints.add(new LatLng(39.900674, 116.429287)); + listPoints.add(new LatLng(39.900694, 116.429745)); + listPoints.add(new LatLng(39.900736, 116.43173)); + listPoints.add(new LatLng(39.900729, 116.433132)); + listPoints.add(new LatLng(39.900729, 116.433267)); + listPoints.add(new LatLng(39.900743, 116.433545)); + } + + private static void addLine1(List listPoints) { + listPoints.add(new LatLng(39.976748, 116.382314)); + listPoints.add(new LatLng(39.976851, 116.388045)); + listPoints.add(new LatLng(39.976892, 116.393597)); + listPoints.add(new LatLng(39.976906, 116.394199)); + listPoints.add(new LatLng(39.976906, 116.394298)); + listPoints.add(new LatLng(39.976996, 116.405949)); + listPoints.add(new LatLng(39.977016, 116.407692)); + listPoints.add(new LatLng(39.97701, 116.417564)); + listPoints.add(new LatLng(39.97701, 116.417564)); + listPoints.add(new LatLng(39.977127, 116.417591)); + listPoints.add(new LatLng(39.977127, 116.417582)); + listPoints.add(new LatLng(39.969017, 116.417932)); + listPoints.add(new LatLng(39.968549, 116.417977)); + listPoints.add(new LatLng(39.9666, 116.418094)); + listPoints.add(new LatLng(39.965099, 116.418193)); + listPoints.add(new LatLng(39.963957, 116.418256)); + listPoints.add(new LatLng(39.961533, 116.418301)); + listPoints.add(new LatLng(39.959343, 116.418301)); + listPoints.add(new LatLng(39.95422, 116.418732)); + listPoints.add(new LatLng(39.952375, 116.418858)); + listPoints.add(new LatLng(39.952106, 116.418876)); + listPoints.add(new LatLng(39.95192, 116.418849)); + listPoints.add(new LatLng(39.951693, 116.418696)); + listPoints.add(new LatLng(39.951528, 116.418525)); + listPoints.add(new LatLng(39.951383, 116.41822)); + listPoints.add(new LatLng(39.95128, 116.417941)); + listPoints.add(new LatLng(39.951239, 116.417609)); + listPoints.add(new LatLng(39.951218, 116.417312)); + listPoints.add(new LatLng(39.951218, 116.417088)); + listPoints.add(new LatLng(39.951197, 116.416899)); + listPoints.add(new LatLng(39.951115, 116.416675)); + listPoints.add(new LatLng(39.950984, 116.416513)); + listPoints.add(new LatLng(39.950839, 116.416378)); + listPoints.add(new LatLng(39.950639, 116.41627)); + listPoints.add(new LatLng(39.950426, 116.416217)); + listPoints.add(new LatLng(39.950095, 116.416243)); + listPoints.add(new LatLng(39.948835, 116.416486)); + listPoints.add(new LatLng(39.948697, 116.416486)); + listPoints.add(new LatLng(39.945557, 116.416648)); + listPoints.add(new LatLng(39.941686, 116.416791)); + listPoints.add(new LatLng(39.941005, 116.4168)); + listPoints.add(new LatLng(39.938442, 116.416944)); + listPoints.add(new LatLng(39.936045, 116.417016)); + listPoints.add(new LatLng(39.933662, 116.417142)); + listPoints.add(new LatLng(39.929247, 116.417295)); + listPoints.add(new LatLng(39.927683, 116.417393)); + listPoints.add(new LatLng(39.926553, 116.417438)); + listPoints.add(new LatLng(39.924583, 116.417492)); + listPoints.add(new LatLng(39.924369, 116.417492)); + listPoints.add(new LatLng(39.921779, 116.417573)); + listPoints.add(new LatLng(39.919044, 116.417654)); + listPoints.add(new LatLng(39.917404, 116.417708)); + listPoints.add(new LatLng(39.917287, 116.417717)); + listPoints.add(new LatLng(39.916233, 116.417825)); + listPoints.add(new LatLng(39.913904, 116.417807)); + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/polyline/PolylineOptionsActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/polyline/PolylineOptionsActivity.java new file mode 100644 index 0000000..8e953e5 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/polyline/PolylineOptionsActivity.java @@ -0,0 +1,87 @@ +package com.tencent.map.vector.demo.polyline; + +import android.os.Bundle; + +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.Polyline; +import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; + +import java.util.ArrayList; +import java.util.List; + +public class PolylineOptionsActivity extends SupportMapFragmentActivity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Polyline polyline = tencentMap.addPolyline(polylineOptions); + Polyline newPolyline = tencentMap.addPolyline(newPolylineOptions); + polyline.pattern(patternLine(patterns)); //设置虚线样式 + } + + private int[] patterns = {10, 15, 20}; + private List patternLine(int [] patterns){ + List patternLine = new ArrayList<>(); + if (patterns == null) + return patternLine; + for (int i = 0; i < patterns.length; i++) + patternLine.add(patterns[i]); + return patternLine; + } + + + private List transferArrayToList(LatLng[] latLngs){ //坐标数组与List转换 + List list = new ArrayList<>(); + if (latLngs == null) + return list; + for (int i = 0; i < latLngs.length; i++) + list.add(latLngs[i]); + + return list; + + } + + private LatLng[] latLngs = { + new LatLng(39.984864, 116.305756), + new LatLng(39.983618, 116.305848), + new LatLng(39.982347, 116.305966), + new LatLng(39.982412, 116.308111), + new LatLng(39.984122, 116.308224), + new LatLng(39.984955, 116.308099), + new LatLng(39.984864, 116.305756) + }; + + private LatLng[] newLatLngs = { + new LatLng(39.984864, 116.305756), + new LatLng(39.983618, 116.305848), + new LatLng(39.982347, 116.305966), + new LatLng(39.982412, 116.308111), + new LatLng(39.984122, 116.308224), + new LatLng(39.984955, 116.308099), + new LatLng(39.984864, 116.305756) + }; + private PolylineOptions polylineOptions = new PolylineOptions(). + addAll(transferArrayToList(latLngs)). //添加顶点 + alpha(0.5f). //设置透明度 + arrow(true). //导航用 接口 + arrowSpacing(110). // 设置方向箭头间距 + arrowTexture(BitmapDescriptorFactory.fromAsset("color_arrow_texture.png")). // 设置箭头纹理 + borderColor(0xaa323456). //设置描边颜色 + borderWidth(1f). //设置描边宽度 + clickable(true). //可点击 + color(PolylineOptions.Colors.LIGHT_BLUE). //线的颜色 + colorTexture(BitmapDescriptorFactory.fromAsset("color_texture.png")). //颜色纹理 + lineCap(true). //路线是否显示半圆端点 + lineType(PolylineOptions.LineType.LINE_TYPE_MULTICOLORLINE). //设置线的类型 + visible(true). //设置折线可见性 + width(10f). //设置线的宽度 + zIndex(0); //堆叠顺序,越大优先级越高 + + + private PolylineOptions newPolylineOptions = new PolylineOptions().add(newLatLngs). + lineType(PolylineOptions.LineType.LINE_TYPE_DOTTEDLINE). + visible(true). + pattern(patternLine(patterns)). + zIndex(1); +} diff --git a/positions/src/main/java/cc/winboll/studio/positions/demo/search/CoordianteTransferActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/search/CoordianteTransferActivity.java similarity index 96% rename from positions/src/main/java/cc/winboll/studio/positions/demo/search/CoordianteTransferActivity.java rename to positions/src/main/java/com/tencent/map/vector/demo/search/CoordianteTransferActivity.java index 9c9face..6adef05 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/demo/search/CoordianteTransferActivity.java +++ b/positions/src/main/java/com/tencent/map/vector/demo/search/CoordianteTransferActivity.java @@ -1,4 +1,4 @@ -//package cc.winboll.studio.positions.demo.search; +//package com.tencent.map.vector.demo.search; // //import android.content.Context; //import android.os.Bundle; @@ -7,7 +7,7 @@ //import android.widget.Toast; // //import cc.winboll.studio.positions.R; -//import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity; +//import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; //import com.tencent.lbssearch.TencentSearch; //import com.tencent.lbssearch.httpresponse.BaseObject; //import com.tencent.lbssearch.httpresponse.HttpResponseListener; diff --git a/positions/src/main/java/com/tencent/map/vector/demo/search/DistrictActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/search/DistrictActivity.java new file mode 100644 index 0000000..209455b --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/search/DistrictActivity.java @@ -0,0 +1,174 @@ +package com.tencent.map.vector.demo.search; + +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Spinner; +import android.widget.TextView; +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.lbssearch.TencentSearch; +import com.tencent.lbssearch.httpresponse.BaseObject; +import com.tencent.lbssearch.httpresponse.HttpResponseListener; +import com.tencent.lbssearch.object.param.DistrictChildrenParam; +import com.tencent.lbssearch.object.result.DistrictResultObject; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import java.util.ArrayList; +import java.util.List; + +public class DistrictActivity extends SupportMapFragmentActivity { + private Spinner spProvince; + private Spinner spCity; + private Spinner spDistrict; + private TextView tvResult; + private List latLngs = new ArrayList<>(); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + initView(); + initSpinner(); + } + + protected void initView() { + spProvince = (Spinner) findViewById(R.id.sp_province); + spCity = (Spinner) findViewById(R.id.sp_city); + spDistrict = (Spinner) findViewById(R.id.sp_district); + tvResult = (TextView) findViewById(R.id.tv_result); + spProvince.setVisibility(View.VISIBLE); + spCity.setVisibility(View.VISIBLE); + spDistrict.setVisibility(View.VISIBLE); + tvResult.setVisibility(View.VISIBLE); + } + + protected void initSpinner() { + + //初始化行政区划,像北京市等只有市和区两级的数据,可能会输出错误id + getDistrict(0, R.id.sp_province); + AdapterView.OnItemSelectedListener onItemSelectedListener = new AdapterView.OnItemSelectedListener() { + + @Override + public void onItemSelected(AdapterView parent, View view, + int position, long id) { + // TODO Auto-generated method stub + switch (parent.getId()) { + case R.id.sp_province: + getDistrict(((List) parent.getTag()). + get(position).intValue(), R.id.sp_city); + break; + case R.id.sp_city: + getDistrict(((List) parent.getTag()). + get(position).intValue(), R.id.sp_district); + break; + case R.id.sp_district: + getDistrict(((List) parent.getTag()). + get(position).intValue(), R.id.sp_district); + tencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(latLngs.get(position), 15f, 0, 0))); + default: + break; + } + } + + @Override + public void onNothingSelected(AdapterView parent) { + // TODO Auto-generated method stub + + } + }; + spProvince.setOnItemSelectedListener(onItemSelectedListener); + spCity.setOnItemSelectedListener(onItemSelectedListener); + spDistrict.setOnItemSelectedListener(onItemSelectedListener); + } + + /** + * 获取行政区划 + */ + protected void getDistrict(int pDistrict, final int spId) { + TencentSearch tencentSearch = new TencentSearch(this); + DistrictChildrenParam districtChildrenParam = new DistrictChildrenParam(); + Log.d("eqrwqeqewr", "getDistrict: " + spId); + //如果不设置id,则获取全部数据 + if (spId != R.id.sp_province && spId == R.id.sp_city) { + districtChildrenParam.id(pDistrict); + } + if (spId != R.id.sp_province && spId != R.id.sp_city) { + districtChildrenParam.id(pDistrict); + } + + tencentSearch.getDistrictChildren(districtChildrenParam, new HttpResponseListener() { + + @Override + public void onSuccess(int arg0, BaseObject arg1) { + // TODO Auto-generated method stub + if (arg1 == null) { + return; + } + DistrictResultObject obj = (DistrictResultObject) arg1; + switch (spId) { + case R.id.sp_province: + setDistrictAdapter(spProvince, obj); + break; + case R.id.sp_city: + setDistrictAdapter(spCity, obj); + break; + case R.id.sp_district: + setDistrictAdapter(spDistrict, obj); + break; + + default: + break; + } + } + + @Override + public void onFailure(int arg0, String arg1, Throwable arg2) { + // TODO Auto-generated method stub + // printResult(arg1); + } + }); + } + + /** + * 设置行政区划的adapter + * + * @param spinner 要设置adapter的spinner + * @param obj 用于填充adapter的数据源 + */ + protected void setDistrictAdapter(Spinner spinner, final DistrictResultObject obj) { + List names = new ArrayList(); + List ids = new ArrayList(); + latLngs.clear(); + final List districtResults = obj.result.get(0); + for (final DistrictResultObject.DistrictResult result : districtResults) { + names.add(result.fullname); + ids.add(result.id); + latLngs.add(result.latLng); + Log.d("位置", "setDistrictAdapter: " + result.fullname); + + } + ArrayAdapter adapter = new ArrayAdapter(this, + android.R.layout.simple_spinner_item, names); + spinner.setAdapter(adapter); + //将行政区划编码附到spinner方便后续查询 + spinner.setTag(ids); + + } + + + protected void printResult(final String result) { + runOnUiThread(new Runnable() { + + @Override + public void run() { + // TODO Auto-generated method stub + tvResult.setText(result); + } + }); + } + +} + diff --git a/positions/src/main/java/com/tencent/map/vector/demo/search/DrivingRouteActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/search/DrivingRouteActivity.java new file mode 100644 index 0000000..a2ce36a --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/search/DrivingRouteActivity.java @@ -0,0 +1,75 @@ +package com.tencent.map.vector.demo.search; + +import android.os.Bundle; +import android.util.Log; + +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.lbssearch.TencentSearch; +import com.tencent.lbssearch.httpresponse.HttpResponseListener; +import com.tencent.lbssearch.object.param.DrivingParam; +import com.tencent.lbssearch.object.result.DrivingResultObject; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds; +import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; + +import java.util.List; + +public class DrivingRouteActivity extends SupportMapFragmentActivity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + CameraUpdate cameraSigma = + CameraUpdateFactory.newCameraPosition(new CameraPosition( + new LatLng(24.66493, 117.09568), + 15, + 0f, + 0f)); + //移动地图 + tencentMap.moveCamera(cameraSigma); + getDrivingRoute(); + } + + private LatLng fromPoint = new LatLng(24.66493, 117.09568); // 起点坐标 + private LatLng toPoint = new LatLng(26.8857, 120.00514); //终点坐标 + + /** + * 获取驾车路线规划 + */ + private void getDrivingRoute() { + long l = (System.currentTimeMillis() / 1000)+1000; + Log.d("时间戳", "getDrivingRoute: " + l); + DrivingParam drivingParam = new DrivingParam(fromPoint, toPoint); //创建导航参数 + drivingParam.roadType(DrivingParam.RoadType.ON_MAIN_ROAD_BELOW_BRIDGE); + drivingParam.heading(90); + drivingParam.accuracy(30); + //drivingParam.departureTime(l) + TencentSearch tencentSearch = new TencentSearch(this); + tencentSearch.getRoutePlan(drivingParam, new HttpResponseListener() { + + @Override + public void onSuccess(int i, DrivingResultObject drivingResultObject) { + if (drivingResultObject == null) { + return; + } + for (DrivingResultObject.Route route : drivingResultObject.result.routes) { + List lines = route.polyline; + tencentMap.addPolyline(new PolylineOptions().addAll(lines).color(0x22ff0000)); + tencentMap.moveCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder() + .include(route.polyline).build(), 100)); + tencentMap.moveCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder() + .include(lines).build(), 100)); + } + } + + @Override + public void onFailure(int i, String s, Throwable throwable) { + + } + }); + } + +} + diff --git a/positions/src/main/java/com/tencent/map/vector/demo/search/GeoCoderActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/search/GeoCoderActivity.java new file mode 100644 index 0000000..44ed8aa --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/search/GeoCoderActivity.java @@ -0,0 +1,186 @@ +package com.tencent.map.vector.demo.search; + +import android.content.Context; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.lbssearch.TencentSearch; +import com.tencent.lbssearch.httpresponse.BaseObject; +import com.tencent.lbssearch.httpresponse.HttpResponseListener; +import com.tencent.lbssearch.httpresponse.Poi; +import com.tencent.lbssearch.object.param.Address2GeoParam; +import com.tencent.lbssearch.object.param.Geo2AddressParam; +import com.tencent.lbssearch.object.result.Address2GeoResultObject; +import com.tencent.lbssearch.object.result.Geo2AddressResultObject; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; + +public class GeoCoderActivity extends SupportMapFragmentActivity { + + private EditText etGeocoder; + private Button btnGeocoder; + private EditText etRegeocoder; + private Button btnRegeocoder; + private TextView tvResult; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + initView(); + } + + + private void initView(){ + etGeocoder = (EditText) findViewById(R.id.et_geocoder); + btnGeocoder = (Button) findViewById(R.id.btn_geocoder); + etRegeocoder = (EditText) findViewById(R.id.et_regeocoder); + btnRegeocoder = (Button) findViewById(R.id.btn_regeocoder); + etGeocoder.setVisibility(View.VISIBLE); + btnGeocoder.setVisibility(View.VISIBLE); + etRegeocoder.setVisibility(View.VISIBLE); + btnRegeocoder.setVisibility(View.VISIBLE); + tvResult = (TextView) findViewById(R.id.tv_result); + tvResult.setVisibility(View.VISIBLE); + btnGeocoder.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + geocoder(); + } + }); + + btnRegeocoder.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + reGeocoder(); + } + }); + } + /** + *地理编码 + */ + protected void geocoder() { + TencentSearch tencentSearch = new TencentSearch(this); + String address = etGeocoder.getText().toString(); + Address2GeoParam address2GeoParam = + new Address2GeoParam(address).region("北京"); + tencentSearch.address2geo(address2GeoParam, new HttpResponseListener() { + + @Override + public void onSuccess(int arg0, BaseObject arg1) { + // TODO Auto-generated method stub + if (arg1 == null) { + return; + } + Address2GeoResultObject obj = (Address2GeoResultObject)arg1; + StringBuilder sb = new StringBuilder(); + sb.append("地址解析"); + if (obj.result.latLng != null) { + sb.append("\n坐标:" + obj.result.latLng.toString()); + } else { + sb.append("\n无坐标"); + } + printResult(sb.toString()); + tencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(obj.result.latLng,15f, 0, 0))); + tencentMap.addMarker(new MarkerOptions() + .position(obj.result.latLng)); + } + + @Override + public void onFailure(int arg0, String arg1, Throwable arg2) { + // TODO Auto-generated method stub + printResult(arg1); + } + }); + } + + /** + * 逆地理编码 + */ + protected void reGeocoder() { + String str = etRegeocoder.getText().toString().trim(); + LatLng latLng = str2Coordinate(this, str); + if (latLng == null) { + return; + } + TencentSearch tencentSearch = new TencentSearch(this); + //还可以传入其他坐标系的坐标,不过需要用coord_type()指明所用类型 + //这里设置返回周边poi列表,可以在一定程度上满足用户获取指定坐标周边poi的需求 + Geo2AddressParam geo2AddressParam = new Geo2AddressParam(latLng).getPoi(true) + .setPoiOptions(new Geo2AddressParam.PoiOptions() + .setRadius(1000).setCategorys("面包") + .setPolicy(Geo2AddressParam.PoiOptions.POLICY_O2O)); + tencentSearch.geo2address(geo2AddressParam, new HttpResponseListener() { + + @Override + public void onSuccess(int arg0, BaseObject arg1) { + // TODO Auto-generated method stub + if (arg1 == null) { + return; + } + Geo2AddressResultObject obj = (Geo2AddressResultObject)arg1; + StringBuilder sb = new StringBuilder(); + sb.append("逆地址解析"); + sb.append("\n地址:" + obj.result.address); + sb.append("\npois:"); + for (Poi poi : obj.result.pois) { + sb.append("\n\t" + poi.title); + tencentMap.addMarker(new MarkerOptions() + .position(poi.latLng) //标注的位置 + .title(poi.title) //标注的InfoWindow的标题 + .snippet(poi.address) //标注的InfoWindow的内容 + ); + } + //printResult(sb.toString()); + } + + @Override + public void onFailure(int arg0, String arg1, Throwable arg2) { + // TODO Auto-generated method stub + printResult(arg1); + } + }); + } + + + /** + * 由字符串获取坐标 + * @param context + * @param str + * @return + */ + public static LatLng str2Coordinate(Context context, String str) { + if (!str.contains(",")) { + Toast.makeText(context, "经纬度用\",\"分割", Toast.LENGTH_SHORT).show(); + return null; + } + String[] strs = str.split(","); + double lat = 0; + double lng = 0; + try { + lat = Double.parseDouble(strs[0]); + lng = Double.parseDouble(strs[1]); + } catch (NumberFormatException e) { + Toast.makeText(context, e.toString(), Toast.LENGTH_SHORT).show(); + return null; + } + return new LatLng(lat, lng); + } + protected void printResult(final String result) { + runOnUiThread(new Runnable() { + + @Override + public void run() { + // TODO Auto-generated method stub + tvResult.setText(result); + } + }); + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/search/SearchBasicActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/search/SearchBasicActivity.java new file mode 100644 index 0000000..b7b2c9b --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/search/SearchBasicActivity.java @@ -0,0 +1,305 @@ +package com.tencent.map.vector.demo.search; + +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.text.Editable; +import android.text.TextWatcher; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.BaseAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ListView; +import android.widget.TextView; +import android.widget.Toast; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.lbssearch.TencentSearch; +import com.tencent.lbssearch.httpresponse.BaseObject; +import com.tencent.lbssearch.httpresponse.HttpResponseListener; +import com.tencent.lbssearch.object.param.SearchParam; +import com.tencent.lbssearch.object.param.SuggestionParam; +import com.tencent.lbssearch.object.result.SearchResultObject; +import com.tencent.lbssearch.object.result.SuggestionResultObject; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; + +import java.lang.ref.WeakReference; +import java.util.List; + +public class SearchBasicActivity extends SupportMapFragmentActivity { + private EditText etSearch; + private Button btnSearch; + private ListView lvSuggesion; + private SuggestionAdapter suggestionAdapter; + private final int MSG_SUGGESTION = 10000; + private final MyHandler handler = new MyHandler(this); + + private static class MyHandler extends Handler { + private final WeakReference mActivity; + + public MyHandler(SearchBasicActivity activity) { + // TODO Auto-generated constructor stub + mActivity = new WeakReference<>(activity); + } + + @Override + public void handleMessage(Message msg) { + // TODO Auto-generated method stub + SearchBasicActivity activity = mActivity.get(); + if (activity != null) { + activity.handleMessage(msg); + } + } + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + initView(); + } + + protected void initView(){ + etSearch = (EditText) findViewById(R.id.et_search_poi); + btnSearch = (Button) findViewById(R.id.btn_search_poi); + etSearch.setVisibility(View.VISIBLE); + btnSearch.setVisibility(View.VISIBLE); + lvSuggesion = (ListView) findViewById(R.id.lv_suggestions); + + etSearch.addTextChangedListener(textWatcher); + etSearch.setOnFocusChangeListener(new View.OnFocusChangeListener() { + + @Override + public void onFocusChange(View v, boolean hasFocus) { + // TODO Auto-generated method stub + if (!etSearch.hasFocus()) { + lvSuggesion.setVisibility(View.GONE); + } + } + }); + + lvSuggesion.setOnItemClickListener(new AdapterView.OnItemClickListener() { + + @Override + public void onItemClick(AdapterView parent, View view, + int position, long id) { + // TODO Auto-generated method stub + etSearch.removeTextChangedListener(textWatcher); + CharSequence cs = + ((TextView)view.findViewById(R.id.label)).getText(); + etSearch.setText(cs); + lvSuggesion.setVisibility(View.GONE); + etSearch.addTextChangedListener(textWatcher); + } + }); + + btnSearch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + searchPoi(); + } + }); + } + + final TextWatcher textWatcher = new TextWatcher() { + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + // TODO Auto-generated method stub + suggestion(s.toString()); + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, + int after) { + // TODO Auto-generated method stub + + } + + @Override + public void afterTextChanged(Editable s) { + // TODO Auto-generated method stub + + } + }; + + + + /** + * poi检索 + */ + protected void searchPoi() { + TencentSearch tencentSearch = new TencentSearch(this); + String keyWord = etSearch.getText().toString().trim(); + //城市搜索 + SearchParam.Region region = new SearchParam.Region("北京").//设置搜索城市 + autoExtend(false);//设置搜索范围不扩大 + //圆形范围搜索 + LatLng latLng1 = new LatLng(39.984154, 116.307490); + SearchParam.Nearby nearBy = new SearchParam.Nearby(latLng1, 1000); + //矩形搜索,这里的范围是故宫 + LatLng latLng2 = new LatLng(39.913127, 116.392164); + LatLng latLng3 = new LatLng(39.923034, 116.402078); + SearchParam.Rectangle rectangle = new SearchParam.Rectangle(latLng2, latLng3); + + //filter()方法可以设置过滤类别, + //search接口还提供了排序方式、返回条目数、返回页码具体用法见文档, + //同时也可以参考官网的webservice对应接口的说明 + SearchParam searchParam = new SearchParam(keyWord, region);//.pageIndex(0).pageSize(20).filter("大学,中学"); + tencentSearch.search(searchParam, new HttpResponseListener() { + + @Override + public void onFailure(int arg0, String arg2, + Throwable arg3) { + Toast.makeText(getApplicationContext(), arg2, Toast.LENGTH_LONG).show(); + } + + @Override + public void onSuccess(int arg0, BaseObject arg1) { + if (arg1 == null) { + return; + } + SearchResultObject obj = (SearchResultObject) arg1; + if(obj.data == null){ + return; + } + tencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(obj.data.get(0).latLng,15f, 0, 0))); + for(SearchResultObject.SearchResultData data : obj.data){ + Log.v("SearchDemo","title:"+data.title + ";" + data.address); + tencentMap.addMarker(new MarkerOptions() + .position(data.latLng) //标注的位置 + .title(data.title) //标注的InfoWindow的标题 + .snippet(data.address) //标注的InfoWindow的内容 + ); + + } + } + }); + } + + public void handleMessage(Message msg) { + switch (msg.what) { + case MSG_SUGGESTION: + showAutoComplete((SuggestionResultObject)msg.obj); + break; + + default: + break; + } + } + + /** + * 显示完整ListView + * @param obj + */ + protected void showAutoComplete(SuggestionResultObject obj) { + if (obj.data.size() == 0) { + lvSuggesion.setVisibility(View.GONE); + return; + } + if (suggestionAdapter == null) { + suggestionAdapter = new SuggestionAdapter(obj.data); + lvSuggesion.setAdapter(suggestionAdapter); + } else { + suggestionAdapter.setDatas(obj.data); + suggestionAdapter.notifyDataSetChanged(); + } + lvSuggesion.setVisibility(View.VISIBLE); + } + /** + * 关键字提示 + * @param keyword + */ + protected void suggestion(String keyword) { + if (keyword.trim().length() == 0) { + lvSuggesion.setVisibility(View.GONE); + return; + } + TencentSearch tencentSearch = new TencentSearch(this); + SuggestionParam suggestionParam = new SuggestionParam(keyword, "北京"); + //suggestion也提供了filter()方法和region方法 + //具体说明见文档,或者官网的webservice对应接口 + tencentSearch.suggestion(suggestionParam, new HttpResponseListener() { + + @Override + public void onSuccess(int arg0, BaseObject arg1) { + if (arg1 == null || + etSearch.getText().toString().trim().length() == 0) { + lvSuggesion.setVisibility(View.GONE); + return; + } + + Message msg = new Message(); + msg.what = MSG_SUGGESTION; + msg.obj = arg1; + handler.sendMessage(msg); + } + + @Override + public void onFailure(int arg0, String arg1, Throwable arg2) { + //printResult(arg1); + } + }); + } + + class SuggestionAdapter extends BaseAdapter { + + List mSuggestionDatas; + + public SuggestionAdapter(List suggestionDatas) { + // TODO Auto-generated constructor stub + setDatas(suggestionDatas); + } + + public void setDatas(List suggestionDatas) { + mSuggestionDatas = suggestionDatas; + } + + @Override + public int getCount() { + // TODO Auto-generated method stub + return mSuggestionDatas.size(); + } + + @Override + public Object getItem(int position) { + // TODO Auto-generated method stub + return mSuggestionDatas.get(position); + } + + @Override + public long getItemId(int position) { + // TODO Auto-generated method stub + return position; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + // TODO Auto-generated method stub + ViewHolder viewHolder; + if (convertView == null) { + convertView = View.inflate(SearchBasicActivity.this, + R.layout.suggestion_list_item, null); + viewHolder = new ViewHolder(); + viewHolder.tvTitle = (TextView) convertView.findViewById(R.id.label); + viewHolder.tvAddress = (TextView) convertView.findViewById(R.id.desc); + convertView.setTag(viewHolder); + } else { + viewHolder = (ViewHolder) convertView.getTag(); + } + viewHolder.tvTitle.setText(mSuggestionDatas.get(position).title); + viewHolder.tvAddress.setText(mSuggestionDatas.get(position).address); + return convertView; + } + + private class ViewHolder{ + TextView tvTitle; + TextView tvAddress; + } + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/search/TransitRouteActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/search/TransitRouteActivity.java new file mode 100644 index 0000000..c9eddc1 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/search/TransitRouteActivity.java @@ -0,0 +1,93 @@ +package com.tencent.map.vector.demo.search; + +import android.os.Bundle; +import android.util.Log; + +import com.tencent.lbssearch.TencentSearch; +import com.tencent.lbssearch.httpresponse.HttpResponseListener; +import com.tencent.lbssearch.object.param.TransitParam; +import com.tencent.lbssearch.object.result.TransitResultObject; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; + +import java.util.List; + +public class TransitRouteActivity extends SupportMapFragmentActivity { + private LatLng fromPoint = new LatLng(40.127265, 116.208051); // 起点坐标 + private LatLng toPoint = new LatLng(40.040219, 116.273348); //终点坐标 + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + //移动地图 + tencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition( + new LatLng(40.080287, 116.244949), + 12, + 0f, + 0f))); + getTransitRoute(); + tencentMap.setOnMapClickListener(new TencentMap.OnMapClickListener() { + @Override + public void onMapClick(LatLng latLng) { + Log.d("TAG", "onMapClick: "+latLng); + } + }); + } + + /** + * 获取公交路径规划 + * TransitResultObject中的Segment是抽象类,要转换成具体的子类才能获取数据 + */ + private void getTransitRoute() { + TransitParam transitParam = new TransitParam(fromPoint, toPoint); + TencentSearch tencentSearch = new TencentSearch(this); + transitParam.policy(TransitParam.Policy.LEAST_WALKING, TransitParam.Preference.NO_SUBWAY); + tencentSearch.getRoutePlan(transitParam, new HttpResponseListener() { + + @Override + public void onSuccess(int i, TransitResultObject transitResultObject) { + if (transitResultObject == null) { + Log.i("TAG", "baseObject为空"); + return; + } + showTransitRoute(transitResultObject); + + } + + @Override + public void onFailure(int i, String s, Throwable throwable) { + Log.d("TransitRouteActivity", "onFailure: " + s); + } + }); + } + + private void showTransitRoute(TransitResultObject transitResultObject) { + tencentMap.clearAllOverlays(); + if (transitResultObject.result != null && transitResultObject.result.routes != null && transitResultObject.result.routes.size() > 0) { + for (int i = 0; i < transitResultObject.result.routes.size(); i++) { + TransitResultObject.Route route = transitResultObject.result.routes.get(i); + + List steps = route.steps; + for (int j = 0; j < steps.size(); j++) { + TransitResultObject.Segment segment = steps.get(j); + if (segment instanceof TransitResultObject.Transit) { + TransitResultObject.Transit transit = (TransitResultObject.Transit) segment; + tencentMap.addPolyline(new PolylineOptions().addAll(transit.lines.get(0).polyline).color(i + 1).width(20)); + + } else if (segment instanceof TransitResultObject.Walking) { + TransitResultObject.Walking walking = (TransitResultObject.Walking) segment; + tencentMap.addPolyline(new PolylineOptions().addAll(walking.polyline).color(j + 1).lineType(PolylineOptions.LineType.LINE_TYPE_IMAGEINARYLINE).width(20)); + } + + } + } + + } else { + Log.i("TAG", "路线结果为空"); + } + } +} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/search/TruckingRouteActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/search/TruckingRouteActivity.java new file mode 100644 index 0000000..9b47eff --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/search/TruckingRouteActivity.java @@ -0,0 +1,77 @@ +package com.tencent.map.vector.demo.search; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; +import android.util.Log; + +import com.tencent.lbssearch.TencentSearch; +import com.tencent.lbssearch.httpresponse.HttpResponseListener; +import com.tencent.lbssearch.object.param.TransitParam; +import com.tencent.lbssearch.object.param.TruckingParam; +import com.tencent.lbssearch.object.result.RoutePlanningObject; +import com.tencent.lbssearch.object.result.TransitResultObject; +import com.tencent.lbssearch.object.result.TruckingResultObject; +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds; +import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; + +import java.util.List; + +public class TruckingRouteActivity extends SupportMapFragmentActivity { + private LatLng fromPoint = new LatLng(40.127265, 116.208051); // 起点坐标 + private LatLng toPoint = new LatLng(40.040219, 116.273348); //终点坐标 + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + CameraUpdate cameraSigma = + CameraUpdateFactory.newCameraPosition(new CameraPosition( + new LatLng(40.040219, 116.273348), + 15, + 0f, + 0f)); + //移动地图 + tencentMap.moveCamera(cameraSigma); + geTruckingRoute(); + } + + private void geTruckingRoute() { + TruckingParam truckingParam = new TruckingParam(); + truckingParam.from(fromPoint); + truckingParam.to(toPoint); + truckingParam.setMultRoute(1); + // truckingParam.setNoPolyline(1); + truckingParam.trafficSpeed(true); + TencentSearch tencentSearch = new TencentSearch(this); + tencentSearch.getRoutePlan(truckingParam, new HttpResponseListener() { + + @Override + public void onSuccess(int i, TruckingResultObject truckingResultObject) { + if (null != truckingResultObject.result && null != truckingResultObject.result.routes && truckingResultObject.result.routes.size() > 0) { + for (int j = 0; j < truckingResultObject.result.routes.size(); j++) { + TruckingResultObject.Result result = truckingResultObject.result; + TruckingResultObject.Route route = result.routes.get(j); + // List steps = route.steps; + tencentMap.addPolyline(new PolylineOptions().addAll(route.polyline).color(i + 1).width(20)); + tencentMap.moveCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder() + .include(route.polyline).build(), 100)); + + } + } + } + + @Override + public void onFailure(int i, String s, Throwable throwable) { + Log.d("TruckingRouteActivity", "onFailure: " + s); + + } + }); + + } +} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/search/WalkingRouteActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/search/WalkingRouteActivity.java new file mode 100644 index 0000000..d8d0da4 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/search/WalkingRouteActivity.java @@ -0,0 +1,76 @@ +package com.tencent.map.vector.demo.search; + +import android.os.Bundle; +import android.util.Log; + +import com.tencent.lbssearch.object.result.RoutePlanningObject; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.lbssearch.TencentSearch; +import com.tencent.lbssearch.httpresponse.HttpResponseListener; +import com.tencent.lbssearch.object.param.WalkingParam; +import com.tencent.lbssearch.object.result.WalkingResultObject; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds; +import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; + + +public class WalkingRouteActivity extends SupportMapFragmentActivity { + + private LatLng fromPoint = new LatLng(40.040219, 116.273348); // 起点坐标 + private LatLng toPoint = new LatLng(40.048055, 116.281166); //终点坐标 + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + getWalkingRoute(); + } + + /** + * 获取步行路线规划 + */ + private void getWalkingRoute() { + WalkingParam walkingParam = new WalkingParam(); + walkingParam.from(fromPoint); + walkingParam.to(toPoint); + TencentSearch tencentSearch = new TencentSearch(getApplicationContext()); + Log.i("TAG", "checkParams:" + walkingParam.checkParams()); + tencentSearch.getRoutePlan(walkingParam, new HttpResponseListener() { + @Override + public void onSuccess(int statusCode, WalkingResultObject object) { + if (object == null) { + Log.i("TAG", "baseObject为空"); + return; + } + showWalkingRoute(object); + Log.i("TAG", "message:" + object.message); + } + + @Override + public void onFailure(int statusCode, String responseString, Throwable throwable) { + Log.i("TAG:", statusCode + " " + responseString); + } + }); + } + + private void showWalkingRoute(WalkingResultObject object) { + tencentMap.clearAllOverlays(); + if (object.result != null && object.result.routes != null && object.result.routes.size() > 0) { + for (int i = 0; i < object.result.routes.size(); i++) { + WalkingResultObject.Route result = object.result.routes.get(i); + tencentMap.addPolyline(new PolylineOptions().addAll(result.polyline).color(i + 1).width(20)); + Log.i("TAG", "distance:" + result.distance + " duration:" + result.duration + + " mode:" + result.mode + " direction:" + result.direction); + for (RoutePlanningObject.Step step : result.steps) { + Log.i("TAG", "step:" + step.road_name + " " + step.distance + " " + + step.instruction + " " + step.act_desc + " " + step.dir_desc); + } + tencentMap.moveCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder() + .include(result.polyline).build(), 100)); + } + + } else { + Log.i("TAG", "路线结果为空"); + } + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/smooth/SmoothMoveActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/smooth/SmoothMoveActivity.java new file mode 100644 index 0000000..cfa5cce --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/smooth/SmoothMoveActivity.java @@ -0,0 +1,251 @@ +package com.tencent.map.vector.demo.smooth; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.graphics.drawable.RoundedBitmapDrawable; +import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory; + +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Matrix; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.ImageView; + +import cc.winboll.studio.positions.R; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.MapView; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds; +import com.tencent.tencentmap.mapsdk.maps.model.Marker; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; +import com.tencent.tencentmap.mapsdk.maps.model.Polyline; +import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; +import com.tencent.tencentmap.mapsdk.vector.utils.animation.MarkerTranslateAnimator; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Timer; +import java.util.TimerTask; + +import static com.tencent.tencentmap.mapsdk.vector.utils.animation.MarkerTranslateAnimator.MarkerTranslateStatusListener.AnimationStatus.AnimationComplete; + +public class SmoothMoveActivity extends AppCompatActivity implements View.OnClickListener { + private MapView mapView; + private final String mLine = "39.98409,116.30804,39.98409,116.3081,39.98409,116.3081,39.98397,116.30809,39.9823,116.30809,39.9811,116.30817,39.9811,116.30817,39.97918,116.308266,39.97918,116.308266,39.9791,116.30827,39.9791,116.30827,39.979008,116.3083,39.978756,116.3084,39.978386,116.3086,39.977867,116.30884,39.977547,116.308914,39.976845,116.308914,39.975826,116.308945,39.975826,116.308945,39.975666,116.30901,39.975716,116.310486,39.975716,116.310486,39.975754,116.31129,39.975754,116.31129,39.975784,116.31241,39.975822,116.31327,39.97581,116.31352,39.97588,116.31591,39.97588,116.31591,39.97591,116.31735,39.97591,116.31735,39.97593,116.31815,39.975967,116.31879,39.975986,116.32034,39.976055,116.32211,39.976086,116.323395,39.976105,116.32514,39.976173,116.32631,39.976254,116.32811,39.976265,116.3288,39.976345,116.33123,39.976357,116.33198,39.976418,116.33346,39.976418,116.33346,39.97653,116.333755,39.97653,116.333755,39.978157,116.333664,39.978157,116.333664,39.978195,116.33509,39.978195,116.33509,39.978226,116.33625,39.978226,116.33625,39.97823,116.33656,39.97823,116.33656,39.978256,116.33791,39.978256,116.33791,39.978016,116.33789,39.977047,116.33791,39.977047,116.33791,39.97706,116.33768,39.97706,116.33768,39.976967,116.33706,39.976967,116.33697"; + private TencentMap map; + private Polyline mPolyline; + private Marker mCarMarker; + private LatLng[] mCarLatLngArray; + private MarkerTranslateAnimator mAnimator; + private Polyline polyline; + private ArrayList skews; + private ArrayList roates; + private String parentPath; + private ImageView imageView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_smooth_move); + mapView = findViewById(R.id.map); + map = mapView.getMap(); + //解析路线 + init(); + Button btLin = findViewById(R.id.button_set); + Button btStart = findViewById(R.id.satrt); + Button btStop = findViewById(R.id.stop); + btLin.setOnClickListener(this); + btStart.setOnClickListener(this); + btStop.setOnClickListener(this); + } + + private void init() { + String[] linePointsStr = mLine.split(","); + mCarLatLngArray = new LatLng[linePointsStr.length / 4]; + skews = new ArrayList<>(); + roates = new ArrayList<>(); + + for (int i = 0; i < mCarLatLngArray.length; i++) { + double latitude = Double.parseDouble(linePointsStr[i * 4]); + double longitude = Double.parseDouble(linePointsStr[i * 4 + 1]); + // float skew = Float.parseFloat(linePointsStr[i * 4 + 2]); + // float roate = Float.parseFloat(linePointsStr[i * 4 + 3]); + mCarLatLngArray[i] = new LatLng(latitude, longitude); + // skews.add(skew); + // roates.add(roate); + } + } + + @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 onDestroy() { + super.onDestroy(); + mapView.onDestroy(); + } + + @Override + protected void onRestart() { + super.onRestart(); + mapView.onRestart(); + } + + @Override + public void onClick(View v) { + switch (v.getId()) { + case R.id.button_set: + if (polyline == null && mCarMarker == null) { + //添加小车路线 + polyline = map.addPolyline(new PolylineOptions().add(mCarLatLngArray).color(R.color.colorPrimaryDark)); + LatLng carLatLng = mCarLatLngArray[0]; + mCarMarker = map.addMarker( + new MarkerOptions(carLatLng) + .anchor(0.5f, 0.5f) + .title("即将到达终点") + .icon(BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.taxi))) + .flat(true) + .clockwise(false)); + //调整最佳视界 + map.animateCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder().include(Arrays.asList(mCarLatLngArray)).build(), 50)); + TimerTask timerTask = new TimerTask() { + @Override + public void run() { + if (polyline != null) { + snapshot(); + } + + } + }; + Timer timer = new Timer(); + timer.schedule(timerTask, 800); + } + break; + case R.id.satrt: + if (mAnimator == null) { + //创建移动动画 + mAnimator = new MarkerTranslateAnimator(mCarMarker, 100 * 1000, mCarLatLngArray, true, new MarkerTranslateAnimator.MarkerTranslateStatusListener() { + private CameraUpdate cameraSigma; + + @Override + public void onInterpolatePoint(LatLng latLng, int i, AnimationStatus animationStatus) { + //路线擦出 + polyline.setEraseable(true); + polyline.eraseTo(i, latLng); + + /* CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBoundsWithMapCenter(LatLngBounds.builder().include(Arrays.asList(mCarLatLngArray)).build(), latLng, 10); + map.animateCamera(cameraUpdate);*/ + if (mCarMarker.getRotation() < 90 && mCarMarker.getRotation() > 0) { + cameraSigma = + CameraUpdateFactory.newCameraPosition(new CameraPosition( + latLng, + 18, + 60, + mCarMarker.getRotation() + 180)); + } else if (mCarMarker.getRotation() >= 90 && mCarMarker.getRotation() <= 180) { + cameraSigma = + CameraUpdateFactory.newCameraPosition(new CameraPosition( + latLng, + 18, + 60, + -mCarMarker.getRotation())); + } else { + cameraSigma = + CameraUpdateFactory.newCameraPosition(new CameraPosition( + latLng, + 18, + 60, + -mCarMarker.getRotation())); + } + + //移动地图 + map.moveCamera(cameraSigma); + map.enableMultipleInfowindow(true); + if (i == 41) { + mCarMarker.startAnimation(); + mCarMarker.showInfoWindow(); + } + if (animationStatus == AnimationComplete) { + mCarMarker.setTitle("到达目的地"); + } + } + }); + + + //开启动画 + mAnimator.startAnimation(); + } + break; + case R.id.stop: + if (mAnimator != null && polyline != null && mCarMarker != null) { + mAnimator.endAnimation(); + //mAnimator.cancelAnimation(); + polyline.remove(); + polyline = null; + mCarMarker.remove(); + mCarMarker = null; + mAnimator = null; + } + + + break; + default: + throw new IllegalStateException("Unexpected value: " + v.getId()); + } + } + + private void snapshot() { + imageView = findViewById(R.id.iv); + + map.snapshot(new TencentMap.SnapshotReadyCallback() { + @Override + public void onSnapshotReady(Bitmap bitmap) { + RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), bitmap); + roundedBitmapDrawable.setCircular(true); + imageView.setImageDrawable(roundedBitmapDrawable); + } + }, Bitmap.Config.ARGB_8888); + } + + //设置图片 + private Bitmap getBitMap(int resourceId) { + Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId); + int width = bitmap.getWidth(); + int height = bitmap.getHeight(); + int newWidth = 100; + int newHeight = 150; + float widthScale = ((float) newWidth) / width; + float heightScale = ((float) newHeight) / height; + Matrix matrix = new Matrix(); + matrix.postScale(widthScale, heightScale); + bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); + return bitmap; + } +} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/transaction/AnimateCameraActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/transaction/AnimateCameraActivity.java new file mode 100644 index 0000000..a485ce5 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/transaction/AnimateCameraActivity.java @@ -0,0 +1,61 @@ +package com.tencent.map.vector.demo.transaction; + +import android.os.Bundle; +import android.view.View; +import android.widget.Button; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; + +public class AnimateCameraActivity extends SupportMapFragmentActivity implements View.OnClickListener { + + private Button btn; + private boolean flag; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + btn = findViewById(R.id.btn_bottom); + btn.setVisibility(View.VISIBLE); + btn.setText("以动画的方式改变地图视图"); + btn.setOnClickListener(this); + + flag = true; + } + + /** + * 改变地图视图 + * @param v + */ + @Override + public void onClick(View v) { + if(flag){ + CameraUpdate cameraSigma = + CameraUpdateFactory.newCameraPosition(new CameraPosition( + new LatLng(39.977290,116.337000), //新的中心点坐标 + 19, //新的缩放级别 + 40f, //俯仰角 0~45° (垂直地图时为0) + 45f)); //偏航角 0~360° (正北方为0) + //移动地图 + tencentMap.animateCamera(cameraSigma); + flag = !flag; + }else { + CameraUpdate cameraSigma = + CameraUpdateFactory.newCameraPosition(new CameraPosition( + new LatLng(39.877290,116.437000), //新的中心点坐标 + 18, //新的缩放级别 + 0f, //俯仰角 0~45° (垂直地图时为0) + 0f)); //偏航角 0~360° (正北方为0) + //移动地图 + tencentMap.animateCamera(cameraSigma); + flag = !flag; + } + + } + +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/transaction/MoveCameraActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/transaction/MoveCameraActivity.java new file mode 100644 index 0000000..8586b4f --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/transaction/MoveCameraActivity.java @@ -0,0 +1,61 @@ +package com.tencent.map.vector.demo.transaction; + +import android.os.Bundle; +import android.view.View; +import android.widget.Button; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; + +public class MoveCameraActivity extends SupportMapFragmentActivity implements View.OnClickListener { + + + private Button btn; + private boolean flag; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + btn = findViewById(R.id.btn_bottom); + btn.setVisibility(View.VISIBLE); + btn.setText("以移动的方式改变地图视图"); + btn.setOnClickListener(this); + + flag = true; + } + + /** + * 改变地图视图 + * @param v + */ + @Override + public void onClick(View v) { + if(flag){ + CameraUpdate cameraSigma = + CameraUpdateFactory.newCameraPosition(new CameraPosition( + new LatLng(39.977290,116.337000), //新的中心点坐标 + 19, //新的缩放级别 + 40f, //俯仰角 0~45° (垂直地图时为0) + 45f)); //偏航角 0~360° (正北方为0) + //移动地图 + tencentMap.moveCamera(cameraSigma); + flag = !flag; + }else { + CameraUpdate cameraSigma = + CameraUpdateFactory.newCameraPosition(new CameraPosition( + new LatLng(39.877290,116.437000), //新的中心点坐标 + 18, //新的缩放级别 + 0f, //俯仰角 0~45° (垂直地图时为0) + 0f)); //偏航角 0~360° (正北方为0) + //移动地图 + tencentMap.moveCamera(cameraSigma); + flag = !flag; + } + + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/transaction/RotateMapActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/transaction/RotateMapActivity.java new file mode 100644 index 0000000..7fda144 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/transaction/RotateMapActivity.java @@ -0,0 +1,28 @@ +package com.tencent.map.vector.demo.transaction; + +import android.os.Bundle; +import android.view.View; +import android.widget.Button; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; + +public class RotateMapActivity extends SupportMapFragmentActivity { + private Button btn; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + btn = findViewById(R.id.btn_bottom); + btn.setVisibility(View.VISIBLE); + btn.setText("旋转地图"); + btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + CameraUpdate cameraUpdate = CameraUpdateFactory.rotateTo(90f,1.5f); + tencentMap.animateCamera(cameraUpdate); + } + }); + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/transaction/ScollMapActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/transaction/ScollMapActivity.java new file mode 100644 index 0000000..73b2e8d --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/transaction/ScollMapActivity.java @@ -0,0 +1,82 @@ +package com.tencent.map.vector.demo.transaction; + +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.CompoundButton; +import android.widget.LinearLayout; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.TencentMap; + +public class ScollMapActivity extends SupportMapFragmentActivity implements View.OnClickListener { + private static final int SCROLL_BY_PX = 100; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + LinearLayout linearLayout = findViewById(R.id.ll); + linearLayout.setVisibility(View.VISIBLE); + Button scrollLeft = (Button) findViewById(R.id.scroll_left); + scrollLeft.setOnClickListener(this); + + Button scrollRight = (Button) findViewById(R.id.scroll_right); + scrollRight.setOnClickListener(this); + + Button scrollUp = (Button) findViewById(R.id.scroll_up); + scrollUp.setOnClickListener(this); + + Button scrollDown = (Button) findViewById(R.id.scroll_down); + scrollDown.setOnClickListener(this); + + /* btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + CameraUpdate cameraUpdate = CameraUpdateFactory.scrollBy(50f,50f); + tencentMap.animateCamera(cameraUpdate); + } + });*/ + } + + + // 根据动画按钮状态,调用函数animateCamera或moveCamera来改变可视区域 + + private void changeCamera(CameraUpdate update, TencentMap.CancelableCallback callback) { + boolean animated = ((CompoundButton) findViewById(R.id.animate)) + .isChecked(); + if (animated) { + tencentMap.animateCamera(update, 1000, callback); + } else { + tencentMap.moveCamera(update); + } + } + + @Override + public void onClick(View v) { + switch (v.getId()) { + //点击向左移动按钮响应事件,camera将向左边移动 + + case R.id.scroll_left: + changeCamera(CameraUpdateFactory.scrollBy(-SCROLL_BY_PX, 0), null); + break; + // 点击向右移动按钮响应事件,camera将向右边移动 + case R.id.scroll_right: + changeCamera(CameraUpdateFactory.scrollBy(SCROLL_BY_PX, 0), null); + break; + // 点击向上移动按钮响应事件,camera将向上边移动 + case R.id.scroll_up: + changeCamera(CameraUpdateFactory.scrollBy(0, -SCROLL_BY_PX), null); + break; + // 点击向下移动按钮响应事件,camera将向下边移动 + case R.id.scroll_down: + changeCamera(CameraUpdateFactory.scrollBy(0, SCROLL_BY_PX), null); + break; + + default: + break; + } + } +} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/transaction/ZoomCalulateActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/transaction/ZoomCalulateActivity.java new file mode 100644 index 0000000..62d7059 --- /dev/null +++ b/positions/src/main/java/com/tencent/map/vector/demo/transaction/ZoomCalulateActivity.java @@ -0,0 +1,73 @@ +package com.tencent.map.vector.demo.transaction; + +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Matrix; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; + +import cc.winboll.studio.positions.R; +import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; +import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; +import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; +import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; + +import java.util.ArrayList; + +public class ZoomCalulateActivity extends SupportMapFragmentActivity { + + private Button btn; + private int leftpadding = 50,rightpadding =50, toppadding = 50, bottompadding=50; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + btn = findViewById(R.id.btn_bottom); + btn.setVisibility(View.VISIBLE); + btn.setText("根据点集缩放地图"); + btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(addMarker()); + tencentMap.moveCamera(cameraUpdate); + } + }); + } + + + private CameraPosition addMarker(){ + ArrayList points = new ArrayList<>(); + points.add(new LatLng(39.984059,116.307621)); + points.add(new LatLng(39.984049,116.307631)); +// points.add(new LatLng(39.981527,116.308994)); +// points.add(new LatLng(39.984026,116.316419)); +// points.add(new LatLng(39.978501,116.311827)); + //根据markers计算缩放级别 + for(int i=0; i - - - - diff --git a/positions/src/main/res/drawable/ic_launcher_disable.xml b/positions/src/main/res/drawable/ic_launcher_disable.xml deleted file mode 100644 index 9a31905..0000000 --- a/positions/src/main/res/drawable/ic_launcher_disable.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/positions/src/main/res/drawable/ic_launcher_foreground.xml b/positions/src/main/res/drawable/ic_launcher_foreground.xml deleted file mode 100644 index 872b04e..0000000 --- a/positions/src/main/res/drawable/ic_launcher_foreground.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - diff --git a/positions/src/main/res/drawable/ic_launcher_foreground_disable.xml b/positions/src/main/res/drawable/ic_launcher_foreground_disable.xml deleted file mode 100644 index 763b72c..0000000 --- a/positions/src/main/res/drawable/ic_launcher_foreground_disable.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - diff --git a/positions/src/main/res/drawable/shape_gradient.xml b/positions/src/main/res/drawable/shape_gradient.xml deleted file mode 100644 index c164fe9..0000000 --- a/positions/src/main/res/drawable/shape_gradient.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - diff --git a/positions/src/main/res/drawable/taxi.png b/positions/src/main/res/drawable/taxi.png new file mode 100644 index 0000000000000000000000000000000000000000..f5a90cf316dd149f89aff9db76b6994f7ac956f0 GIT binary patch literal 4150 zcmaJ^XH-*Z*QEvsMY>3hK~NM3gqB1?4J9H7AyNdCNCIRaMG|^ZigZ*!K@boI5Jj3u z2k9zRkf91vMoN9blwbbE>?JrL(dU^B*3E)zg#63&Z&A>i=AS9%HhY;2sz zh*&4Oll57I2Zf}LJBU#aB2igrHa303AS%wohd>8iCU_CaNbp8;8yG~yBf*Y3)*9AS zQ-U|qGQ^KyA7X>`2=VcNO|0;n*{fCxJ`@2o7hCzaGREVa!#z9Fx1Ffz9 zcPNSUPc)5=A^gAI|4K~522%+T41q@R_w!&KoTuVJDk{R%kAS07{IC>?@6RsUdQ<2W znm2_CGPTzQov_Av5XlD{Dt{uZtr2K4jgBLG5YQ+jn8l$^B;pY|8d@4CU6eTrW^SUX zX{HU+HipAsdT?D6Z4E6mxb{yhisIot2;zUyVxkK**MJ(c_)!0%l4TUW-_sP02A4)K19zWHJkEvlfx7s0ajEhz=##iJte#lK!|H*t@A!M!pw{a(@?FS=b&^PILBW+_QbbXIGcaxR{5NLUQH$wjRcMA$_`1?bG^8MbW-*sNh zCkafF5t+*Y5IG%`6lZ%nJ>oniyKTBg9|@U z^NejnkXyv37jcy>enW~pLarGKlXW7kjAg591&wR5T*}|S$JKXCJr&!0<3pL)XTAtE zl#`VX|MIo%M;{EbTZi1~vygB4xVz9bA*U+YyvjIn_Mwmgz>^T;`CC}cY>`5d&yGJH zh*sppcnabJW)Jz58l|P?W1J&D7W@`Dh7LbfY?jE;Tb-T_{K@HDb}) z*5U{MueyLqrw1jSCN)<`?nwffLe%}KG~=g$+8_Gt`Tp02$Ga?OZ>iI3JUh8TTZ@6- z%tGN7QSSQvK+lDa1V{PEK_>5mRaKuM3!Z@{bNY~OQ=!1^VWkwIrXkyF10QgXLqPp4 zM!kEZD^nL4mLsHSYo{@(=16+WXg6k#)N&hxxp;;F+eVt8X-PH&mnKCW7IXBQm(Pqp ziO=Bluv7!_$9O**2Qsds*tGfi;Jr||Wg;faW}3_a`39wB_W)l5wA;>-iUN(O6VZx_-D0_=4xs} zxP4T7(9vp*7*IMjVQ>Ff%+QARP90}`1;L^dt?srLXH=zToVsIz85WmmD4ujiQI;=2 ztUh1IJ#Y=zn&WlDG05J}qvB6E%Q$-EdB8VNVCgr)1A#gei8x@l@SNmAyj|f_p~xrR zQt$ZQa_cj`j#HzuIJ?8{UIV@tQ2--aVzu<7^X^F10V4Zyxt9+e7Cn2uTElIy!&Oai zsR?i@7I@p&H%j}wQO1o~A)#>b)cS4BDV{c$&+ zsEuBnIcLdd*yib|y!H&!Hx?fX)#&f(NwX#+;(BwV*RSmOe)HN0UPdBh@I`J}h$0F0 znqxCGw^l8ISL?8b_k9?ZtDVh_jm^Kb;USk}gnm=(tWolqduPt85wt!?(G_&M=kjC< z{3c(8Fx$Mv?^8CCfv$JW8^d0I1`>WOxjD5YFO|R2#i`es6c?|Ve9YDezj?!W;v*1| ze4F9>$nVB+zKwdrruyMWExQha0YX)e<7_H73wO%oA_4=%WM?%kCFj`0YU3lA-=CXQ zygvdq{}6mm%|w^}$L9DKn+8I^s{U5}6oq^-Q}Uekaub27%zksEu?tvuUeP+X&t1$e zG$hX~ImQh03pB7kgnYi0>Bf<9T+2bDI;=b_z@+|5yTr61TUqDDh3=I6!Z!o$bvlSJ zm{PQAFWJP;2L_psVXAViKN)Z>)f1Pt{b1u>*f*SLBzPFI@{6lc?hMpkr@HDHCG|_@ z1I%y7thgtgv~l67=}W+#5-teu!SuX;vcgt z2+`-gA~jltdp#U>N@kRZEXl^Lbyy#rI(N@C#Wo=|jaPB3^nMAc302f?I&n&{VCuG? zh}li)oatSi#`h&>j-GguZ9@l^&8Vn~a4PKVmV^O-W6YCBitJGu-n?Te)RADiP5Qlu z4Qof->=7qdnezA$1Mb6!m8~vY`R{y1*f?nPDcfuNE-wyk3-gKBbTZ?92J`gNwGb{6SdrI8{|(DB`+r$)PNvGG$x&1M1knD@qq z>g1{tZSxS>=x?H1?*gJxZ4DaX#`zg}p{I-UYks}*;d!M|V(HzLk(0$wXKy`enM5m5 zb03b8a!(z5@=2@Ynpb@|IM?UQyr4gD!lM=}-px_RqeuAO&uBiHIn?!*6Y_>qif^R8 z_o}PqQGYRWq56)EY?KP=Tk!neAt94z6`DozNvT>-qB%t0jQJk+) z^|h==QDhOY64}r_j8B+_j;_4`XSXSJrun;pVQh?fvHcI?fOZ8woI zsW3Z{MuZ%<@>En6Q^9-!jY>fI&7iWWm%VB2kgnHrSwQHiB>p~KtRA1eDbXp}F0bnG z-En}$$1KrWl**&5p1dn{&iH<%Iy1@8bLlep0l!Y(;s%jNqt5iwvH7K2Uu&S<4-?#L z`uvYC)}E{#^-KzX?OaHn#vsu{i=H(Z`UdiL^>HMK(c12ZeD zJtUm7GlumY!F6+d3=kw2FWh>4KdWv=wWCoq{od$(w-_7IbjRz4`zwgji*Sj3|K(R% zwmsCI2e+Ci>_lr=)=l7z3#N4)k`Cf`%ZhM#1D@hAxz^UJ8KX{-U*)zQN83vcxs8Or zDz_Cb#R4Fsr+rIboVsqw>=VsZQ3g*3nHAsG_o}Qd3B23qBmP)itm0Hd>dH(DAhDE- zu~L3nxvpV*X8|j93H$K9UJIhINxDJ4Zl?E4Y;}4@a(a2XGwN#|&PKI_M4gaLu4Al? zVltVZvn8`CB;sj0lbD+BwebL(wq=0mi(eCzP~B(MEZQU(hx}1@0&)t8Dm{Z^<4OH3 zahOLdYt(Nu&rKVKNWPU5*^ckrv;+IroTvq)BV*p3Qj0l;{O3mkON|z#MQox{kndxL zrR;Eb9%cic*D8f<79bzJ?oJ4p|Ftyfrq#0VNI;SGkdPI1uPi)d%Ha`Vx)|Af$XQy$mZiE~$mkh-fgvw}#GK@2UMS596 zUrtFRxrBa9az0Iw#kX=fYw{sSrmK{YJQ!VS$7^`RN!Q6(LlXM5o(l4+!3fR9AvhZi zZc_WBzM(h#M4R5tRU3%JbWMGoS0=&!`~|kmr7P`r&}-SsSO9JqBU@lkXx-q%JhoykC!UZ|(*+ zw9+p(H1*FBx`$_*?LiI38SqHRH)7nL3ztCj#uYC|^{5N>GBM+uJYQ=Ui(B0 z#nL}CQqsW*Hf&~i|9QnAF#7pX_Vkxr$$2Z+|YDy!8`^VeazD2HI=$0y>AN - + android:layout_height="wrap_content"> \ No newline at end of file diff --git a/positions/src/main/res/layout/activity_location.xml b/positions/src/main/res/layout/activity_location.xml deleted file mode 100644 index 72de22e..0000000 --- a/positions/src/main/res/layout/activity_location.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - diff --git a/positions/src/main/res/layout/activity_mapview.xml b/positions/src/main/res/layout/activity_mapview.xml deleted file mode 100644 index 0bfc294..0000000 --- a/positions/src/main/res/layout/activity_mapview.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - diff --git a/positions/src/main/res/menu/toolbar_main.xml b/positions/src/main/res/menu/toolbar_main.xml index 2f47455..2e69bae 100644 --- a/positions/src/main/res/menu/toolbar_main.xml +++ b/positions/src/main/res/menu/toolbar_main.xml @@ -2,8 +2,11 @@ + android:id="@+id/item_mapview" + android:title="MapViewActivity"/> + diff --git a/positions/src/main/res/values/attrs.xml b/positions/src/main/res/values/attrs.xml deleted file mode 100644 index e8d3289..0000000 --- a/positions/src/main/res/values/attrs.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/positions/src/main/res/values/colors.xml b/positions/src/main/res/values/colors.xml index 05e37ab..193ea37 100644 --- a/positions/src/main/res/values/colors.xml +++ b/positions/src/main/res/values/colors.xml @@ -1,9 +1,8 @@ - - #FF196ABC - #FF002B57 - #FF80BFFF + #1033F6 + #131313 + #FF4081 #4ddad589 #C71585 diff --git a/positions/src/main/res/values/strings.xml b/positions/src/main/res/values/strings.xml index 2b816e8..adb34ce 100644 --- a/positions/src/main/res/values/strings.xml +++ b/positions/src/main/res/values/strings.xml @@ -1,7 +1,5 @@ - - - Positions + 腾讯地图示例 基础地图 地图交互 @@ -41,4 +39,5 @@ 普通点聚合 海量点聚合 自定义点聚合 + diff --git a/positions/src/main/res/values/styles.xml b/positions/src/main/res/values/styles.xml index 8380acf..5f3bdbf 100644 --- a/positions/src/main/res/values/styles.xml +++ b/positions/src/main/res/values/styles.xml @@ -1,4 +1,3 @@ -