|
|
@@ -12,6 +12,7 @@ import android.support.annotation.Nullable;
|
|
|
import android.util.AttributeSet;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
+import android.widget.ImageButton;
|
|
|
import android.widget.RelativeLayout;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
@@ -49,6 +50,11 @@ public class ShipMap extends RelativeLayout implements GoogleMap.OnMarkerClickLi
|
|
|
private Context mContext;
|
|
|
private Boolean mUseGoogleMap;
|
|
|
|
|
|
+ private ShipMapListener mListener;
|
|
|
+ private ShipMap self = this;
|
|
|
+
|
|
|
+ private ImageButton mResizeBtn;
|
|
|
+
|
|
|
public ShipMap(Context context) {
|
|
|
super(context);
|
|
|
init(context);
|
|
|
@@ -134,6 +140,53 @@ public class ShipMap extends RelativeLayout implements GoogleMap.OnMarkerClickLi
|
|
|
LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);
|
|
|
addView(mBaiduMap,layoutParams);
|
|
|
}
|
|
|
+
|
|
|
+ ImageButton resizeBtn = new ImageButton(mContext);
|
|
|
+ resizeBtn.setImageResource(R.drawable.rect_history);
|
|
|
+ resizeBtn.setTag(false);
|
|
|
+
|
|
|
+ LayoutParams layoutParams = new LayoutParams(dp2px(mContext,40.0f),dp2px(mContext,40.0f));
|
|
|
+ layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
|
|
|
+ layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
|
|
+ layoutParams.setMargins(0,dp2px(mContext,10.0f),dp2px(mContext,10.0f),0);
|
|
|
+
|
|
|
+ addView(resizeBtn,layoutParams);
|
|
|
+ mResizeBtn = resizeBtn;
|
|
|
+
|
|
|
+ resizeBtn.setOnClickListener(new OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ ImageButton zoomBtn = (ImageButton)v;
|
|
|
+ boolean selected = (boolean) zoomBtn.getTag();
|
|
|
+ selected = !selected;
|
|
|
+
|
|
|
+ setZoomIn(selected);
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setZoomIn(boolean zoomIn) {
|
|
|
+
|
|
|
+ mResizeBtn.setTag(zoomIn);
|
|
|
+
|
|
|
+ if (zoomIn) {
|
|
|
+ mResizeBtn.setImageResource(R.drawable.rect_announcements);
|
|
|
+ } else {
|
|
|
+ mResizeBtn.setImageResource(R.drawable.rect_history);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (mListener != null) {
|
|
|
+ mListener.shipMapTryToZoomIn(self,zoomIn);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static int dp2px(Context context, float dpValue) {
|
|
|
+ float scale = context.getResources().getDisplayMetrics().density;
|
|
|
+ return (int) (dpValue * scale + 0.5f);
|
|
|
}
|
|
|
|
|
|
private static int AnnotationDisplayPriorityRequired = 2;
|
|
|
@@ -434,6 +487,14 @@ public class ShipMap extends RelativeLayout implements GoogleMap.OnMarkerClickLi
|
|
|
return mShowCurrent;
|
|
|
}
|
|
|
|
|
|
+ public void setShipMapListener(ShipMapListener listener) {
|
|
|
+ mListener = listener;
|
|
|
+ }
|
|
|
+
|
|
|
+ public ShipMapListener getShipMapListener() {
|
|
|
+ return mListener;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Google
|
|
|
* */
|
|
|
@@ -554,4 +615,10 @@ public class ShipMap extends RelativeLayout implements GoogleMap.OnMarkerClickLi
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ public interface ShipMapListener {
|
|
|
+
|
|
|
+ void shipMapTryToZoomIn(ShipMap shipMap,boolean zoomIn);
|
|
|
+
|
|
|
+ }
|
|
|
}
|