use of com.google.android.libraries.maps.model.LatLng in project android-maps-utils by googlemaps.
the class HeatmapsDemoActivity method readItems.
// Datasets from http://data.gov.au
private ArrayList<LatLng> readItems(int resource) throws JSONException {
ArrayList<LatLng> list = new ArrayList<>();
InputStream inputStream = getResources().openRawResource(resource);
String json = new Scanner(inputStream).useDelimiter("\\A").next();
JSONArray array = new JSONArray(json);
for (int i = 0; i < array.length(); i++) {
JSONObject object = array.getJSONObject(i);
double lat = object.getDouble("lat");
double lng = object.getDouble("lng");
list.add(new LatLng(lat, lng));
}
return list;
}
use of com.google.android.libraries.maps.model.LatLng in project android-maps-utils by googlemaps.
the class IconGeneratorDemoActivity method startDemo.
@Override
protected void startDemo(boolean isRestore) {
if (!isRestore) {
getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-33.8696, 151.2094), 10));
}
IconGenerator iconFactory = new IconGenerator(this);
addIcon(iconFactory, "Default", new LatLng(-33.8696, 151.2094));
iconFactory.setColor(Color.CYAN);
addIcon(iconFactory, "Custom color", new LatLng(-33.9360, 151.2070));
iconFactory.setRotation(90);
iconFactory.setStyle(IconGenerator.STYLE_RED);
addIcon(iconFactory, "Rotated 90 degrees", new LatLng(-33.8858, 151.096));
iconFactory.setContentRotation(-90);
iconFactory.setStyle(IconGenerator.STYLE_PURPLE);
addIcon(iconFactory, "Rotate=90, ContentRotate=-90", new LatLng(-33.9992, 151.098));
iconFactory.setRotation(0);
iconFactory.setContentRotation(90);
iconFactory.setStyle(IconGenerator.STYLE_GREEN);
addIcon(iconFactory, "ContentRotate=90", new LatLng(-33.7677, 151.244));
iconFactory.setRotation(0);
iconFactory.setContentRotation(0);
iconFactory.setStyle(IconGenerator.STYLE_ORANGE);
addIcon(iconFactory, makeCharSequence(), new LatLng(-33.77720, 151.12412));
}
use of com.google.android.libraries.maps.model.LatLng in project android-maps-utils by googlemaps.
the class VisibleClusteringDemoActivity method startDemo.
@Override
protected void startDemo(boolean isRestore) {
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int widthDp = (int) (metrics.widthPixels / metrics.density);
int heightDp = (int) (metrics.heightPixels / metrics.density);
if (!isRestore) {
getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(51.503186, -0.126446), 10));
}
mClusterManager = new ClusterManager<>(this, getMap());
mClusterManager.setAlgorithm(new NonHierarchicalViewBasedAlgorithm<>(widthDp, heightDp));
getMap().setOnCameraIdleListener(mClusterManager);
try {
readItems();
} catch (JSONException e) {
Toast.makeText(this, "Problem reading list of markers.", Toast.LENGTH_LONG).show();
}
}
use of com.google.android.libraries.maps.model.LatLng in project android-maps-utils by googlemaps.
the class ZoomClusteringDemoActivity method startDemo.
@Override
protected void startDemo(boolean isRestore) {
if (!isRestore) {
getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(18.528146, 73.797726), 9.5f));
}
ClusterManager<MyItem> clusterManager = new ClusterManager<>(this, getMap());
getMap().setOnCameraIdleListener(clusterManager);
// Initialize renderer
ZoomBasedRenderer renderer = new ZoomBasedRenderer(this, getMap(), clusterManager);
clusterManager.setRenderer(renderer);
// Set click listeners
clusterManager.setOnClusterClickListener(this);
clusterManager.setOnClusterInfoWindowClickListener(this);
clusterManager.setOnClusterItemClickListener(this);
clusterManager.setOnClusterItemInfoWindowClickListener(this);
String snippet = "This item wouldn't have changed to a marker if we didn't override shouldRenderAsCluster() AND shouldRender()";
// Add items
clusterManager.addItem(new MyItem(18.528146, 73.797726, "Loc1", snippet));
clusterManager.addItem(new MyItem(18.545723, 73.917202, "Loc2", snippet));
}
use of com.google.android.libraries.maps.model.LatLng in project android-maps-utils by googlemaps.
the class DistanceDemoActivity method startDemo.
@Override
protected void startDemo(boolean isRestore) {
mTextView = findViewById(R.id.textView);
if (!isRestore) {
getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-33.8256, 151.2395), 10));
}
getMap().setOnMarkerDragListener(this);
mMarkerA = getMap().addMarker(new MarkerOptions().position(new LatLng(-33.9046, 151.155)).draggable(true));
mMarkerB = getMap().addMarker(new MarkerOptions().position(new LatLng(-33.8291, 151.248)).draggable(true));
mPolyline = getMap().addPolyline(new PolylineOptions().geodesic(true));
Toast.makeText(this, "Drag the markers!", Toast.LENGTH_LONG).show();
showDistance();
}
Aggregations