我一直在尋找這個星期的答案,所以請原諒,如果我看起來有點沮喪。這是因爲我。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中添加導航抽屜 –