Code example for MarkerOptions

Methods: iconpositionsnippettitle

0
package jp.hackugyo.gatemail.ui.activity; 
 
import android.graphics.Color; 
import android.os.Bundle; 
 
import com.google.android.gms.maps.GoogleMap; 
import com.google.android.gms.maps.GoogleMap.OnMarkerClickListener; 
import com.google.android.gms.maps.SupportMapFragment; 
import com.google.android.gms.maps.model.BitmapDescriptorFactory; 
import com.google.android.gms.maps.model.CircleOptions; 
import com.google.android.gms.maps.model.LatLng; 
import com.google.android.gms.maps.model.Marker; 
import com.google.android.gms.maps.model.MarkerOptions; 
import com.google.android.gms.maps.model.PolygonOptions; 
 
import jp.hackugyo.gatemail.R; 
import jp.hackugyo.gatemail.model.withoutdb.MapField; 
import jp.hackugyo.gatemail.ui.AbsFragmentActivity; 
import jp.hackugyo.gatemail.util.LogUtils; 
 
public class MapOfTheEarthActivity extends AbsFragmentActivity { 
    @SuppressWarnings("unused") 
    private final MapOfTheEarthActivity self = this;
    private GoogleMap mGoogleMap;
 
    /*********************************************** 
     * Life Cycle * 
     ***********************************************/ 
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map_of_the_earth); 
    } 
 
    @Override 
    protected void onStart() { 
        super.onStart(); 
    } 
 
    @Override 
    protected void onResume() { 
        super.onResume(); 
        if (mGoogleMap == null) {
            mGoogleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
        } 
        if (mGoogleMap != null) {
            mGoogleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID); // ラベルつき航空写真モード
 
            mGoogleMap.setOnMarkerClickListener(new OnMarkerClickListener() {
                @Override 
                public boolean onMarkerClick(Marker marker) {
                    marker.showInfoWindow(); // ピンの上にバルーンを表示
                    return false; 
                } 
            }); 
 
            LatLng[] here = { //
            // 
                    new LatLng(35.6472069, 139.7013787),//
                    new LatLng(35.6472069, 139.701), //
                    new LatLng(35.6471, 139.701),//
                    new LatLng(35.6471, 139.7013787),//
                    new LatLng(35.6473, 139.702),//
            }; 
            LogUtils.i("drawn"); 
            MapField field1 = new MapField("だいかんやま", here);
            drawField(field1);
 
            LatLng[] here2 = { //
            // 
            new LatLng(35.64705, 139.70),//
            }; 
            LogUtils.i("drawn"); 
            MapField field2 = new MapField("だいかんやま", here2);
            field2.setColorRgb(128, 128, 0);
            drawField(field2);
        } 
    } 
 
    @Override 
    protected void onPause() { 
        // TODO Auto-generated method stub 
        super.onPause(); 
    } 
 
    /*********************************************** 
     * draw Fields * 
     ***********************************************/ 
 
    private void drawField(MapField field) {
        // マーカー定義 
        MarkerOptions markerOptions = new MarkerOptions();
        markerOptions.title(field.getName()); // 名前を設定 
        markerOptions.snippet(field.getMemo()); // 説明を設定
        // マーカーの座標を設定(区画の中心を自動算出)  
        markerOptions.position(calcCenter(field.getVertexes()));
        // 色を設定  
        markerOptions.icon(BitmapDescriptorFactory.defaultMarker(field.getColorHue()));
        // マップにマーカーを追加  
        mGoogleMap.addMarker(markerOptions);
        // 区画を描画 
        final LatLng[] vertexes = field.getVertexes();
        if (vertexes == null || vertexes.length == 0) return;
Experience pair programming with AI  Get Codota for Java