@Override public void onMapReady(GoogleMap googleMap) { // Instantiates a new Polyline object and adds points to define a rectangle com.google.android.gms.maps.model.PolylineOptions rectOptions = new com.google.android.gms.maps.model.PolylineOptions() .add(new com.google.android.gms.maps.model.LatLng(-18.5186650000, 141.9748780000)) .add(new com.google.android.gms.maps.model.LatLng(-18.5186650000, 144.9748780000)) // North of the previous point, but at the same longitude .add(new com.google.android.gms.maps.model.LatLng(-20.5186650000, 144.9748780000)) // Same latitude, and 30km to the west .add(new com.google.android.gms.maps.model.LatLng(-20.5186650000, 141.9748780000)) // Same longitude, and 16km to the south .add(new com.google.android.gms.maps.model.LatLng(-24.5186650000, 141.9748780000)); // Closes the polyline. rectOptions.width(8) .color(ContextCompat.getColor(getActivity(), R.color.red_500)); // Get back the mutable Polyline com.google.android.gms.maps.model.Polyline polyline = googleMap.addPolyline(rectOptions); googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new com.google.android.gms.maps.model.LatLng(-18.5186650000, 141.9748780000), 6)); }
@Override public boolean onPolylineClick(Polyline polyline) { boolean flag = false; for (Overlay mPolyline : mOverlayList) { if (mPolyline instanceof Polyline && mPolyline.equals(polyline)) { // 选中 flag = true; break; } } setFocus(flag); return true; }
public void setFocus(boolean flag) { focus = flag; for (Overlay mPolyline : mOverlayList) { if (mPolyline instanceof Polyline) { // 选中 ((Polyline) mPolyline).setFocus(flag); break; } } }
@Override public void addPolyline(final PolylineInfo polylineInfo) { if (polylineInfo == null || polylineInfo.isOnMap()) { return; } final PolylineOptions options = fromPolylineInfo(polylineInfo); if (options == null) { return; } Polyline polyline = (Polyline) getBaiduMap().addOverlay(options); polylineInfo.setProxyPolyline(new ProxyMapPolyline(polyline)); polylinesMap.put(polyline, polylineInfo); }
@Override public boolean onPolylineClick(Polyline polyline) { // TODO Auto-generated method stub return false; }
@Override public boolean onPolylineClick(Polyline polyline) { return false; }
@Override public boolean onPolylineClick(Polyline polyline) { return super.onPolylineClick(polyline); }