2013-03-15 2 views
8

午後。マーカーの配列を作成するGoogleマップV2

public void ParseQueryMap() { 
      ParseQuery query = new ParseQuery("MyObject"); 
      query.findInBackground(new FindCallback() { 
      public void done(List<ParseObject> myObject, ParseException e) { 
      if (e == null) { 

        for (int i = 0; i < myObject.size(); i++) { 

          commGet = myObject.get(i).getString("Comment"); 

          geo1Dub = myObject.get(i).getParseGeoPoint("location").getLatitude(); 
          geo2Dub = myObject.get(i).getParseGeoPoint("location").getLongitude(); 

         Location aLocation = new Location("first"); 
         aLocation.setLatitude(geo1Dub); 
         aLocation.setLongitude(geo2Dub); 
         Location bLocation = new Location("second"); 
         bLocation.setLatitude(location.getLatitude()); 
         bLocation.setLongitude(location.getLongitude()); 
         int distance = (int)aLocation.distanceTo(bLocation); 
           if (distance<rad) { // where "rad" radius display points 
            myMap.addMarker(new MarkerOptions().position(new LatLng(geo1Dub,geo2Dub)).title(commGet)         .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));  

           } else { 
           }                

         } 

      } else { 
        Toast.makeText(MainActivity.this, "Error!", Toast.LENGTH_SHORT).show(); 
       } 
      } 
     }); 

が、私はその大きさをテストするためのマーカーの配列を作成したい、それがゼロの場合は、その後、AlertDialogを示しています。私のアプリケーションでは、私はparse.com上のマーカーのためのデータベースからデータを抽出します。つまり、私はどれくらいの弾丸があるか知りたい。 ....私はマップ

+0

に示したどのように多くのマーカーを知りたいとの問題がある:あなたの助け

UPDATEいただきありがとうございますか! –

+0

List myObjectの各エントリにマーカーを追加するので、myObject.getSize()マーカーがあると思います。 – AlexVogel

+0

myObject.getSize()は、データベース内のレコード数を示します。私は自分のポジションとベースのポイントとの距離を計算し続ける計画を持っています。そこで、私は隣のマーカを知る必要があります。 –

答えて

27
// before loop: 
List<Marker> markers = new ArrayList<Marker>(); 

// inside your loop: 
Marker marker = myMap.addMarker(new MarkerOptions().position(new LatLng(geo1Dub,geo2Dub))); //... 
markers.add(marker); 

// after loop: 
markers.size(); 
+0

ありがとうございます。必要に応じてすべて –

関連する問題