-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
210 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
app/src/main/java/com/cczhr/otglocation/BaiduMapActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.cczhr.otglocation | ||
|
||
import com.baidu.location.BDAbstractLocationListener | ||
import com.baidu.location.BDLocation | ||
import com.baidu.location.LocationClient | ||
import com.baidu.location.LocationClientOption | ||
import com.baidu.mapapi.map.BaiduMap | ||
import kotlinx.android.synthetic.main.activity_baidu_map.* | ||
|
||
/** | ||
* @author cczhr | ||
* @description | ||
* @since 2021/3/26 11:45 | ||
*/ | ||
class BaiduMapActivity :BaseActivity() { | ||
override val layoutId: Int = R.layout.activity_baidu_map | ||
|
||
lateinit var baiduMap: BaiduMap | ||
|
||
lateinit var locationClient:LocationClient | ||
override fun init() { | ||
locationClient=LocationClient(this) | ||
locationClient.locOption= LocationClientOption().apply { | ||
isOpenGps=true | ||
coorType="gcj02" | ||
scanSpan=1000 | ||
} | ||
locationClient.registerLocationListener(object :BDAbstractLocationListener(){ | ||
override fun onReceiveLocation(location: BDLocation?) { | ||
|
||
|
||
|
||
|
||
} | ||
|
||
}) | ||
baiduMap=map_view.map | ||
baiduMap.isMyLocationEnabled=true | ||
|
||
|
||
locationClient.start() | ||
} | ||
|
||
|
||
override fun onResume() { | ||
map_view.onResume() | ||
super.onResume() | ||
|
||
} | ||
|
||
|
||
override fun onPause() { | ||
map_view.onPause() | ||
super.onPause() | ||
|
||
} | ||
|
||
|
||
override fun onDestroy() { | ||
locationClient.stop() | ||
baiduMap.isMyLocationEnabled=false | ||
map_view.onDestroy() | ||
super.onDestroy() | ||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
|
||
<com.google.android.material.textfield.TextInputLayout | ||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="8dp" | ||
android:hint="@string/search" | ||
> | ||
|
||
<com.google.android.material.textfield.TextInputEditText | ||
android:id="@+id/edit_query" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:maxLines="1" | ||
android:singleLine="true" /> | ||
</com.google.android.material.textfield.TextInputLayout> | ||
|
||
|
||
<com.baidu.mapapi.map.MapView | ||
android:id="@+id/map_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="0dp" | ||
android:clickable="true" | ||
android:layout_margin="8dp" | ||
android:layout_weight="1" /> | ||
|
||
|
||
<TextView | ||
android:id="@+id/location_info" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="8dp" /> | ||
|
||
<LinearLayout | ||
android:orientation="horizontal" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<com.google.android.material.textfield.TextInputLayout | ||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu" | ||
android:layout_width="0dp" | ||
android:layout_weight="1" | ||
android:id="@+id/text_input_layout" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="8dp" | ||
android:layout_marginStart="8dp" | ||
android:hint="@string/local_location" | ||
app:errorEnabled="false" | ||
app:helperTextEnabled="true"> | ||
<AutoCompleteTextView | ||
android:id="@+id/select_location" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:inputType="none"/> | ||
</com.google.android.material.textfield.TextInputLayout> | ||
|
||
<Button | ||
android:layout_marginEnd="8dp" | ||
android:textColor="@color/white" | ||
android:onClick="deleteLocalLocation" | ||
android:text="@string/delete" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content"/> | ||
</LinearLayout> | ||
|
||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal"> | ||
|
||
<Button | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginEnd="8dp" | ||
android:layout_weight="1" | ||
android:onClick="moveMap" | ||
android:text="@string/move_map" | ||
android:textColor="@color/white" /> | ||
|
||
|
||
<Button | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginEnd="8dp" | ||
android:layout_weight="1" | ||
android:onClick="saveLocation" | ||
android:text="@string/save_location" | ||
android:textColor="@color/white" /> | ||
</LinearLayout> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal"> | ||
|
||
<Button | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginEnd="8dp" | ||
android:layout_weight="1" | ||
android:onClick="downloadOfflineMap" | ||
android:text="@string/download_offline_map" | ||
android:textColor="@color/white" /> | ||
|
||
<Button | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginEnd="8dp" | ||
android:layout_weight="1" | ||
android:onClick="confirm" | ||
android:text="@string/confirm" | ||
android:textColor="@color/white" /> | ||
</LinearLayout> | ||
|
||
|
||
</LinearLayout> |