android maps api v2 adding multiple circles

johnsonjp34

I'm trying to add a circle to the map every second with an update from the gps. How would I pass the Location location = locationmanager.getLastKnownLocation(provider); to make a new circle every second? Here is what I have so far.

public class MainActivity extends Activity implements LocationListener{

Location myLocation;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


GoogleMap mMap;
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();


mMap.setMyLocationEnabled(true);





Location myLocation;

LocationManager locationmanager = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria cr = new Criteria();
String provider = locationmanager.getBestProvider(cr, true);
Location location = locationmanager.getLastKnownLocation(provider);

locationmanager.requestLocationUpdates(provider, 1000, 0, (LocationListener) this);

CircleOptions circleOptions = new CircleOptions()
.center(new LatLng( , ))
.radius(3.048); // In meters

Circle circle = mMap.addCircle(circleOptions);



 }

}

MaciejGórski

Instead of using getLastKnownLocation, you are better of using LocationListener's callback: onLocationChange for that, which you seem to implement and request already.

To convert Location to LatLng use:

new LatLng(location.getLatitude(), location.getLongitude())

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Adding Multiple Markers in real time google maps v2 android

分類Dev

Google Maps Android API v2

分類Dev

Removing multiple circles google maps api

分類Dev

Google Maps Android API v2 Authorization failure

分類Dev

Can't connect to Google Maps Api Android V2

分類Dev

Overlay an image on google maps android api v2

分類Dev

Adding multiple circles to MapKit

分類Dev

Android 2.3およびgoogle maps API v2

分類Dev

Android Google Maps API v2:方位位置を取得する

分類Dev

Add animation to default marker on setOnMarkerClickListener maps api v2 android

分類Dev

How to manage Markers well using google maps api v2 on android

分類Dev

Draw circles around multiple markers in Maps

分類Dev

Google android maps api v2マーカータイトルを常に表示

分類Dev

How to set api key for Google maps v2

分類Dev

How to download and use offline maps in Map API V2?

分類Dev

Google Maps V2 - API key not found Error Message

分類Dev

Google Maps Activity V2 Android Studio

分類Dev

access maps v2 with calabash-android

分類Dev

access maps v2 with calabash-android

分類Dev

Google Maps Android API v2のMapFragmentにカスタムコントロールを追加する方法

分類Dev

Google Maps Android API V2で白地図しか入手できないのはなぜですか?

分類Dev

Office api V2 authentication multiple resources in scopes

分類Dev

Google map API v2 Android - Markers & scale

分類Dev

How to change Language on Android google map V2 api

分類Dev

Fade In circles in Google Maps

分類Dev

displaying Google Maps API v2 on real device/emulator. can't figure out error

分類Dev

Maps API v2で座標を選択する方法は?

分類Dev

Google Maps V2 APIマニフェスト、問題。

分類Dev

Circle on Google Maps for Android v2 is flickering when size changes by seekbar

Related 関連記事

  1. 1

    Adding Multiple Markers in real time google maps v2 android

  2. 2

    Google Maps Android API v2

  3. 3

    Removing multiple circles google maps api

  4. 4

    Google Maps Android API v2 Authorization failure

  5. 5

    Can't connect to Google Maps Api Android V2

  6. 6

    Overlay an image on google maps android api v2

  7. 7

    Adding multiple circles to MapKit

  8. 8

    Android 2.3およびgoogle maps API v2

  9. 9

    Android Google Maps API v2:方位位置を取得する

  10. 10

    Add animation to default marker on setOnMarkerClickListener maps api v2 android

  11. 11

    How to manage Markers well using google maps api v2 on android

  12. 12

    Draw circles around multiple markers in Maps

  13. 13

    Google android maps api v2マーカータイトルを常に表示

  14. 14

    How to set api key for Google maps v2

  15. 15

    How to download and use offline maps in Map API V2?

  16. 16

    Google Maps V2 - API key not found Error Message

  17. 17

    Google Maps Activity V2 Android Studio

  18. 18

    access maps v2 with calabash-android

  19. 19

    access maps v2 with calabash-android

  20. 20

    Google Maps Android API v2のMapFragmentにカスタムコントロールを追加する方法

  21. 21

    Google Maps Android API V2で白地図しか入手できないのはなぜですか?

  22. 22

    Office api V2 authentication multiple resources in scopes

  23. 23

    Google map API v2 Android - Markers & scale

  24. 24

    How to change Language on Android google map V2 api

  25. 25

    Fade In circles in Google Maps

  26. 26

    displaying Google Maps API v2 on real device/emulator. can't figure out error

  27. 27

    Maps API v2で座標を選択する方法は?

  28. 28

    Google Maps V2 APIマニフェスト、問題。

  29. 29

    Circle on Google Maps for Android v2 is flickering when size changes by seekbar

ホットタグ

アーカイブ