Random r =newRandom();double randomValue = rangeMin +(rangeMax - rangeMin)* r.nextDouble();
テスト
for (int i = 1 ; i <=5 ; i++){
Random r = new Random();
double randomValue = 123.004722 + (145.816278 - 123.004722) * r.nextDouble();
System.out.println(randomValue);
}
public class MapsActivity extends FragmentActivity implements
OnMapReadyCallback, GoogleMap.OnMapLoadedCallback {
Marker marker;
Handler handler = new Handler();
BitmapDescriptor iconSanta;
BitmapDescriptor iconSanta01;
BitmapDescriptor iconSanta02;
BitmapDescriptor iconSanta03;
BitmapDescriptor iconSanta04;
BitmapDescriptor iconSanta05;
BitmapDescriptor iconSanta06;
BitmapDescriptor iconSanta07;
BitmapDescriptor iconSanta08;
BitmapDescriptor iconSanta09;
BitmapDescriptor iconSanta10;
Runnable runnable = new Runnable() {
@Override
public void run() {
switch (marker.getTag().toString()) {
case ("i"):
marker.setIcon(iconSanta01);
marker.setTag("1");
break;
case ("1"):
marker.setIcon(iconSanta02);
marker.setTag("2");
break;
case ("2"):
marker.setIcon(iconSanta03);
marker.setTag("3");
break;
case ("3"):
marker.setIcon(iconSanta04);
marker.setTag("4");
break;
case ("4"):
marker.setIcon(iconSanta05);
marker.setTag("5");
break;
case ("5"):
marker.setIcon(iconSanta06);
marker.setTag("6");
break;
case ("6"):
marker.setIcon(iconSanta07);
marker.setTag("7");
break;
case ("7"):
marker.setIcon(iconSanta08);
marker.setTag("8");
break;
case ("8"):
marker.setIcon(iconSanta09);
marker.setTag("9");
break;
case ("9"):
marker.setIcon(iconSanta10);
marker.setTag("10");
break;
case ("10"):
marker.setIcon(iconSanta01);
marker.setTag("1");
break;
}
handler.postDelayed(runnable, 200);
}
};
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// 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);
iconSanta = BitmapDescriptorFactory.fromResource(R.drawable.christmas_santa_sori_i);
iconSanta01 = BitmapDescriptorFactory.fromResource(R.drawable.christmas_santa_sori_01);
iconSanta02 = BitmapDescriptorFactory.fromResource(R.drawable.christmas_santa_sori_02);
iconSanta03 = BitmapDescriptorFactory.fromResource(R.drawable.christmas_santa_sori_03);
iconSanta04 = BitmapDescriptorFactory.fromResource(R.drawable.christmas_santa_sori_04);
iconSanta05 = BitmapDescriptorFactory.fromResource(R.drawable.christmas_santa_sori_05);
iconSanta06 = BitmapDescriptorFactory.fromResource(R.drawable.christmas_santa_sori_06);
iconSanta07 = BitmapDescriptorFactory.fromResource(R.drawable.christmas_santa_sori_07);
iconSanta08 = BitmapDescriptorFactory.fromResource(R.drawable.christmas_santa_sori_08);
iconSanta09 = BitmapDescriptorFactory.fromResource(R.drawable.christmas_santa_sori_09);
iconSanta10 = BitmapDescriptorFactory.fromResource(R.drawable.christmas_santa_sori_10);
}
/**
* 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;
LatLng fuji = new LatLng(35.362859, 138.730883);
BitmapDescriptor iconSanta = BitmapDescriptorFactory.fromResource(R.drawable.christmas_santa_sori_i);
MarkerOptions option = new MarkerOptions();
option.icon(iconSanta).position(fuji);
marker = mMap.addMarker(option);
mMap.moveCamera(CameraUpdateFactory.newLatLng(fuji));
mMap.setOnMapLoadedCallback(this);
}
@Override
public void onMapLoaded() {
marker.setIcon(iconSanta);
marker.setTag("i");
handler.post(runnable);
}
protected void onDestroy() {
super.onDestroy();
handler.removeCallbacks(runnable);
}
}
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// 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;
LatLng fuji = new LatLng(35.362859,138.730883);
BitmapDescriptor iconSanta = BitmapDescriptorFactory.fromResource(R.drawable.christmas_santa_sori_s);
MarkerOptions option = new MarkerOptions();
option.icon(iconSanta).position(fuji);
mMap.addMarker(option);
mMap.moveCamera(CameraUpdateFactory.newLatLng(fuji));
}
}