Selaa lähdekoodia

1.修改Android Apex Mobile地图气泡、缩放。

Pen Li 8 vuotta sitten
vanhempi
commit
eb34f2e731

+ 19 - 19
Apex Mobile/app/src/main/AndroidManifest.xml

@@ -111,29 +111,29 @@
                 android:resource="@xml/download_dir" />
         </provider>
 
-        <!-- release key -->
-        <meta-data
-            android:name="com.google.android.maps.v2.API_KEY"
-            android:value="AIzaSyDdbk58Lx6QzaXcB_hNpSHVp3l_CJeNpoo" />
-        <meta-data
-            android:name="com.baidu.lbsapi.API_KEY"
-            android:value="nqBQoSDbxrslhuzW91uViQX7" />
-        <meta-data
-            android:name="com.google.android.gms.version"
-            android:value="@integer/google_play_services_version" />
+        <!-- release key -->ipa
+        <!--<meta-data-->
+            <!--android:name="com.google.android.maps.v2.API_KEY"-->
+            <!--android:value="AIzaSyDdbk58Lx6QzaXcB_hNpSHVp3l_CJeNpoo" />-->
+        <!--<meta-data-->
+            <!--android:name="com.baidu.lbsapi.API_KEY"-->
+            <!--android:value="nqBQoSDbxrslhuzW91uViQX7" />-->
+        <!--<meta-data-->
+            <!--android:name="com.google.android.gms.version"-->
+            <!--android:value="@integer/google_play_services_version" />-->
 
         <!-- debug key -->
 
 
-        <!-- <meta-data -->
-        <!-- android:name="com.google.android.maps.v2.API_KEY" -->
-        <!-- android:value="AIzaSyD6Snyg2SDUGtkC3sOAr979__IDCZnGGuU" /> -->
-        <!-- <meta-data -->
-        <!-- android:name="com.baidu.lbsapi.API_KEY" -->
-        <!-- android:value="tznWFxd3RvSoul1TGQp6GSzo" /> -->
-        <!-- <meta-data -->
-        <!-- android:name="com.google.android.gms.version" -->
-        <!-- android:value="@integer/google_play_services_version" /> -->
+         <meta-data
+         android:name="com.google.android.maps.v2.API_KEY"
+         android:value="AIzaSyD6Snyg2SDUGtkC3sOAr979__IDCZnGGuU" />
+         <meta-data
+         android:name="com.baidu.lbsapi.API_KEY"
+         android:value="tznWFxd3RvSoul1TGQp6GSzo" />
+         <meta-data
+         android:name="com.google.android.gms.version"
+         android:value="@integer/google_play_services_version" />
 
         <activity
             android:name=".DetailActivity"

+ 23 - 3
Apex Mobile/app/src/main/java/com/usai/apex/ShipMap/ShipMap.java

@@ -27,6 +27,7 @@ import com.baidu.mapapi.map.MapView;
 import com.baidu.mapapi.map.Marker;
 import com.baidu.mapapi.map.MarkerOptions;
 import com.baidu.mapapi.model.LatLng;
+import com.google.android.gms.maps.CameraUpdate;
 import com.google.android.gms.maps.CameraUpdateFactory;
 import com.google.android.gms.maps.GoogleMap;
 import com.google.android.gms.maps.MapFragment;
@@ -124,6 +125,10 @@ public class ShipMap extends RelativeLayout implements GoogleMap.OnMarkerClickLi
             mBaiduMap = new MapView(mContext);
             mBaiduMap.getMap().setOnMarkerClickListener(this);
 
+            // 设置当前缩放
+            MapStatusUpdate u = MapStatusUpdateFactory.zoomTo(mBaiduMap.getMap().getMinZoomLevel());
+            mBaiduMap.getMap().setMapStatus(u);
+
             LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);
             addView(mBaiduMap,layoutParams);
         }
@@ -158,6 +163,7 @@ public class ShipMap extends RelativeLayout implements GoogleMap.OnMarkerClickLi
             if (pol != null) {
                 handleLocation(pol,AnnotationDisplayPriorityHigh);
             }
+//            moveToLocation(pol);
         }
         if (showPoe()) {
             JSONObject poe = annotation.optJSONObject("poe");
@@ -378,6 +384,11 @@ public class ShipMap extends RelativeLayout implements GoogleMap.OnMarkerClickLi
             if (mAnnotation != null) {
                 showShipAnnotation(mAnnotation);
             }
+            mGoogleMap.getUiSettings().setMapToolbarEnabled(false); // 隐藏底部ToolBar 导航按钮
+
+            // 设置缩放级别
+            CameraUpdate zoom = CameraUpdateFactory.zoomTo(mGoogleMap.getMinZoomLevel());
+            mGoogleMap.animateCamera(zoom);
         }
     }
 
@@ -388,10 +399,19 @@ public class ShipMap extends RelativeLayout implements GoogleMap.OnMarkerClickLi
     @Override
     public boolean onMarkerClick(Marker marker) {
 
-        View viewCache = LayoutInflater.from(mContext).inflate(R.layout.ship_map_bubble, null);
+//        View viewCache = LayoutInflater.from(mContext).inflate(R.layout.ship_map_bubble, null);
+//
+//        TextView tv_title = (TextView) viewCache.findViewById(R.id.bubble_title);
+//        TextView tv_info = (TextView) viewCache.findViewById(R.id.bubble_detail);
+
+        View viewCache = ((Activity)mContext)
+                .getLayoutInflater().inflate(
+                        R.layout.marker_view, null);
 
-        TextView tv_title = (TextView) viewCache.findViewById(R.id.bubble_title);
-        TextView tv_info = (TextView) viewCache.findViewById(R.id.bubble_detail);
+        TextView tv_title = (TextView) viewCache
+                .findViewById(R.id.tv_title);
+        TextView tv_info = (TextView) viewCache
+                .findViewById(R.id.tv_info);
 
         tv_title.setText(marker.getTitle());
         tv_info.setText(marker.getExtraInfo().getString("detail"));

+ 10 - 4
Apex Mobile/app/src/main/java/com/usai/apex/mainframe/RecentFragment.java

@@ -63,6 +63,11 @@ public class RecentFragment extends TrackingListFragment {
 //            }
 //        }
 
+        if (savedInstanceState != null) {
+            mSelectedIndex = savedInstanceState.getInt("selectIndex");
+            setSelectedPosition(mSelectedIndex);
+        }
+
         if (searchresult.get_count() == 0) {
             requestData();
         }
@@ -257,17 +262,18 @@ if(TextUtils.isEmpty(serial_no))
     public void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
 
+        outState.putInt("selectIndex",mSelectedIndex);
+
         Log.d("RecentFragment", "onSaveInstanceState: ");
     }
 
+
+
     @Override
     public void onClick(View v) {
-//        super.onClick(v);
+        super.onClick(v);
         int position = (Integer) v.getTag();
         setSelectedPosition(position);
-
-//        getListView().setSelection(position);
-
     }
 
 

+ 3 - 1
Apex Mobile/app/src/main/res/layout/detail_fragment_withmap.xml

@@ -1,7 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
-    android:layout_height="wrap_content" >
+    android:layout_height="wrap_content"
+                android:background="#FFF5F5F5"
+    >
 
     <LinearLayout
         android:id="@+id/detail_linear"

+ 20 - 28
Apex Mobile/app/src/main/res/layout/ship_map_bubble.xml

@@ -1,32 +1,24 @@
 <?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-                android:id="@+id/ship_map_bubble"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:orientation="vertical"
-                android:background="@drawable/pop_bg9"
-                android:paddingLeft="5dp"
-                android:paddingRight="5dp"
-                android:paddingTop="5dp"
-                android:paddingBottom="20dp">
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:orientation="vertical"
+              android:gravity="center_horizontal">
 
-    <TextView
-        android:id="@+id/bubble_title"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:gravity="center_vertical"
-        android:textSize="14sp"
-        android:textStyle="bold"
-        />
+<TextView
+    android:id="@+id/bubble_title"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:text="title"
+    android:textAllCaps="false"
+    android:textStyle="bold"/>
 
-    <TextView
-        android:gravity="center"
-        android:id="@+id/bubble_detail"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:layout_below="@id/bubble_title"
-        android:layout_marginTop="5dp"
-        android:textSize="12sp"
-        />
+<TextView
+    android:id="@+id/bubble_detail"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:textAllCaps="false"
+    android:text="info" />
 
-</RelativeLayout>
+
+</LinearLayout>