我一直在寻找这个星期的答案,所以请原谅,如果我看起来有点沮丧。这是因为我。Android |将导航抽屉添加到默认地图活动
提前,对不起,如果这个问题之前已被问过。我是Android新手(我主要做网络应用程序),对我来说这是一个全新的世界。所有帮助表示赞赏!
我想要做的是添加一个导航抽屉到mill maps活动的标准运行。我会如何去做这件事?我希望每个按钮都能够将地图重新映射到另一个地方。
虽然我们在这里,但我打算在地图上创建一个KML图层。如您所知,KML点内置了信息,因此当您点击/点击它们时,您可以看到信息。我想让KML点使用其内置信息打开导航抽屉。我很好用这个默认的Android点,但与KML东西赞赏。如果你想要一个参照系,认为像这样的JavaScript的例子,但与隐藏的大部分时间侧边栏:https://developers.google.com/maps/documentation/javascript/kml
MainActivity.java:
package us.tourismproject.jared.tourismprojectandroid;
import android.content.res.Resources;
import android.nfc.Tag;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MapStyleOptions;
import com.google.android.gms.maps.model.MarkerOptions;
public class MainActivity extends AppCompatActivity implements OnMapReadyCallback {
private static final String TAG = MainActivity.class.getSimpleName();
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 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);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
try {
// Customise the styling of the base map using a JSON object defined
// in a raw resource file.
boolean success = googleMap.setMapStyle(
MapStyleOptions.loadRawResourceStyle(
this, R.raw.style_json));
if (!success) {
Log.e(TAG, "Style parsing failed.");
}
} catch (Resources.NotFoundException e) {
Log.e(TAG, "Can't find style. Error: ", e);
}
// Position the map's camera near Sydney, Australia.
googleMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(-34, 151)));
}
}
activity_main.xml中
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="us.tourismproject.jared.tourismprojectandroid.MainActivity" />
感谢您的任何帮助提前。现在好日子!
你想要什么?您想在MainActivity中添加导航抽屉 –