Vẽ một marker
Tạo một marker mặc định với một InfoWindow
.
Ví dụ này cần một tập tin thứ hai là:
activity_main.xml
import android.app.Activity;
import android.os.Bundle;
import com.vietbando.vietbandosdk.annotations.MarkerOptions;
import com.vietbando.vietbandosdk.geometry.LatLng;
import com.vietbando.vietbandosdk.maps.MapView;
import com.vietbando.vietbandosdk.maps.vietbandoMap;
import com.vietbando.vietbandosdk.maps.OnMapReadyCallback;
public class MainActivity extends Activity {
private MapView mapView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(VietbandoMap VietbandoMap) {
VietbandoMap.addMarker(new MarkerOptions()
.position(new LatLng(10.7773973, 106.701278))
.title("Hello World!")
.snippet("Welcome to my marker."));
}
});
}
@Override
public void onResume() {
super.onResume();
mapView.onResume();
}
@Override
public void onPause() {
super.onPause();
mapView.onPause();
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mapView.onSaveInstanceState(outState);
}
@Override
public void onLowMemory() {
super.onLowMemory();
mapView.onLowMemory();
}
@Override
public void onDestroy() {
super.onDestroy();
mapView.onDestroy();
}
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:Vietbando="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<!-- Set the starting camera position and map style using xml-->
<com.Vietbando.vietbandosdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
Vietbando:access_token="<your access token here>"
Vietbando:center_latitude="10.7773973"
Vietbando:center_longitude="106.701278"
Vietbando:zoom="14"/>
</RelativeLayout>