Oliver Lauter
- Forum-Beiträge: 5
20.06.2013, 17:14:59 via Website
20.06.2013 17:14:59 via Website
Hallo liebes Forum,
Android Neuling braucht mal kurz eine Erleuchtung :-)
So erzeuge ich einen Circle um meine aktuelle Position auf einer Map.
Soweit so gut, nun habe ich einen Alert Dialog in dem man den MapZoom verändern kann.
Bei entsprechendem Klick auf einen radioButton soll auch der Circle seine Größe ändern. Also muß das ganze irgendwie
in die Schleife. Leider funktioniert es nicht, bekomme das leider nicht hin :-(
Jat jemand ne Idee?
Gruß
Olli
Android Neuling braucht mal kurz eine Erleuchtung :-)
So erzeuge ich einen Circle um meine aktuelle Position auf einer Map.
1public void onLocationChanged(Location location) {
2
3 LatLng latlng = new LatLng(location.getLatitude(), location.getLongitude());
4 CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latlng, Zoomwert);
5 googleMap.animateCamera(cameraUpdate);
6 locationManager.removeUpdates(this);// TODO Auto-generated method stub
7
8
9 CircleOptions circleOptions = new CircleOptions()
10 .center(latlng) //set center
11 .radius(rad) //set radius in meters
12 .fillColor(0x100000ff) //default
13 .strokeColor(Color.GRAY)
14 .strokeWidth(1);
15
16 Circle myCircle = googleMap.addCircle(circleOptions);
17 }
2
3 LatLng latlng = new LatLng(location.getLatitude(), location.getLongitude());
4 CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latlng, Zoomwert);
5 googleMap.animateCamera(cameraUpdate);
6 locationManager.removeUpdates(this);// TODO Auto-generated method stub
7
8
9 CircleOptions circleOptions = new CircleOptions()
10 .center(latlng) //set center
11 .radius(rad) //set radius in meters
12 .fillColor(0x100000ff) //default
13 .strokeColor(Color.GRAY)
14 .strokeWidth(1);
15
16 Circle myCircle = googleMap.addCircle(circleOptions);
17 }
Soweit so gut, nun habe ich einen Alert Dialog in dem man den MapZoom verändern kann.
1builder.setSingleChoiceItems(items,-1, new DialogInterface.OnClickListener() {
2
3 @Override
4 public void onClick(DialogInterface dialog, int which) {
5 // TODO Auto-generated method stub
6 //LinearLayout ll=(LinearLayout)findViewById(R.id.linear);
7
8 if("3KM".equals(items[which]))
9 {
10 // stelle Zoomwert Variable auf Umkreis 5Kilometer
11 Zoomwert=12;
12 Toast.makeText(getApplicationContext(), "Yipihaha", Toast.LENGTH_LONG).show();
13 CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(Zoomwert);
14 googleMap.animateCamera(cameraUpdate);
15
16
17 }
18 else if("6KM".equals(items[which]))
19 {
20 Zoomwert=11;
21 Toast.makeText(getApplicationContext(), "Yipihaha", Toast.LENGTH_LONG).show();
22 CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(Zoomwert);
23 googleMap.animateCamera(cameraUpdate);
24
25 }
26 else if("15KM".equals(items[which]))
27 {
28
29 Zoomwert=10;
30 Toast.makeText(getApplicationContext(), "Yipihaha", Toast.LENGTH_LONG).show();
31 CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(Zoomwert);
32 googleMap.animateCamera(cameraUpdate);
33
34 }
35 else if("Über15KM".equals(items[which]))
36 {
37
38
39 Zoomwert=6;
40 Toast.makeText(getApplicationContext(), "Yipihaha", Toast.LENGTH_LONG).show();
41 CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(Zoomwert);
42 googleMap.animateCamera(cameraUpdate);
43
44 }
45
46 }
47
48 });
49
50 builder.show();
2
3 @Override
4 public void onClick(DialogInterface dialog, int which) {
5 // TODO Auto-generated method stub
6 //LinearLayout ll=(LinearLayout)findViewById(R.id.linear);
7
8 if("3KM".equals(items[which]))
9 {
10 // stelle Zoomwert Variable auf Umkreis 5Kilometer
11 Zoomwert=12;
12 Toast.makeText(getApplicationContext(), "Yipihaha", Toast.LENGTH_LONG).show();
13 CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(Zoomwert);
14 googleMap.animateCamera(cameraUpdate);
15
16
17 }
18 else if("6KM".equals(items[which]))
19 {
20 Zoomwert=11;
21 Toast.makeText(getApplicationContext(), "Yipihaha", Toast.LENGTH_LONG).show();
22 CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(Zoomwert);
23 googleMap.animateCamera(cameraUpdate);
24
25 }
26 else if("15KM".equals(items[which]))
27 {
28
29 Zoomwert=10;
30 Toast.makeText(getApplicationContext(), "Yipihaha", Toast.LENGTH_LONG).show();
31 CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(Zoomwert);
32 googleMap.animateCamera(cameraUpdate);
33
34 }
35 else if("Über15KM".equals(items[which]))
36 {
37
38
39 Zoomwert=6;
40 Toast.makeText(getApplicationContext(), "Yipihaha", Toast.LENGTH_LONG).show();
41 CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(Zoomwert);
42 googleMap.animateCamera(cameraUpdate);
43
44 }
45
46 }
47
48 });
49
50 builder.show();
Bei entsprechendem Klick auf einen radioButton soll auch der Circle seine Größe ändern. Also muß das ganze irgendwie
in die Schleife. Leider funktioniert es nicht, bekomme das leider nicht hin :-(
Jat jemand ne Idee?
Gruß
Olli
— geändert am 20.06.2013, 22:06:10
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.