com.google.maps.android.clustering.ClusterManager Java Examples
The following examples show how to use
com.google.maps.android.clustering.ClusterManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClusterMarkerActivity.java From AndroidDemoProjects with Apache License 2.0 | 6 votes |
private void initMarkers() { ClusterManager<ClusterMarkerLocation> clusterManager = new ClusterManager<ClusterMarkerLocation>( this, mGoogleMap ); mGoogleMap.setOnCameraChangeListener(clusterManager); double lat; double lng; Random generator = new Random(); for( int i = 0; i < 1000; i++ ) { lat = generator.nextDouble() / 3; lng = generator.nextDouble() / 3; if( generator.nextBoolean() ) { lat = -lat; } if( generator.nextBoolean() ) { lng = -lng; } clusterManager.addItem( new ClusterMarkerLocation( new LatLng( mCenterLocation.latitude + lat, mCenterLocation.longitude + lng ) ) ); } }
Example #2
Source File: VisibleClusteringDemoActivity.java From android-maps-utils with Apache License 2.0 | 6 votes |
@Override protected void startDemo(boolean isRestore) { DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); if (!isRestore) { getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(51.503186, -0.126446), 10)); } mClusterManager = new ClusterManager<>(this, getMap()); mClusterManager.setAlgorithm(new NonHierarchicalViewBasedAlgorithm<MyItem>( metrics.widthPixels, metrics.heightPixels)); getMap().setOnCameraIdleListener(mClusterManager); try { readItems(); } catch (JSONException e) { Toast.makeText(this, "Problem reading list of markers.", Toast.LENGTH_LONG).show(); } }
Example #3
Source File: CustomMarkerClusteringDemoActivity.java From android-maps-utils with Apache License 2.0 | 6 votes |
@Override protected void startDemo(boolean isRestore) { if (!isRestore) { getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(51.503186, -0.126446), 9.5f)); } mClusterManager = new ClusterManager<>(this, getMap()); mClusterManager.setRenderer(new PersonRenderer()); getMap().setOnCameraIdleListener(mClusterManager); getMap().setOnMarkerClickListener(mClusterManager); getMap().setOnInfoWindowClickListener(mClusterManager); mClusterManager.setOnClusterClickListener(this); mClusterManager.setOnClusterInfoWindowClickListener(this); mClusterManager.setOnClusterItemClickListener(this); mClusterManager.setOnClusterItemInfoWindowClickListener(this); addItems(); mClusterManager.cluster(); }
Example #4
Source File: DetailFragment.java From animation-samples with Apache License 2.0 | 5 votes |
@NonNull private ClusterManager.OnClusterItemClickListener<Detail> getOnClusterItemClickListener() { if (mOnClusterItemClickListener == null) { mOnClusterItemClickListener = new ClusterManager.OnClusterItemClickListener<Detail>() { @Override public boolean onClusterItemClick(Detail detail) { setDescriptionText(detail); return false; } }; } return mOnClusterItemClickListener; }
Example #5
Source File: ObservationClusterCollection.java From mage-android with Apache License 2.0 | 5 votes |
public ObservationClusterCollection(Context context, GoogleMap map) { this.context = context; clusterManager = new ClusterManager<ObservationClusterItem>(context, map); clusterManager.setAlgorithm(new PreCachingAlgorithmDecorator<ObservationClusterItem>(new GridBasedAlgorithm<ObservationClusterItem>())); clusterManager.setOnClusterItemClickListener(this); }
Example #6
Source File: BigClusteringDemoActivity.java From android-maps-utils with Apache License 2.0 | 5 votes |
@Override protected void startDemo(boolean isRestore) { if (!isRestore) { getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(51.503186, -0.126446), 10)); } mClusterManager = new ClusterManager<>(this, getMap()); getMap().setOnCameraIdleListener(mClusterManager); try { readItems(); } catch (JSONException e) { Toast.makeText(this, "Problem reading list of markers.", Toast.LENGTH_LONG).show(); } }
Example #7
Source File: MultiLayerDemoActivity.java From android-maps-utils with Apache License 2.0 | 5 votes |
private void addClusterItems(ClusterManager clusterManager) { InputStream inputStream = getResources().openRawResource(R.raw.radar_search); List<MyItem> items; try { items = new MyItemReader().read(inputStream); clusterManager.addItems(items); } catch (JSONException e) { Toast.makeText(this, "Problem reading list of markers.", Toast.LENGTH_LONG).show(); e.printStackTrace(); } }
Example #8
Source File: ClusteringViewModelDemoActivity.java From android-maps-utils with Apache License 2.0 | 5 votes |
@Override protected void startDemo(boolean isRestore) { if (!isRestore) { getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(51.503186, -0.126446), 10)); } DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); mViewModel.getAlgorithm().updateViewSize(metrics.widthPixels, metrics.heightPixels); mClusterManager = new ClusterManager<>(this, getMap()); mClusterManager.setAlgorithm(mViewModel.getAlgorithm()); getMap().setOnCameraIdleListener(mClusterManager); }
Example #9
Source File: DefaultClusterRenderer.java From android-maps-utils with Apache License 2.0 | 5 votes |
public DefaultClusterRenderer(Context context, GoogleMap map, ClusterManager<T> clusterManager) { mMap = map; mAnimate = true; mDensity = context.getResources().getDisplayMetrics().density; mIconGenerator = new IconGenerator(context); mIconGenerator.setContentView(makeSquareTextView(context)); mIconGenerator.setTextAppearance(R.style.amu_ClusterIcon_TextAppearance); mIconGenerator.setBackground(makeClusterBackground()); mClusterManager = clusterManager; }
Example #10
Source File: DefaultClusterRenderer.java From android-maps-utils with Apache License 2.0 | 4 votes |
@Override public void setOnClusterItemInfoWindowLongClickListener(ClusterManager.OnClusterItemInfoWindowLongClickListener<T> listener) { mItemInfoWindowLongClickListener = listener; }
Example #11
Source File: DetailFragment.java From animation-samples with Apache License 2.0 | 4 votes |
private void setMarkers(GoogleMap googleMap) { final List<Detail> locations = mGallery.getDetails(); ClusterManager<Detail> clusterManager = getClusterManager(googleMap); clusterManager.addItems(locations); googleMap.setOnCameraChangeListener(clusterManager); }
Example #12
Source File: DefaultClusterRenderer.java From android-maps-utils with Apache License 2.0 | 4 votes |
@Override public void setOnClusterItemInfoWindowClickListener(ClusterManager.OnClusterItemInfoWindowClickListener<T> listener) { mItemInfoWindowClickListener = listener; }
Example #13
Source File: DefaultClusterRenderer.java From android-maps-utils with Apache License 2.0 | 4 votes |
@Override public void setOnClusterItemClickListener(ClusterManager.OnClusterItemClickListener<T> listener) { mItemClickListener = listener; }
Example #14
Source File: DefaultClusterRenderer.java From android-maps-utils with Apache License 2.0 | 4 votes |
@Override public void setOnClusterInfoWindowLongClickListener(ClusterManager.OnClusterInfoWindowLongClickListener<T> listener) { mInfoWindowLongClickListener = listener; }
Example #15
Source File: DefaultClusterRenderer.java From android-maps-utils with Apache License 2.0 | 4 votes |
@Override public void setOnClusterInfoWindowClickListener(ClusterManager.OnClusterInfoWindowClickListener<T> listener) { mInfoWindowClickListener = listener; }
Example #16
Source File: DefaultClusterRenderer.java From android-maps-utils with Apache License 2.0 | 4 votes |
@Override public void setOnClusterClickListener(ClusterManager.OnClusterClickListener<T> listener) { mClickListener = listener; }
Example #17
Source File: MainActivity.java From ExamplesAndroid with Apache License 2.0 | 4 votes |
public OwnIconRendered(Context context, GoogleMap map, ClusterManager<MyItem> clusterManager) { super(context, map, clusterManager); }
Example #18
Source File: MainActivity.java From ExamplesAndroid with Apache License 2.0 | 4 votes |
private void setUpMapIfNeeded() { if (mGoogleMap != null) { return; } mGoogleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap(); if (mGoogleMap != null) { mClusterManager = new ClusterManager<MyItem>(this, mGoogleMap); mClusterManager.setRenderer(new OwnIconRendered(MainActivity.this, mGoogleMap, mClusterManager)); /* mClusterManager.setOnClusterInfoWindowClickListener(new ClusterManager.OnClusterInfoWindowClickListener<MyItem>() { @Override public void onClusterInfoWindowClick(Cluster<MyItem> cluster) { Toast.makeText(MainActivity.this,"csm",Toast.LENGTH_SHORT).show(); Log.e("Example"," Android"); } }); mClusterManager.setOnClusterClickListener(new ClusterManager.OnClusterClickListener<MyItem>() { @Override public boolean onClusterClick(Cluster<MyItem> cluster) { Toast.makeText(MainActivity.this,"csm",Toast.LENGTH_SHORT).show(); Log.e("ejemplo"," Android"); return false; } }); mClusterManager.setOnClusterItemInfoWindowClickListener(new ClusterManager.OnClusterItemInfoWindowClickListener<MyItem>() { @Override public void onClusterItemInfoWindowClick(MyItem myItem) { Toast.makeText(MainActivity.this,"csm",Toast.LENGTH_SHORT).show(); Log.e("csm"," Android"); } }); mClusterManager.setOnClusterItemClickListener(new ClusterManager.OnClusterItemClickListener<MyItem>() { @Override public boolean onClusterItemClick(MyItem myItem) { Toast.makeText(MainActivity.this,"csm",Toast.LENGTH_SHORT).show(); Log.e("LMAO"," Android"); return false; } }); */ mGoogleMap.setOnCameraChangeListener(mClusterManager); mGoogleMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { Toast.makeText(MainActivity.this,marker.getTitle(),Toast.LENGTH_SHORT).show(); } }); getList(); mGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(19.0337592, -98.1869488), 1)); } }
Example #19
Source File: PlacesFragment.java From narrate-android with Apache License 2.0 | 4 votes |
private void setup() { mSheetAdapter = new EntriesRecyclerAdapter(mainActivity.entries); mapView = (MapView) mRoot.findViewById(R.id.mapView); mapView.setAlwaysDrawnWithCacheEnabled(true); mapView.setPersistentDrawingCache(MapView.PERSISTENT_ALL_CACHES); mapView.onCreate(null); try { MapsInitializer.initialize(getActivity().getApplicationContext()); } catch (Exception e) { e.printStackTrace(); } map = mapView.getMap(); mClusterManager = new ClusterManager<EntryMarker>(getActivity(), map); map.setOnCameraChangeListener(mClusterManager); map.setOnMarkerClickListener(mClusterManager); mClusterManager.setOnClusterClickListener(this); mClusterManager.setOnClusterItemClickListener(this); onDataUpdated(); if (ActivityCompat.checkSelfPermission(mainActivity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(mainActivity, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { map.setMyLocationEnabled(false); if ( getActivity() != null && getActivity().getSystemService(Context.LOCATION_SERVICE) != null) { String locationProvider = LocationManager.NETWORK_PROVIDER; LocationManager mLocationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); lastKnownLocation = mLocationManager.getLastKnownLocation(locationProvider); } new Handler().postDelayed(new Runnable() { @Override public void run() { if ( !isAdded() ) return; if ( lastKnownLocation != null ) { LatLng position = new LatLng(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude()); CameraPosition newPosition = CameraPosition.fromLatLngZoom(position, 12.0f); map.animateCamera(CameraUpdateFactory.newCameraPosition(newPosition)); } } }, 500); } }
Example #20
Source File: DetailMarkerRenderer.java From animation-samples with Apache License 2.0 | 4 votes |
public DetailMarkerRenderer(Context context, final GoogleMap map, final ClusterManager<Detail> clusterManager) { super(context, map, clusterManager); mMarkerDrawable = ContextCompat.getDrawable(context, R.drawable.map_pin); map.setInfoWindowAdapter(clusterManager.getMarkerManager()); }
Example #21
Source File: ClusterRenderer.java From android-maps-utils with Apache License 2.0 | votes |
void setOnClusterItemClickListener(ClusterManager.OnClusterItemClickListener<T> listener);
Example #22
Source File: ClusterRenderer.java From android-maps-utils with Apache License 2.0 | votes |
void setOnClusterItemInfoWindowClickListener(ClusterManager.OnClusterItemInfoWindowClickListener<T> listener);
Example #23
Source File: ClusterRenderer.java From android-maps-utils with Apache License 2.0 | votes |
void setOnClusterItemInfoWindowLongClickListener(ClusterManager.OnClusterItemInfoWindowLongClickListener<T> listener);
Example #24
Source File: ClusterRenderer.java From android-maps-utils with Apache License 2.0 | votes |
void setOnClusterInfoWindowLongClickListener(ClusterManager.OnClusterInfoWindowLongClickListener<T> listener);
Example #25
Source File: ClusterRenderer.java From android-maps-utils with Apache License 2.0 | votes |
void setOnClusterInfoWindowClickListener(ClusterManager.OnClusterInfoWindowClickListener<T> listener);
Example #26
Source File: ClusterRenderer.java From android-maps-utils with Apache License 2.0 | votes |
void setOnClusterClickListener(ClusterManager.OnClusterClickListener<T> listener);