|
|
@@ -36,6 +36,7 @@ import com.google.android.gms.maps.model.CameraPosition;
|
|
|
import com.usai.apex.ApexTrackingApplication;
|
|
|
import com.usai.apex.R;
|
|
|
|
|
|
+import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
public class ShipMap extends RelativeLayout implements GoogleMap.OnMarkerClickListener, BaiduMap.OnMarkerClickListener, GoogleMap.OnInfoWindowClickListener, OnMapReadyCallback, InfoWindow.OnInfoWindowClickListener {
|
|
|
@@ -161,45 +162,80 @@ public class ShipMap extends RelativeLayout implements GoogleMap.OnMarkerClickLi
|
|
|
if (showPol()) {
|
|
|
JSONObject pol = annotation.optJSONObject("pol");
|
|
|
if (pol != null) {
|
|
|
- handleLocation(pol,AnnotationDisplayPriorityHigh);
|
|
|
+ try {
|
|
|
+ pol.put("port","Port Of Load");
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ handleLocation(pol,AnnotationDisplayPriorityHigh,R.drawable.new_location_pol);
|
|
|
}
|
|
|
// moveToLocation(pol);
|
|
|
}
|
|
|
if (showPoe()) {
|
|
|
JSONObject poe = annotation.optJSONObject("poe");
|
|
|
if (poe != null) {
|
|
|
- handleLocation(poe,AnnotationDisplayPriorityLow);
|
|
|
+ try {
|
|
|
+ poe.put("port","Place Of Deliver");
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ handleLocation(poe,AnnotationDisplayPriorityLow,R.drawable.new_location_poe);
|
|
|
}
|
|
|
}
|
|
|
if (showPod()) {
|
|
|
JSONObject pod = annotation.optJSONObject("pod");
|
|
|
if (pod != null) {
|
|
|
- handleLocation(pod,AnnotationDisplayPriorityHigh);
|
|
|
+ try {
|
|
|
+ pod.put("port","Port Of Discharge");
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ handleLocation(pod,AnnotationDisplayPriorityHigh,R.drawable.new_location_pod);
|
|
|
}
|
|
|
}
|
|
|
if (showPor()) {
|
|
|
JSONObject por = annotation.optJSONObject("por");
|
|
|
if (por != null) {
|
|
|
- handleLocation(por,AnnotationDisplayPriorityLow);
|
|
|
+ try {
|
|
|
+ por.put("port","Place Of Receipt");
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ handleLocation(por,AnnotationDisplayPriorityLow,R.drawable.new_location_por);
|
|
|
}
|
|
|
}
|
|
|
if (showOrigin()) {
|
|
|
JSONObject origin = annotation.optJSONObject("origin");
|
|
|
if (origin != null) {
|
|
|
- handleLocation(origin,AnnotationDisplayPriorityLow);
|
|
|
+ try {
|
|
|
+ origin.put("port","Origin");
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ handleLocation(origin,AnnotationDisplayPriorityLow,R.drawable.new_location_origin);
|
|
|
}
|
|
|
}
|
|
|
if (showDestination()) {
|
|
|
JSONObject destination = annotation.optJSONObject("destination");
|
|
|
if (destination != null) {
|
|
|
- handleLocation(destination,AnnotationDisplayPriorityLow);
|
|
|
+ try {
|
|
|
+ destination.put("port","Destination");
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ handleLocation(destination,AnnotationDisplayPriorityLow,R.drawable.new_location_destination);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
JSONObject current = annotation.optJSONObject("current");
|
|
|
if (showCurrent()) {
|
|
|
if (current != null) {
|
|
|
- handleLocation(current,AnnotationDisplayPriorityRequired);
|
|
|
+ try {
|
|
|
+ current.put("port","Current");
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ handleLocation(current,AnnotationDisplayPriorityRequired,R.drawable.ic_marker);
|
|
|
}
|
|
|
}
|
|
|
moveToLocation(current);
|
|
|
@@ -240,22 +276,23 @@ public class ShipMap extends RelativeLayout implements GoogleMap.OnMarkerClickLi
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void handleLocation(JSONObject location,int priority) {
|
|
|
+ private void handleLocation(JSONObject location,int priority, int imageId) {
|
|
|
|
|
|
if (location == null) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (mUseGoogleMap) {
|
|
|
- handleGoogleLocation(location,priority);
|
|
|
+ handleGoogleLocation(location,priority,imageId);
|
|
|
} else {
|
|
|
- handleBaiduLocation(location,priority);
|
|
|
+ handleBaiduLocation(location,priority,imageId);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void handleGoogleLocation(JSONObject location,int priority) {
|
|
|
+ private void handleGoogleLocation(JSONObject location,int priority, int imageId) {
|
|
|
|
|
|
+ String port = location.optString("port");
|
|
|
String name = location.optString("name");
|
|
|
String addr = location.optString("addr");
|
|
|
String lonStr = location.optString("lon");
|
|
|
@@ -263,12 +300,18 @@ public class ShipMap extends RelativeLayout implements GoogleMap.OnMarkerClickLi
|
|
|
|
|
|
if (lonStr != null && lonStr.length() > 0 && latStr != null && latStr.length() > 0) {
|
|
|
|
|
|
+ if (port == null) {
|
|
|
+ port = "";
|
|
|
+ }
|
|
|
+ if (addr == null) {
|
|
|
+ addr = "";
|
|
|
+ }
|
|
|
|
|
|
mGoogleMap.addMarker(new com.google.android.gms.maps.model.MarkerOptions()
|
|
|
- .icon(com.google.android.gms.maps.model.BitmapDescriptorFactory.fromResource(R.drawable.ic_marker))
|
|
|
+ .icon(com.google.android.gms.maps.model.BitmapDescriptorFactory.fromResource(imageId))
|
|
|
.position(new com.google.android.gms.maps.model.LatLng(Double.parseDouble(latStr), Double.parseDouble(lonStr)))
|
|
|
.title(name)
|
|
|
- .snippet(addr));
|
|
|
+ .snippet(port + " " + addr));
|
|
|
|
|
|
} else {
|
|
|
return;
|
|
|
@@ -276,8 +319,9 @@ public class ShipMap extends RelativeLayout implements GoogleMap.OnMarkerClickLi
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void handleBaiduLocation(JSONObject location,int priority) {
|
|
|
+ private void handleBaiduLocation(JSONObject location,int priority, int imageId) {
|
|
|
|
|
|
+ String port = location.optString("port");
|
|
|
String name = location.optString("name");
|
|
|
String addr = location.optString("addr");
|
|
|
String lonStr = location.optString("lon");
|
|
|
@@ -285,11 +329,18 @@ public class ShipMap extends RelativeLayout implements GoogleMap.OnMarkerClickLi
|
|
|
|
|
|
if (lonStr != null && lonStr.length() > 0 && latStr != null && latStr.length() > 0) {
|
|
|
|
|
|
+ if (port == null) {
|
|
|
+ port = "";
|
|
|
+ }
|
|
|
+ if (addr == null) {
|
|
|
+ addr = "";
|
|
|
+ }
|
|
|
+
|
|
|
LatLng llA = new LatLng(Double.parseDouble(latStr), Double.parseDouble(lonStr));
|
|
|
- BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.ic_marker);
|
|
|
+ BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(imageId);
|
|
|
|
|
|
Bundle extrainfo = new Bundle();
|
|
|
- extrainfo.putString("detail",addr);
|
|
|
+ extrainfo.putString("detail",port + " " + addr);
|
|
|
|
|
|
MarkerOptions markeroption = new MarkerOptions().position(llA).icon(icon).zIndex(9).title(name).extraInfo(extrainfo).draggable(true);
|
|
|
mBaiduMap.getMap().addOverlay(markeroption);
|