Skip navigation

Category Archives: map

The Elements of Amazon Maps

The Amazon Maps API consists of a core set of classes that combine to provide mapping capabilities in Android applications on the Kindle Fire. The key classes are:

MapActivity – A subclass of the Android Activity class, this provides the base class for activities that need to provide map support. Any activity that needs to work with maps must be derived from this class.
MapView – Provides the canvas onto which the map is drawn.
MapController – Provides an interface for managing an existing map. This class includes capabilities such as setting both the center coordinates of the map and the current zoom level.
ItemizedOverlay – A class specifically designed to overlay information onto a map. For example, an overlay might be used to mark all the locations of the public libraries in a town. A single overlay can contain multiple items, each represented by an OverlayItem instance. An onTap() callback method may be implemented to pop up additional information about a location when tapped by the user.
OverlayItem – Used to represent each item in an ItemizedOverlay. Each item has associated with it a location on the map and an optional image to mark the location.
MyLocationOverlay – A special-purpose overlay designed specifically to display the current location of the device on the map view.
Overlay – A general-purpose overlay class provided primarily to allow transparent effects or content to be placed on top of the map.

You can use the Original documentation from gMaps V1: https://developers.google.com/maps/documentation/android/v1/hello-mapview

IMPORTANT LINKS/NOTEs:

  • You need to create you MD5 certificate into your free (thx) Amazon developer account to enable the maps on your app.
  • You will need A REGISTERED KINDLE FIRE TO SEE THE MAP it does not work in other case (also enable the location on settings)
  • getLatitudeSpan() Returns the difference in microdegrees(decimal degrees multiplied by one million). between the latitude of the top edge of the MapView and the latitude of the bottom edge. * 1E6 or / 1E6
  • Useful to replace the typical markers: https://developer.amazon.com/public/binaries/content/assets/javadoc/fire-phone/reference/com/amazon/geo/maps/overlayitem.html
  • http://www.techotopia.com/index.php/Marking_Android_Map_Locations_using_Amazon_Map_Overlays

Example of extension of Maps to calculate user interactions and refresh for instance the Overlay

package your_package

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import com.amazon.geo.maps.GeoPoint;
import com.amazon.geo.maps.MapView;

/**
 * Created by victoriza on 18/07/14.
 */

public class ExplorerAmazonMapView extends MapView {

	private static final String TAG = ExplorerAmazonMapView.class.getSimpleName();

	private static final int DURATION_DEFAULT = 700;

	private OnRegionChangedListener onRegionChangedListener;
	private GeoPoint previousMapCenter;
	private int previousZoomLevel;

	// This is the duration between when the user stops moving the map around and when the onRegionEndChange event fires.
	private int changeDuration;

	private boolean isTouched = false;
	private boolean regionChanging = false;

	private Runnable onRegionEndChangeTask = new Runnable() {
		public void run() {
			regionChanging = false;
			previousMapCenter = getMapCenter();
			previousZoomLevel = getZoomLevel();
			if (onRegionChangedListener != null) {
				onRegionChangedListener.onRegionEndChange(ExplorerAmazonMapView.this, previousMapCenter, previousZoomLevel);
			}
		}
	};

	public ExplorerAmazonMapView(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	public ExplorerAmazonMapView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		init();
	}

	public ExplorerAmazonMapView(Context context, String apiKey) {
		super(context, apiKey);
		init();
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		isTouched = event.getAction() != MotionEvent.ACTION_UP;
		return super.onTouchEvent(event);
	}

	@Override
	public void computeScroll() {
		super.computeScroll();

		// If the map region is still changing (user is still scrolling or zooming), reset timer for onRegionEndChange.
		if ((!isTouched && !getMapCenter().equals(previousMapCenter)) || (previousZoomLevel != getZoomLevel())) {

			// If the region has just begun changing, fire off onRegionBeginChange event.
			if (!regionChanging) {
				regionChanging = true;
				if (onRegionChangedListener != null) {
					onRegionChangedListener.onRegionBeginChange(this, previousMapCenter, previousZoomLevel);
				}
			}

			// Reset timer for onRegionEndChange.
			removeCallbacks(onRegionEndChangeTask);
			postDelayed(onRegionEndChangeTask, changeDuration);
		}
	}

	private void init() {
		changeDuration = DURATION_DEFAULT;
		previousMapCenter = getMapCenter();
		previousZoomLevel = getZoomLevel();
	}

	public void setOnRegionChangedListener(OnRegionChangedListener listener) {
		onRegionChangedListener = listener;
	}

	public void setChangeDuration(int duration) {
		changeDuration = duration;
	}

	public interface OnRegionChangedListener {
		public abstract void onRegionBeginChange(ExplorerAmazonMapView explorerMapView, GeoPoint geoPoint, int zoomLevel);

		public abstract void onRegionEndChange(ExplorerAmazonMapView explorerMapView, GeoPoint geoPoint, int zoomLevel);
	}
}

Step 1

Start emulator your emulator (and go for coffee (it takes FOREVER))

Step 2
Go to your ..sdk\platform-tools\
path (skip if you added the adb executable to your context path)

Step 3
Download the apps that you need to install ( basically the Google Suit)
Yeah search over the internet or root your Android phone and get the .apk files from there
Step 4
adb shell mount -o remount,YOUR_ADV_NAME_HERE -t yaffs2 /dev/block/mtdblock0 /system
adb shell chmod 777 /system/app
adb push GoogleLoginService.apk /system/app/
adb push GoogleServicesFramework.apk /system/app/

Step 5
adb install com.google.android.apps.maps-1.apk
adb install com.google.android.gms-2.apk

Step 6 I hope it was OK sometimes it gives you memory problems…