Created
September 28, 2016 07:31
-
-
Save mnafian/576d407060404ef6b971b577dd2b59cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Map2 extends AppCompatActivity implements OnMapReadyCallback { | |
private List<LatLng> dataLatlng = new ArrayList<>(); | |
private double a, b; | |
private LatLng data; | |
private int incrementNext = 0; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_map2); | |
Button btnNext; // ini maksudnya mau dibuat next gak? atau gimana aku cuma nerka | |
btnNext = (Button) findViewById(R.id.btn_map_dua)) // ini deklarasi view button | |
// add data manual | |
a = -8.18330000; | |
b = 131.08330000; | |
data = new LatLng(a, b); | |
dataLatLng.add(data); | |
a = -8.09546270; | |
b = 112.16090560; | |
data = new LatLng(a, b); | |
dataLatLng.add(data); | |
SupportMapFragment mapFragment = | |
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map_dua); | |
mapFragment.getMapAsync(this); | |
} | |
/** | |
* This is where we can add markers or lines, add listeners or move the camera. In this case, | |
* we | |
* just add a marker near Africa. | |
*/ | |
@Override | |
public void onMapReady(GoogleMap map) { | |
btnNext.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
if (increment == 0) { | |
cameraMover(dataLatLng.get(increment)); // biar lebih sedikit nulis code, jadi dibuatin method | |
increment += 1; | |
} else if (increment == 1) { | |
cameraMover(dataLatLng.get(increment)); | |
increment -= 1; | |
} | |
} | |
}); | |
foreach(int data : dataLatlng) { | |
map.addMarker(new MarkerOptions().position(data).title("Mukidi Get Data Tambal Ban")); | |
} | |
} | |
private void cameraMover(LatLng data) { | |
map.moveCamera(CameraUpdateFactory.newLatLngZoom(data, 18)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment