Wednesday 12 September 2012

Draw a path between two Geo Points

Objective:
Draw a line that between two points on Google Maps lets say City “A” and City “B”. Repeat the process to draw a line between City “B” and City “C”.
What we need:
Coordinates of 3 cities or any 3 locations that we want to connect.
  1. Abbottabad : 34159000,73220000
  2. Islamabad : 33695043,73050000
  3. Rawalpindi :33615043, 73050000
I have taken relative coordinates of 3 Pakistani cities starting from Abbottabad (where my family lives), moving to Islamabad (Capital of Pakistan). From Islamabad moving to Rawalpindi.



  • GeoPoint :An immutable class representing a pair of latitude and longitude, stored as integer numbers of microdegrees
  • Projection :A Projection serves to translate between the coordinate system of x/y on-screen pixel coordinates and that of latitude/longitude points on the surface of the earth.
  • Point :Converts the given GeoPoint to onscreen pixel coordinates, relative to the top-left of the MapView that provided this Projection 

    Here is the Screen: 





Monday 3 September 2012

PopupWindow For Android

A popup window that can be used to display an arbitrary view. The popup windows is a floating container that appears on top of the current activity.Developer site link

Here we are using LayoutInflater for displaying the popupwindow objects. According to our requirements we will create the xml for popupWindow.

Here is the code lines:
LayoutInflater layoutInflater
= (LayoutInflater)getBaseContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.popup, null);
final PopupWindow popupWindow = new PopupWindow(
popupView,
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT); 

ScreenShot: