5

을 모두 사용하여 안드로이드에 markererclusterer을하고 PLZ 나에게 올바른 에뮬레이터 사양을 알 수 있습니까 다음 링크어떻게</p> <p>I에 의해 시도 ...... 그것이 에뮬레이터의 오류 일 수 있습니다 ... 맵 apiv2 또는지도 API를 v3의

https://www.google.co.in/?gws_rd=cr&ei=iCf5Upm7KsWXrAedkoCoDg#q=marker+cluster+example+in+android 
http://karnshah8890.blogspot.in/2013/04/clustering-on-google-map-v2.html 
https://developers.google.com/maps/documentation/android/utility/marker-clustering 
https://developers.google.com/maps/documentation/android/utility/marker-clustering 
http://stackoverflow.com/questions/7447350/android-maps-point-clustering 
http://stackoverflow.com/questions/14204554/google-maps-marker-clusters-in-android 
https://github.com/twotoasters/clusterkraf/ 
https://github.com/nodesagency-mobile/Android-Google-Map-V2-Sample 
https://github.com/googlemaps/android-maps-utils/tree/master/demo/src/com/google/maps/android/utils/demo/model 
https://github.com/Bersh/MarkersCluster/blob/master/res/menu/activity_main.xml 
https://github.com/damianflannery/Polaris/blob/clustering/sample/src/com/cyrilmottier/android/polarissample/util/Config.java 
http://umut.tekguc.info/en/content/google-android-map-v2-step-step 
http://stackoverflow.com/questions/15495171/cluster-markers-in-google-maps-android-v2/15510054#15510054 

나는 구글 API 데모를 생성, 읽기 내가 너무 여러 번에 의해 시도했지만 그것은 오류를 보여줄 때마다 또한 웹 응용 프로그램을 사용하여 나에게 제안 그래서 클러스터 마커를 필요로하는 응용 프로그램을 구축을 위해 노력하고있다 map API v3 API를 사용하여 마커를 클러스터링 API v2 또는 apiv3 맵을 사용하여 앱을 빌드하십시오. 안드로이드 0123에서 초보자입니다.또는 나에게 내가 내 솔루션을 찾을 수있는 링크를 제공은

.............................mainactivity class.......................................... 

    package com.example.cluster; 

    import java.util.ArrayList; 

    import java.util.LinkedHashMap; 
    import java.util.concurrent.ExecutionException; 

    import android.graphics.Bitmap; 
    import android.graphics.BitmapFactory; 
    import android.graphics.Point; 
    import android.os.Bundle; 
    import android.support.v4.app.FragmentActivity; 
    import android.view.Menu; 

    import com.example.demo.MarkerClusterizer; 
    import com.google.android.gms.maps.CameraUpdateFactory; 
    import com.google.android.gms.maps.GoogleMap; 
    import com.google.android.gms.maps.MapFragment; 
    import com.google.android.gms.maps.model.BitmapDescriptorFactory; 
    import com.google.android.gms.maps.model.CameraPosition; 
    import com.google.android.gms.maps.model.LatLng; 
    import com.google.android.gms.maps.model.MarkerOptions; 

    public class MainActivity extends FragmentActivity { 
     private ArrayList<MarkerOptions> markers = new ArrayList<MarkerOptions>(); 
      private Bitmap markerImage; 
      private float oldZoom = 0; 
      private GoogleMap map; 
      private static final int INTERVAL = 25; 
      private LinkedHashMap<Point, ArrayList<MarkerOptions>> clusters; 
      private final double initLat1 = 40.462740; 
      private final double initLng1 = 30.039572; 
      private final double initLat2 = 48.462740; 
      private final double initLng2 = 35.039572; 
      private static final int MAP_ZOOM_LEVEL = 4; 

     @Override 
     protected void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 

      setContentView(R.layout.activity_main); 
      markerImage = BitmapFactory.decodeResource(this.getResources(), R.drawable.ic_launcher); 

      map= ((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap(); 
      map.getUiSettings().setMyLocationButtonEnabled(true); 
       LatLng position = new LatLng(initLat2, initLng2); 
       map.animateCamera(CameraUpdateFactory.newLatLngZoom(position, MAP_ZOOM_LEVEL)); 
       map.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() { 
        @Override 
        public void onCameraChange(CameraPosition cameraPosition) { 
         if (cameraPosition.zoom != oldZoom) { 
          try { 
           clusters = MarkerClusterizer.clusterMarkers(map, markers, INTERVAL); 
          } catch (ExecutionException e) { 
           e.printStackTrace(); 
          } catch (InterruptedException e) { 
           e.printStackTrace(); 
          } 
         } 
         oldZoom = cameraPosition.zoom; 
        } 
       }); 
       createMarkers(map); 
      } 

      @Override 
      public boolean onCreateOptionsMenu(Menu menu) { 
       getMenuInflater().inflate(R.menu.main, menu); 
       return true; 
      } 


      private void createMarkers(GoogleMap map) { 
       double initLat; 
       double initLng; 

       initLat = initLat1; 
       initLng = initLng1; 
       for (float i = 0; i < 2; i += 0.2) { 
        LatLng pos = new LatLng(initLat + i, initLng + i); 
        markers.add(new MarkerOptions().position(pos).icon(BitmapDescriptorFactory.fromBitmap(markerImage))); 
       } 

       initLat = initLat2; 
       initLng = initLng2; 
       for (float i = 0; i < 2; i += 0.2) { 
        LatLng pos = new LatLng(initLat + i, initLng); 
        markers.add(new MarkerOptions().position(pos).icon(BitmapDescriptorFactory.fromBitmap(markerImage))); 
       } 
       for (float i = 0; i < 2; i += 0.2) { 
        LatLng pos = new LatLng(initLat, initLng + i); 
        markers.add(new MarkerOptions().position(pos).icon(BitmapDescriptorFactory.fromBitmap(markerImage))); 
       } 

      } 
     } 
...............................markerclusterizer class............................... 
package com.example.demo; 

import java.util.ArrayList; 
import java.util.LinkedHashMap; 
import java.util.concurrent.ExecutionException; 

import android.graphics.Point; 
import android.os.AsyncTask; 

import com.google.android.gms.maps.GoogleMap; 
import com.google.android.gms.maps.Projection; 
import com.google.android.gms.maps.model.MarkerOptions; 

public class MarkerClusterizer { 
    private static GoogleMap map; 
    private static int interval; 
    private static final int DEFAULT_INTERVAL = 25; 


    public static LinkedHashMap<Point,ArrayList<MarkerOptions>>clusterMarkers(GoogleMap googleMap, ArrayList<MarkerOptions> markers) throws ExecutionException, InterruptedException { 
     return clusterMarkers(googleMap, markers, DEFAULT_INTERVAL); 
    } 
    @SuppressWarnings("unchecked") 
    public static LinkedHashMap<Point, ArrayList<MarkerOptions>> clusterMarkers(GoogleMap googleMap, ArrayList<MarkerOptions> markers, int i) throws ExecutionException, InterruptedException { 
     map=googleMap; 
     interval=i; 
     Projection projection=map.getProjection(); 
     LinkedHashMap<MarkerOptions, Point> points=new LinkedHashMap<MarkerOptions, Point>(); 
     for(MarkerOptions markerOptions:markers){ 
      points.put(markerOptions, projection.toScreenLocation(markerOptions.getPosition())); 
      markerOptions.title(""); 

     } 
     map.clear(); 
     CheckMarkersTask checkMarkersTask=new CheckMarkersTask(); 
     checkMarkersTask.execute(points); 



     return checkMarkersTask.get(); 

    } 

    private static class CheckMarkersTask extends AsyncTask<LinkedHashMap<MarkerOptions, Point>, Void, LinkedHashMap<Point, ArrayList<MarkerOptions>>> { 

     private double findDistance(float x1, float y1, float x2, float y2) { 
      return Math.sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))); 
     } 
     @Override 
     protected LinkedHashMap<Point, ArrayList<MarkerOptions>> doInBackground(LinkedHashMap<MarkerOptions, Point>... params) { 
      LinkedHashMap<Point, ArrayList<MarkerOptions>> clusters = new LinkedHashMap<Point, ArrayList<MarkerOptions>>(); 
      LinkedHashMap<MarkerOptions, Point> points = params[0]; 
      for (MarkerOptions markerOptions : points.keySet()) { //go thru all markers 
       Point point = points.get(markerOptions); 
       double minDistance = -1; //Currently found min distance. This need for finding nearest point. 
       Point nearestPoint = null; //Currently found nearest point 
       double currentDistance; 
       for (Point existingPoint : clusters.keySet()) { //try to find existing cluster for current marker 
        currentDistance = findDistance(point.x, point.y, existingPoint.x, existingPoint.y); 
        if ((currentDistance <= interval) && ((currentDistance < minDistance) || (minDistance == -1))) { 
         minDistance = currentDistance; 
         nearestPoint = existingPoint; 
        } 
       } 

       if (nearestPoint != null) { 
        clusters.get(nearestPoint).add(markerOptions); 
       } else { 
        ArrayList<MarkerOptions> markersForPoint = new ArrayList<MarkerOptions>(); 
        markersForPoint.add(markerOptions); 
        clusters.put(point, markersForPoint); 
       } 
      } 
      return clusters; 
     } 

     @Override 
     protected void onPostExecute(LinkedHashMap<Point, ArrayList<MarkerOptions>> clusters) { 
      for (Point point : clusters.keySet()) { 
       ArrayList<MarkerOptions> markersForPoint = clusters.get(point); 
       MarkerOptions mainMarker = markersForPoint.get(0); 
       int clusterSize = markersForPoint.size(); 
       if (clusterSize > 1) { 
        mainMarker.title(Integer.toString(clusterSize)); 
       } 

       map.addMarker(mainMarker); 
      } 
     } 
    } 
    } 


    ![..............activity_main.xml............................................... 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:paddingTop="@dimen/activity_vertical_margin" 
     tools:context=".MainActivity" > 

     <fragment 
      android:id="@+id/map" 
      android:name="com.google.android.gms.maps.MapFragment" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent"/>t 
    </RelativeLayout> 
..................manifest.xml................................................ 
<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.cluster" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk 
     android:minSdkVersion="8" 
     android:targetSdkVersion="17" /> 

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> 

    <permission 
     android:name="com.example.cluster.permission.MAPS_RECEIVE" 
     android:protectionLevel="signature" /> 

    <uses-permission android:name="com.example.demo.permission.MAPS_RECEIVE" /> 

    <uses-feature 
     android:glEsVersion="0x00020000" 
     android:required="true"/> 

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name="com.example.cluster.MainActivity" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 

     <meta-data 
      android:name="com.google.android.maps.v2.API_KEY" 
      android:value="AIzaSyDqFw-lJjvppil-ixpHjBolINPqJO2b83Q" /> 
    </application> 

</manifest>][1] 
+0

API v2는 더 이상 사용되지 않습니다. 지금까지 시도한 것은 무엇이고 오류는 무엇입니까? 몇 가지 코드를 보여주십시오. – MrUpsidown

+0

안녕하세요 @MrUpsidown 난 내가 지금까지 시도 내가 실수 – vaib

+0

을보고 나에게 sugeestion을주지하시기 바랍니다 것을 여기에 게시. 오류가 있다고하던가요? – vaib

답변

0

나는 당신이 안드로이드의지도를 개발하기위한 하나의 API 키를 생성 할 수있는 하나의 패키지 이름을 찾을 너무 많은 R의 $의 D를 할 수 있지만. 비록 내가 동일한 패키지 이름으로 다른 프로젝트에 2 3 api 키를 만들었습니다.

+1

하지만 주요 질문 에뮬레이터 스펙 관련이 map apiv2 또는 map api v3을 사용하여 android에서 markererclusterer를 수행하는 방법. –

0

PLZ 나에게 올바른 에뮬레이터 사양

을 난 정말 GenyMotion처럼 내 안드로이드 응용 프로그램을 테스트합니다 알 수 있습니까. 그것은 안드로이드가 제공하는 것보다 훨씬 낫다.

here에서 Genymotion을 다운로드

및 실제 장치에 대한

는 OpenGL을 장치 지원 확인 나중에

오류 MSG 장치에 opengles를 지원하지 않습니다 원하는 중 에뮬레이터를 추가 지도가 필요한 ES 버전 2.

마커 클러스터의 경우에는 문서 here를 읽을 수 있습니다.

+0

4.2.2 Google API를 사용하여 – vaib

+0

@vaib 나는 당신을 얻지 못했고 조금 설명 드리겠습니다 –

+0

kk 내가 보내 줄 것입니다 U 저에 대한 사양 아무것도하지만, 내가두면 PLZ 내가 마커 클러스터링 – vaib