Android Open Source - GPA Address Overlay






From Project

Back to project page GPA.

License

The source code is released under:

Apache License

If you think the Android project GPA 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.bishal.android.taskmanager.views;
/*from w  w  w.  j av  a2 s  . c o m*/
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.location.Address;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;

public class AddressOverlay extends Overlay {

  private static final int CONTAINER_RADIUS        = 4;
  private static final int CONTAINER_SHADOW_OFFSET    = 1;
  
  private Address address;
  private GeoPoint geopoint;
  
  public AddressOverlay(Address address) {
    super();
    assert(null != address);
    this.setAddress(address);
    Double convertedLongitude = address.getLongitude() * 1E6;
    Double convertedLatitude = address.getLatitude() * 1E6;

    setGeopoint(new GeoPoint(
        convertedLatitude.intValue(),
        convertedLongitude.intValue()));
  }

  @Override
  public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    super.draw(canvas, mapView, shadow);
      Point locationPoint = new Point();
      Projection projection = mapView.getProjection();
      projection.toPixels(getGeopoint(), locationPoint);
      Paint containerPaint = new Paint();
    containerPaint.setAntiAlias(true);
      int containerX = locationPoint.x;
      int containerY = locationPoint.y;
    if (shadow) {
      containerX += CONTAINER_SHADOW_OFFSET;
      containerY += CONTAINER_SHADOW_OFFSET;
      containerPaint.setARGB(90, 0, 0, 0);
            canvas.drawCircle(containerX, containerY, CONTAINER_RADIUS, containerPaint);
    } else {
      containerPaint.setColor(Color.RED);
            canvas.drawCircle(containerX, containerY, CONTAINER_RADIUS, containerPaint);
    }
  }

  public void setAddress(Address address) {
    this.address = address;
  }

  public Address getAddress() {
    return address;
  }

  public void setGeopoint(GeoPoint geopoint) {
    this.geopoint = geopoint;
  }

  public GeoPoint getGeopoint() {
    return geopoint;
  }

}




Java Source Code List

com.bishal.android.taskmanager.ACCOUNT_INFO.java
com.bishal.android.taskmanager.ADD_TASK.java
com.bishal.android.taskmanager.AddLocationMapActivity.java
com.bishal.android.taskmanager.AddTaskActivity.java
com.bishal.android.taskmanager.AlarmActivity.java
com.bishal.android.taskmanager.AlertDialogManager.java
com.bishal.android.taskmanager.AndroidAlarmService.java
com.bishal.android.taskmanager.CURRENT_LOCATION.java
com.bishal.android.taskmanager.DB_ADAPTER.java
com.bishal.android.taskmanager.DbHelper.java
com.bishal.android.taskmanager.GPA_HOME.java
com.bishal.android.taskmanager.GPS_FIELD.java
com.bishal.android.taskmanager.GPS_INFO.java
com.bishal.android.taskmanager.LOGIN.java
com.bishal.android.taskmanager.MyAlarmService.java
com.bishal.android.taskmanager.SCHEDULES.java
com.bishal.android.taskmanager.SEARCHING_PLACES.java
com.bishal.android.taskmanager.SIGNUP.java
com.bishal.android.taskmanager.Search_Education.java
com.bishal.android.taskmanager.Search_Hospital.java
com.bishal.android.taskmanager.SpecifyTime.java
com.bishal.android.taskmanager.TaskManagerActivity.java
com.bishal.android.taskmanager.TaskManagerApplication.java
com.bishal.android.taskmanager.ViewTasksActivity.java
com.bishal.android.taskmanager.YourAlarmService.java
com.bishal.android.taskmanager.adapters.TaskListAdapter.java
com.bishal.android.taskmanager.tasks.Task.java
com.bishal.android.taskmanager.tasks.TasksSQLiteOpenHelper.java
com.bishal.android.taskmanager.views.AddressOverlay.java
com.bishal.android.taskmanager.views.TaskListItem.java