Android Open Source - android-maps-utils Tile Provider And Projection Demo From Project Back to project page android-maps-utils .
License The source code is released under:
Apache License
If you think the Android project android-maps-utils listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code package com.google.maps.android.utils.demo;
/ / w w w . j a v a 2 s . c o m
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Tile;
import com.google.android.gms.maps.model.TileOverlayOptions;
import com.google.android.gms.maps.model.TileProvider;
import com.google.maps.android.geometry.Point;
import com.google.maps.android.projection.SphericalMercatorProjection;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.List;
public class TileProviderAndProjectionDemo extends BaseDemoActivity {
@Override
protected void startDemo() {
PointTileOverlay pto = new PointTileOverlay();
pto.addPoint(new LatLng(0, 0));
pto.addPoint(new LatLng(21, -10));
getMap().addTileOverlay(new TileOverlayOptions().tileProvider(pto));
}
private class PointTileOverlay implements TileProvider {
private List<Point> mPoints = new ArrayList<Point>();
private int mTileSize = 256;
private SphericalMercatorProjection mProjection = new SphericalMercatorProjection(mTileSize);
private int mScale = 2;
private int mDimension = mScale * mTileSize;
@Override
public Tile getTile(int x, int y, int zoom) {
Matrix matrix = new Matrix();
float scale = (float ) Math.pow(2, zoom) * mScale;
matrix.postScale(scale, scale);
matrix.postTranslate(-x * mDimension, -y * mDimension);
Bitmap bitmap = Bitmap.createBitmap(mDimension, mDimension, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bitmap);
c.setMatrix(matrix);
for (Point p : mPoints) {
c.drawCircle((float ) p.x, (float ) p.y, 1, new Paint());
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
return new Tile(mDimension, mDimension, baos.toByteArray());
}
public void addPoint(LatLng latLng) {
mPoints.add(mProjection.toPoint(latLng));
}
}
}
Java Source Code List com.google.maps.android.MarkerManager.java com.google.maps.android.MathUtil.java com.google.maps.android.PolyUtil.java com.google.maps.android.SphericalUtil.java com.google.maps.android.clustering.ClusterItem.java com.google.maps.android.clustering.ClusterManager.java com.google.maps.android.clustering.Cluster.java com.google.maps.android.clustering.algo.Algorithm.java com.google.maps.android.clustering.algo.GridBasedAlgorithm.java com.google.maps.android.clustering.algo.NonHierarchicalDistanceBasedAlgorithm.java com.google.maps.android.clustering.algo.PreCachingAlgorithmDecorator.java com.google.maps.android.clustering.algo.StaticCluster.java com.google.maps.android.clustering.view.ClusterRenderer.java com.google.maps.android.clustering.view.DefaultClusterRenderer.java com.google.maps.android.geometry.Bounds.java com.google.maps.android.geometry.Point.java com.google.maps.android.heatmaps.Gradient.java com.google.maps.android.heatmaps.HeatmapTileProvider.java com.google.maps.android.heatmaps.WeightedLatLng.java com.google.maps.android.projection.Point.java com.google.maps.android.projection.SphericalMercatorProjection.java com.google.maps.android.quadtree.PointQuadTree.java com.google.maps.android.ui.BubbleDrawable.java com.google.maps.android.ui.BubbleIconFactory.java com.google.maps.android.ui.IconGenerator.java com.google.maps.android.ui.RotationLayout.java com.google.maps.android.ui.SquareTextView.java com.google.maps.android.utils.demo.BaseDemoActivity.java com.google.maps.android.utils.demo.BigClusteringDemoActivity.java com.google.maps.android.utils.demo.ClusteringDemoActivity.java com.google.maps.android.utils.demo.CustomMarkerClusteringDemoActivity.java com.google.maps.android.utils.demo.DistanceDemoActivity.java com.google.maps.android.utils.demo.HeatmapsDemoActivity.java com.google.maps.android.utils.demo.HeatmapsPlacesDemoActivity.java com.google.maps.android.utils.demo.IconGeneratorDemoActivity.java com.google.maps.android.utils.demo.MainActivity.java com.google.maps.android.utils.demo.MultiDrawable.java com.google.maps.android.utils.demo.MyItemReader.java com.google.maps.android.utils.demo.PolyDecodeDemoActivity.java com.google.maps.android.utils.demo.TileProviderAndProjectionDemo.java com.google.maps.android.utils.demo.model.MyItem.java com.google.maps.android.utils.demo.model.Person.java