相关疑难解决方法(0)

Android:在将标记保持在中心的同时拖动地图

我a,目前在MapActivity中获取设备的当前位置(lat,lng).现在我想让用户移动地图,同时将标记保持在中心位置.这意味着无论何时移动地图,都将更新当前位置.(对?)

我按照这个android如何在标记下移动地图以及如何在地图上附加像Uber和Lyft这样的灵活标记?但无法明确我的观念.

Activity_map.xml(这里我添加了ImageView)

<RelativeLayout 
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">

<fragment
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.MapFragment"
    />

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:src="@drawable/gps"
    />

 </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

我的MapActivity如下

 public class MapActivity extends FragmentActivity implements      OnMapReadyCallback,
    GoogleApiClient.ConnectionCallbacks,
    GoogleApiClient.OnConnectionFailedListener,
    LocationListener,GoogleMap.OnInfoWindowClickListener{

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_map);
   // int x =_st.jsonArray.length();
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        checkLocationPermission();
    }

    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

    fragmentOnMap = (FragmentOnMap)getFragmentManager().findFragmentById(R.id.fragment_bottom);
    getFragmentManager().beginTransaction().hide(fragmentOnMap); …
Run Code Online (Sandbox Code Playgroud)

android google-maps google-maps-markers android-location

9
推荐指数
2
解决办法
1万
查看次数

WifiP2pManager.discoverPeers 在 android 10 中失败

以下代码示例返回Error code: 0,这是android中内部错误的错误代码。是否有任何解决方法可以在 Android 10 设备中发现对等点?

                wifip2pmanager.discoverPeers(wifip2pmanagerChannel, new WifiP2pManager.ActionListener() {
                @Override
                public void onSuccess() {
                    status.setText("Peer Discovery Started");
                }

                @Override
                public void onFailure(int reason) {

                    status.setText("Error code:" + reason);
                }
            });
Run Code Online (Sandbox Code Playgroud)

android wifip2p peer-discovery android-10.0

5
推荐指数
2
解决办法
2474
查看次数