Ray Zhang %!s(int64=12) %!d(string=hai) anos
pai
achega
41db039044

+ 10 - 4
Apex/AndroidManifest.xml

@@ -6,9 +6,9 @@
 
     <!-- Copied from Google Maps Library/AndroidManifest.xml. -->
     <uses-sdk
+        android:maxSdkVersion="19"
         android:minSdkVersion="14"
-        android:targetSdkVersion="17"
-        android:maxSdkVersion="19" />
+        android:targetSdkVersion="17" />
 
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     <uses-permission android:name="android.permission.INTERNET" />
@@ -47,7 +47,8 @@
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
-<!--         <activity
+        <!--
+             <activity
             android:name="com.usai.apex.LoginFragment"
             android:label="@string/title_activity_login"
             android:windowSoftInputMode="adjustResize|stateVisible" >
@@ -55,7 +56,8 @@
         <activity
             android:name="com.usai.apex.DirectTrackingFragment"
             android:label="@string/title_activity_direct_tracking" >
-        </activity> -->
+        </activity>
+        -->
         <activity
             android:name="com.usai.apex.FunctionSelectActivity"
             android:label="@string/title_activity_function_select"
@@ -76,6 +78,10 @@
             android:label="@string/title_activity_result"
             android:screenOrientation="portrait" >
         </activity>
+        <activity
+            android:name="com.usai.apex.LocationDetailActivity"
+            android:label="@string/title_activity_location_detail" >
+        </activity>
     </application>
 
 </manifest>

+ 2 - 2
Apex/res/layout/activity_apex.xml

@@ -35,11 +35,11 @@
                 android:layout_height="fill_parent" >
             </FrameLayout>
 
-            <FrameLayout
+    <!--         <FrameLayout
                 android:id="@+id/tab2"
                 android:layout_width="fill_parent"
                 android:layout_height="fill_parent" >
-            </FrameLayout>
+            </FrameLayout> -->
 
             <FrameLayout
                 android:id="@+id/tab3"

+ 87 - 0
Apex/res/layout/activity_location_detail.xml

@@ -0,0 +1,87 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:gravity="center_horizontal"
+    android:orientation="vertical"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    tools:context=".LocationDetailActivity" >
+
+    <TextView
+        android:id="@+id/tv_name"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:paddingBottom="10dp"
+        android:text="Apex Maritime Co., Inc."
+        android:textAppearance="?android:attr/textAppearanceLarge" />
+
+    <TextView
+        android:id="@+id/tv_address"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:gravity="center"
+        android:paddingBottom="5dp"
+        android:paddingTop="5dp"
+        android:text="206 Utah Ave.\nSo. San Francisco, CA 94080"
+        android:textAppearance="?android:attr/textAppearanceMedium" />
+
+    <TextView
+        android:id="@+id/tv_tel"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:autoLink="phone"
+        android:paddingBottom="5dp"
+        android:paddingTop="5dp"
+        android:text="TEL: 650-589-2575"
+        android:textAppearance="?android:attr/textAppearanceMedium" />
+
+    <TextView
+        android:id="@+id/tv_fax"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:paddingBottom="5dp"
+        android:paddingTop="5dp"
+        android:text="FAX: 650-589-8861"
+        android:textAppearance="?android:attr/textAppearanceMedium" />
+
+    <TextView
+        android:id="@+id/tv_contact"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:paddingBottom="5dp"
+        android:paddingTop="5dp"
+        android:text="Contact: James Chu / Esther Hui"
+        android:textAppearance="?android:attr/textAppearanceMedium" />
+
+    <TextView
+        android:id="@+id/tv_email1"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:autoLink="email"
+        android:paddingBottom="5dp"
+        android:paddingTop="5dp"
+        android:text="E-mail: james.chu@apexshipping.com"
+        android:textAppearance="?android:attr/textAppearanceMedium" />
+
+    <TextView
+        android:id="@+id/tv_email2"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:autoLink="email"
+        android:paddingBottom="5dp"
+        android:paddingTop="5dp"
+        android:text="E-mail: esther.hui@apexshipping.com"
+        android:textAppearance="?android:attr/textAppearanceMedium" />
+
+    <Button
+        android:id="@+id/button1"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:paddingBottom="5dp"
+        android:paddingTop="5dp"
+        android:text="Add to contact" />
+
+</LinearLayout>

+ 37 - 29
Apex/res/layout/activity_result.xml

@@ -10,9 +10,9 @@
         android:layout_height="wrap_content"
         android:layout_centerInParent="true"
         android:layout_gravity="center"
+        android:background="#80808080"
         android:gravity="center_horizontal"
         android:orientation="vertical"
-        android:background="#80808080"
         android:visibility="gone" >
 
         <ProgressBar
@@ -30,47 +30,55 @@
             android:textAppearance="?android:attr/textAppearanceMedium" />
     </LinearLayout>
 
-    <ScrollView
+    <HorizontalScrollView
         android:id="@+id/search_form"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_above="@+id/btn_more"
-        android:layout_below="@+id/tv_head" >
+        android:layout_below="@+id/head"
+        android:layout_above="@+id/foot" >
 
-        <HorizontalScrollView
-            android:id="@+id/horizontalScrollView1"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent" >
+        <TableLayout
+            android:id="@+id/result_table"
+            android:layout_width="wrap_content"
+            android:layout_height="fill_parent" >
 
-            <TableLayout
-                android:id="@+id/result_table"
+            <TableRow
+                android:id="@+id/tr_header"
                 android:layout_width="wrap_content"
-                android:layout_height="fill_parent" >
+                android:layout_height="wrap_content" >
+            </TableRow>
+        </TableLayout>
+    </HorizontalScrollView>
+
+    <LinearLayout
+        android:id="@+id/foot"
+        android:layout_width="fill_parent"
+        
+        android:layout_height="wrap_content" 
+        android:layout_alignParentBottom="true">
 
-                <TableRow
-                    android:id="@+id/tr_header"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content" >
-                </TableRow>
-            </TableLayout>
-        </HorizontalScrollView>
-    </ScrollView>
+        <Button
+            android:id="@+id/btn_pre"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:text="Pre Page" />
+
+        <Button
+            android:id="@+id/btn_next"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+             android:layout_weight="1"
+            android:text="Next Page" />
+    </LinearLayout>
 
     <TextView
-        android:id="@+id/tv_head"
+        android:id="@+id/head"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignParentTop="true"
         android:layout_centerHorizontal="true"
-        android:text=""
+        android:text="aaa"
         android:textAppearance="?android:attr/textAppearanceLarge" />
 
-    <Button
-        android:id="@+id/btn_more"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:layout_alignParentBottom="true"
-        android:layout_alignParentLeft="true"
-        android:text="Load More" />
-
 </RelativeLayout>

+ 1 - 1
Apex/res/layout/fragment_direct_tracking.xml

@@ -12,7 +12,7 @@
         android:orientation="vertical" >
 
         <TextView
-            android:id="@+id/textView1"
+            android:id="@+id/tv_name"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="Track your cargo by selected customers" />

+ 6 - 0
Apex/res/layout/fragment_login.xml

@@ -65,6 +65,12 @@
                 android:singleLine="true"
                 android:text="#UL$dc01" />
 
+            <CheckBox
+                android:id="@+id/cb_save"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="Save Password" />
+
             <Button
                 android:id="@+id/sign_in_button"
                 android:layout_width="wrap_content"

+ 9 - 0
Apex/res/menu/location_detail.xml

@@ -0,0 +1,9 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item
+        android:id="@+id/action_settings"
+        android:orderInCategory="100"
+        android:showAsAction="never"
+        android:title="@string/action_settings"/>
+
+</menu>

+ 1 - 0
Apex/res/values/strings.xml

@@ -15,5 +15,6 @@
     <string name="title_activity_search">SearchActivity</string>
     <string name="title_activity_customize_fields">CustomizeFieldsActivity</string>
     <string name="title_activity_result">ResultActivity</string>
+    <string name="title_activity_location_detail">LocationDetail</string>
 
 </resources>

+ 4 - 4
Apex/src/com/usai/apex/ApexActivity.java

@@ -38,7 +38,7 @@ public class ApexActivity extends FragmentActivity /*implements OnTabChangeListe
 //        String[] title = new String[] { "Login", "Not login" };
 //        int[] tabIds = new int[] { R.id.tab1, R.id.tab2 };
         mTabHost.addTab(mTabHost.newTabSpec("Login").setIndicator("Login").setContent(R.id.tab1));
-        mTabHost.addTab(mTabHost.newTabSpec("Direct Tracking").setIndicator("Direct Tracking").setContent(R.id.tab2));
+//        mTabHost.addTab(mTabHost.newTabSpec("Direct Tracking").setIndicator("Direct Tracking").setContent(R.id.tab2));
         mTabHost.addTab(mTabHost.newTabSpec("Service Location").setIndicator("Service Location").setContent(R.id.tab3));
         
 		//FragmentManager manager = this.getFragmentManager();
@@ -55,9 +55,9 @@ public class ApexActivity extends FragmentActivity /*implements OnTabChangeListe
 	    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
 	    ft.addToBackStack("Login");
 	    
-	    ft.replace(R.id.tab2, dtFragement);
-	    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
-	    ft.addToBackStack("Tracking");
+//	    ft.replace(R.id.tab2, dtFragement);
+//	    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+//	    ft.addToBackStack("Tracking");
 
 	    ft.replace(R.id.tab3, (Fragment)slFragment);
 	    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);

+ 25 - 0
Apex/src/com/usai/apex/LocationDetailActivity.java

@@ -0,0 +1,25 @@
+package com.usai.apex;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class LocationDetailActivity extends Activity
+{
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_location_detail);
+	}
+
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu)
+	{
+		// Inflate the menu; this adds items to the action bar if it is present.
+		getMenuInflater().inflate(R.menu.location_detail, menu);
+		return true;
+	}
+
+}

+ 139 - 65
Apex/src/com/usai/apex/ResultActivity.java

@@ -51,7 +51,7 @@ public class ResultActivity extends Activity
 	HashMap<Integer, String> showfieldmap = new HashMap<Integer, String>();
 	private TextView mStatusMessageView;
 	// private View mSearchFormView;
-	private Button mbtnMore;
+	private View footview;
 	private View mStatusView;
 
 	// private class resultAdapter extends SimpleAdapter
@@ -68,9 +68,10 @@ public class ResultActivity extends Activity
 		searchParms = getIntent().getBundleExtra("searchParms");
 		super.onCreate(savedInstanceState);
 		setContentView(R.layout.activity_result);
+		footview =  findViewById(R.id.foot);
 		// mSearchFormView = findViewById(R.id.search_form);
-		mbtnMore = (Button) findViewById(R.id.btn_more);
-		mbtnMore.setOnClickListener(new View.OnClickListener()
+		Button btnnext = (Button) findViewById(R.id.btn_next);
+		btnnext.setOnClickListener(new View.OnClickListener()
 		{
 
 			@Override
@@ -78,6 +79,26 @@ public class ResultActivity extends Activity
 			{
 //				TextView tv_head = (TextView) findViewById(R.id.tv_head);
 
+				searchresult.set_direction(1);
+				if (searchresult.get_totalcount()==-1)
+					requestdata(true);
+				else
+				{
+					requestdata(false);
+				}
+
+			}
+		});
+		
+		Button btnpre = (Button) findViewById(R.id.btn_pre);
+		btnpre.setOnClickListener(new View.OnClickListener()
+		{
+
+			@Override
+			public void onClick(View v)
+			{
+//				TextView tv_head = (TextView) findViewById(R.id.tv_head);
+				searchresult.set_direction(-1);
 				if (searchresult.get_totalcount()==-1)
 					requestdata(true);
 				else
@@ -109,12 +130,15 @@ public class ResultActivity extends Activity
 		HashMap<String, String> map = new HashMap<String, String>();
 		map.put("key", "no.");
 		gridheader.add(map);
+		Button btn = new Button(this);
+		btn.setText("No.");
+		headerRow.addView(btn);
 		while (cursor.moveToNext())
 		{
 			String aname = cursor.getString(0);
-			Button btn = new Button(this);
-			btn.setText(aname);
-			headerRow.addView(btn);
+			Button btn1 = new Button(this);
+			btn1.setText(aname);
+			headerRow.addView(btn1);
 			showfieldmap.put(pos, cursor.getString(1));
 
 			map.put("key", "header");
@@ -167,6 +191,7 @@ public class ResultActivity extends Activity
 
 	public void requestdata(boolean requestcount)
 	{
+
 		if (m_task != null)
 		{
 			return;
@@ -201,14 +226,14 @@ public class ResultActivity extends Activity
 						}
 					});
 
-			mbtnMore.setVisibility(View.VISIBLE);
-			mbtnMore.animate().setDuration(shortAnimTime).alpha(show ? 0 : 1)
+			footview.setVisibility(View.VISIBLE);
+			footview.animate().setDuration(shortAnimTime).alpha(show ? 0 : 1)
 					.setListener(new AnimatorListenerAdapter()
 					{
 						@Override
 						public void onAnimationEnd(Animator animation)
 						{
-							mbtnMore.setVisibility(show ? View.INVISIBLE
+							footview.setVisibility(show ? View.INVISIBLE
 									: View.VISIBLE);
 						}
 					});
@@ -230,7 +255,7 @@ public class ResultActivity extends Activity
 			// The ViewPropertyAnimator APIs are not available, so simply show
 			// and hide the relevant UI components.
 			mStatusView.setVisibility(show ? View.VISIBLE : View.INVISIBLE);
-			mbtnMore.setVisibility(show ? View.INVISIBLE : View.VISIBLE);
+			footview.setVisibility(show ? View.INVISIBLE : View.VISIBLE);
 			// mSearchFormView.setVisibility(show ? View.INVISIBLE :
 			// View.VISIBLE);
 		}
@@ -268,7 +293,10 @@ public class ResultActivity extends Activity
 				}
 			}
 
-			searchParms.putString("offset", searchresult.get_count()+"");
+			if(searchresult.get_direction()==-1)
+				searchresult.set_offset(searchresult.get_offset()-20);
+			searchParms.putString("offset", searchresult.get_offset()+"");
+			
 			String jstr = Network.get_records(user, password, searchParms);
 			if (jstr == null || jstr.length() <= 0)
 			{
@@ -283,12 +311,12 @@ public class ResultActivity extends Activity
 			try
 			{
 				jsobj = new JSONObject(jstr);
-				if (searchresult.get_fieldscount() == 0)
-				{
-					JSONObject objfields = jsobj.getJSONObject("fields");
-					if (objfields != null)
-						searchresult.init_fields(objfields.toString());
-				}
+//				if (searchresult.get_fieldscount() == 0)
+//				{
+//					JSONObject objfields = jsobj.getJSONObject("fields");
+//					if (objfields != null)
+//						searchresult.init_fields(objfields.toString());
+//				}
 				JSONObject objrecords = jsobj.getJSONObject("records");
 				if (objrecords != null)
 					searchresult.add_records(objrecords.toString());
@@ -351,37 +379,60 @@ public class ResultActivity extends Activity
 			if (success)
 			{
 
-				int loadcount = searchresult.get_count();
+//				int loadcount = searchresult.get_count();
 				int totalcount = searchresult.get_totalcount();
-				TextView tv_head = (TextView) findViewById(R.id.tv_head);
+				TextView tv_head = (TextView) findViewById(R.id.head);
 				if (totalcount == 0)
 					tv_head.setText("0 record found");
 				else
-					tv_head.setText(loadcount + "/"
-							+ searchresult.get_totalcount() + " records");
+					tv_head.setText(/*loadcount + "/"
+							+ */searchresult.get_totalcount() + " records");
 				TableLayout tl = (TableLayout) findViewById(R.id.result_table);
 
 				int showcount = tl.getChildCount();
-				int newcount = loadcount - showcount + 1;// +1 header row
-				for (int i = 0; i < newcount; i++)
+				tl.removeViews(1, tl.getChildCount()-1);
+//				int newcount = loadcount - showcount + 1;// +1 header row
+				for (int i = 0; i < 10; i++)
 				{
-					TableRow recordRow = new TableRow(ResultActivity.this);
+					
+					TableRow recordRow= new TableRow(ResultActivity.this);
+			
 					HashMap<String, String> record = searchresult
-							.get_record(loadcount - newcount);
+							.get_record(i);
+					TextView field = new TextView(ResultActivity.this);
+					field.setText(searchresult.get_offset()-10+i+"");
+					Log.d("offset="+searchresult.get_offset(), "direction="+searchresult.get_direction());
+					field.setGravity(Gravity.CENTER);
+					field.setPadding(10, 5, 10, 5);
+					field.setTextSize(20);	
+					recordRow.addView(field);
 					for (int j = 0; j < showfieldmap.size(); j++)
 					{
-						TextView field = new TextView(ResultActivity.this);
-						field.setText(record.get(showfieldmap.get(j)));
-						field.setGravity(Gravity.CENTER);
-						field.setPadding(10, 5, 10, 5);
-						field.setTextSize(20);
+						TextView field1 = new TextView(ResultActivity.this);
+						field1.setText(record.get(showfieldmap.get(j)));
+						field1.setGravity(Gravity.CENTER);
+						field1.setPadding(10, 5, 10, 5);
+						field1.setTextSize(20);
 						// field.setTextAppearance(ResultActivity.this,
 						// android.R.attr.textAppearanceMedium);
-						recordRow.addView(field);
+						recordRow.addView(field1);
 					}
 					tl.addView(recordRow);
 				}
 
+				
+				Button btnnext = (Button) findViewById(R.id.btn_next);
+
+				Button btnpre = (Button) findViewById(R.id.btn_pre);	
+				if(searchresult.get_offset()<=10)
+					btnpre.setEnabled(false);
+				else {
+					btnpre.setEnabled(true);
+				}
+				if(searchresult.get_totalcount()-searchresult.get_offset()<=10)
+					btnnext.setEnabled(false);
+				else
+					btnnext.setEnabled(true);
 				// // fill fake data
 				// for(int i=0;i<10;i++)
 				// {
@@ -432,16 +483,18 @@ public class ResultActivity extends Activity
 	private class SearchResult
 	{
 		int total_count = -1;
+		int direction = 1;
+		int offset = 0;
 		// int count = 0;
 		ArrayList<HashMap<String, String>> records = new ArrayList<HashMap<String, String>>();
-		ArrayList<field> fields = new ArrayList<field>();
+//		ArrayList<field> fields = new ArrayList<field>();
 
-		public void init_fields(String jsonfields)
-		{
-			String TAG = "init_fields@ResultActivity.SearchResult";
-			Log.d(TAG, jsonfields);
-
-		}
+//		public void init_fields(String jsonfields)
+//		{
+//			String TAG = "init_fields@ResultActivity.SearchResult";
+//			Log.d(TAG, jsonfields);
+//
+//		}
 
 		public HashMap<String, String> get_record(int i)
 		{
@@ -452,9 +505,11 @@ public class ResultActivity extends Activity
 		{
 			try
 			{
+				records.clear();
 				JSONObject objrecords = new JSONObject(jsonstr);
 				for (int i = 0; i < objrecords.length(); i++)
 				{
+					offset++;
 					JSONObject rec = objrecords.getJSONObject("record" + i);
 					Iterator it = rec.keys();
 					HashMap<String, String> record = new HashMap<String, String>();
@@ -467,6 +522,7 @@ public class ResultActivity extends Activity
 					records.add(record);
 
 				}
+//				searchresult.set_offset(offset);
 				// Log.e("records count:",objrecords.length()+"");
 
 			}
@@ -489,15 +545,33 @@ public class ResultActivity extends Activity
 			total_count = c;
 		}
 
-		public int get_count()
+		public int get_offset()
 		{
-			return records.size();
+			return offset;
 		}
-
-		public int get_fieldscount()
+		public int get_direction()
+		{
+			return direction;
+		}
+		public void set_offset(int i)
 		{
-			return fields.size();
+			offset=i;
+			
 		}
+		public void set_direction(int i)
+		{
+			direction=i;
+			
+		}
+//		public int get_count()
+//		{
+//			return records.size();
+//		}
+
+//		public int get_fieldscount()
+//		{
+//			return fields.size();
+//		}
 
 		// private class record
 		// {
@@ -505,28 +579,28 @@ public class ResultActivity extends Activity
 		//
 		// }
 
-		private class field
-		{
-			String name = null;
-			String aliasname = null;
-			String type = null;
-
-			public String get_name()
-			{
-				return name;
-			}
-
-			public String get_aliasname()
-			{
-				return aliasname;
-			}
-
-			public String get_type()
-			{
-				return type;
-			}
-
-		}
+//		private class field
+//		{
+//			String name = null;
+//			String aliasname = null;
+//			String type = null;
+//
+//			public String get_name()
+//			{
+//				return name;
+//			}
+//
+//			public String get_aliasname()
+//			{
+//				return aliasname;
+//			}
+//
+//			public String get_type()
+//			{
+//				return type;
+//			}
+//
+//		}
 
 	}
 }

+ 120 - 14
Apex/src/com/usai/apex/ServiceLocationFragment.java

@@ -8,11 +8,21 @@ package com.usai.apex;
 //import com.google.android.gms.maps.model.MarkerOptions;
 
 import com.google.android.gms.maps.GoogleMap;
+import com.google.android.gms.maps.GoogleMap.OnInfoWindowClickListener;
+import com.google.android.gms.maps.GoogleMap.OnMarkerClickListener;
+import com.google.android.gms.maps.CameraUpdateFactory;
 import com.google.android.gms.maps.MapFragment;
 import com.google.android.gms.maps.SupportMapFragment;
+import com.google.android.gms.maps.model.CameraPosition;
 import com.google.android.gms.maps.model.LatLng;
+import com.google.android.gms.maps.model.LatLngBounds;
+import com.google.android.gms.maps.model.Marker;
 import com.google.android.gms.maps.model.MarkerOptions;
+import com.usai.util.Network;
 
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Build;
 //import android.app.Fragment;
 //import android.app.FragmentManager;
 //import android.app.FragmentManager;
@@ -21,43 +31,139 @@ import com.google.android.gms.maps.model.MarkerOptions;
 //import android.app.FragmentManager;
 import android.os.Bundle;
 
-
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentManager;
 //import android.support.v4.app.FragmentManager;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.Toast;
 
-public class ServiceLocationFragment extends Fragment
+public class ServiceLocationFragment extends Fragment implements
+		OnMarkerClickListener, OnInfoWindowClickListener
 {
-	
+    static final CameraPosition US =
+            new CameraPosition.Builder().target(new LatLng(37.646374,
+					-122.398847))
+                    .zoom(2.5f)
+                    .bearing(0)
+                    .tilt(0)
+                    .build();
 	private SupportMapFragment fragment;
 	private GoogleMap map;
-//	
+
+	//
 	@Override
-	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-		return inflater.inflate(R.layout.fragment_service_location, container, false);
+	public View onCreateView(LayoutInflater inflater, ViewGroup container,
+			Bundle savedInstanceState)
+	{
+		return inflater.inflate(R.layout.fragment_service_location, container,
+				false);
 	}
 
 	@Override
-	public void onActivityCreated(Bundle savedInstanceState) {
+	public void onActivityCreated(Bundle savedInstanceState)
+	{
 		super.onActivityCreated(savedInstanceState);
 		FragmentManager fm = getChildFragmentManager();
 		fragment = (SupportMapFragment) fm.findFragmentById(R.id.map);
-		if (fragment == null) {
-			fragment = new SupportMapFragment();//.newInstance();
+		if (fragment == null)
+		{
+			fragment = new SupportMapFragment();// .newInstance();
 			fm.beginTransaction().replace(R.id.map, fragment).commit();
 		}
 	}
-	
+
 	@Override
-	public void onResume() {
+	public void onResume()
+	{
 		super.onResume();
-		if (map == null) {
+		if (map == null)
+		{
 			map = fragment.getMap();
-			map.addMarker(new MarkerOptions().position(new LatLng(30.650208,104.083663)));
-			map.addMarker(new MarkerOptions().position(new LatLng(37.52112,-122.03639)));
+			map.addMarker(new MarkerOptions().position(new LatLng(37.646374,
+					-122.398847)).title("Apex Maritime Co., Inc.").snippet("Click for more info."));
+
 		}
+		if(map!=null)
+			setUpMap();
+	}
+
+	private void setUpMap()
+	{
+		// // Hide the zoom controls as the button panel will cover it.
+		// map.getUiSettings().setZoomControlsEnabled(false);
+		//
+		// // Add lots of markers to the map.
+		// addMarkersToMap();
+		//
+		// // Setting an info window adapter allows us to change the both the
+		// contents and look of the
+		// // info window.
+		// map.setInfoWindowAdapter(new CustomInfoWindowAdapter());
+
+		// Set listeners for marker events. See the bottom of this class for
+		// their behavior.
+		map.moveCamera(CameraUpdateFactory.newCameraPosition(US));
+		map.setOnMarkerClickListener(this);
+		map.setOnInfoWindowClickListener(this);
+		// map.setOnMarkerDragListener(this);
+
+		// Pan to see all markers in view.
+		// Cannot zoom to bounds until the map has a size.
+//		final View mapView = getChildFragmentManager().findFragmentById(
+//				R.id.map).getView();
+//		if (mapView.getViewTreeObserver().isAlive())
+//		{
+//			mapView.getViewTreeObserver().addOnGlobalLayoutListener(
+//					new OnGlobalLayoutListener()
+//					{
+//						@SuppressWarnings("deprecation")
+//						// We use the new method when supported
+//						@SuppressLint("NewApi")
+//						// We check which build version we are using.
+//						@Override
+//						public void onGlobalLayout()
+//						{
+//							LatLngBounds bounds = new LatLngBounds.Builder()
+//									.include(PERTH).include(SYDNEY)
+//									.include(ADELAIDE).include(BRISBANE)
+//									.include(MELBOURNE).build();
+//							if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
+//							{
+//								mapView.getViewTreeObserver()
+//										.removeGlobalOnLayoutListener(this);
+//							}
+//							else
+//							{
+//								mapView.getViewTreeObserver()
+//										.removeOnGlobalLayoutListener(this);
+//							}
+//							map.moveCamera(CameraUpdateFactory.newLatLngBounds(
+//									bounds, 50));
+//						}
+//					});
+//		}
+	}
+
+    @Override
+    public void onInfoWindowClick(Marker marker) {
+//        Toast.makeText(getActivity(), "Click Info Window", Toast.LENGTH_SHORT).show();
+    	Intent intent = new Intent();
+		intent.setClass(getActivity(), LocationDetailActivity.class);
+//		intent.putExtra("user", user);
+//		// intent.putExtra("password", password);
+//		intent.putExtra("function_name", function_name);
+//		intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
+		startActivity(intent);
+		       
+    }
+
+
+	@Override
+	public boolean onMarkerClick(Marker arg0)
+	{
+		// TODO Auto-generated method stub
+		return false;
 	}
 }