com.baidu.mapapi.map.Marker Java Examples

The following examples show how to use com.baidu.mapapi.map.Marker. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OverlayManager.java    From Mobike with Apache License 2.0 6 votes vote down vote up
/**
 * 缩放地图,使所有Overlay都在合适的视野内
 * <p>
 * 注: 该方法只对Marker类型的overlay有效
 * </p>
 * 
 */
public void zoomToSpan() {
    if (mBaiduMap == null) {
        return;
    }
    if (mOverlayList.size() > 0) {
        LatLngBounds.Builder builder = new LatLngBounds.Builder();
        for (Overlay overlay : mOverlayList) {
            // polyline 中的点可能太多,只按marker 缩放
            if (overlay instanceof Marker) {
                builder.include(((Marker) overlay).getPosition());
            }
        }
        mBaiduMap.setMapStatus(MapStatusUpdateFactory
                .newLatLngBounds(builder.build()));
    }
}
 
Example #2
Source File: MapFragment.java    From MapForTour with MIT License 6 votes vote down vote up
@Override
public boolean onMarkerClick(Marker marker) {
    Log.d("lml", "MapFragment:覆盖物被点击");
    baiduMap.hideInfoWindow();
    if (marker != null) {
        latLngshow = marker.getPosition();
        reverseGeoCodeOption.location(latLngshow);
        geoCoder.reverseGeoCode(reverseGeoCodeOption);
        tvAddOverlayGeoCoder.setText("正在获取详细位置");
        bundle = marker.getExtraInfo();

        generalIsMale = bundle.getString("general").equals("m");
        layoutAddOverlayRadarNearbyItem.setBackgroundColor(getResources().getColor(generalIsMale ? R.color.blue : R.color.pink));
        imageViewAddOverlayItem.setImageResource(generalIsMale ? R.mipmap.map_portrait_man : R.mipmap.map_portrait_woman);
        tvAddOverlayItemUserID.setText(bundle.getString("userID"));
        tvAddOverlayItemDistance.setText("距离" + bundle.getInt("distance") + "米        ");
        tvAddOverlayItemLatlng.setText("坐标:   " + latLngshow.latitude + "  ,  " + latLngshow.longitude + "           ");
        Log.d("lml", "MapFragment显示的信息:" + bundle.getString("userID"));
        Log.d("lml", bundle.getString("general") + ";" + generalIsMale);
        baiduMap.showInfoWindow(new InfoWindow(viewOverlayItem, marker.getPosition(), -70));
        MapStatusUpdate update = MapStatusUpdateFactory.newLatLng(marker.getPosition());
        baiduMap.animateMapStatus(update);
        return true;
    } else
        return false;
}
 
Example #3
Source File: MapListener.java    From react-native-baidu-map with MIT License 6 votes vote down vote up
@Override
public boolean onMarkerClick(Marker marker) {
    WritableMap writableMap = Arguments.createMap();
    WritableMap position = Arguments.createMap();
    position.putDouble("latitude", marker.getPosition().latitude);
    position.putDouble("longitude", marker.getPosition().longitude);
    writableMap.putMap("position", position);
    writableMap.putString("title", marker.getTitle());
    OverlayMarker overlayMarker = MapViewManager.findOverlayMaker(marker);
    mapView.getMap().hideInfoWindow();
    if (overlayMarker != null) {
        InfoWindow infoWindow = overlayMarker.getInfoWindow(marker.getPosition());
        if (infoWindow != null) {
            mapView.getMap().showInfoWindow(infoWindow);
        }
        reactContext
                .getJSModule(RCTEventEmitter.class)
                .receiveEvent(overlayMarker.getId(),
                        "topClick", writableMap.copy());
    }
    sendEvent(mapView, "onMarkerClick", writableMap);
    return true;
}
 
Example #4
Source File: SetFavoriteMapActivity.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
/**
 * 定位接收到的地址
 **/
private void locationReceiveAddress() {
    if (receiveAddress == null) {
        return;
    }
    LatLng p = new LatLng(receiveAddress.getLatitude(), receiveAddress.getLongitude());
    MarkerOptions markerOptions = new MarkerOptions();
    /* 设置覆盖物图标 */
    markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_openmap_focuse_mark))
            .position(p)
            .visible(true);
    baiduMap.setOnMarkerClickListener(new BaiduMap.OnMarkerClickListener() {
        @Override
        public boolean onMarkerClick(Marker marker) {
            setSinglePoiDetail();
            return true;
        }
    });
    if (NetUtil.getInstance(SetFavoriteMapActivity.this).getCurrentNetType().equals(NetUtil.NetType.NETWORK_TYPE_NONE)) {
        // Snackbar.make(mAmosfPoiList,mAppConfig.getResources().getString(R.string.no_network), Snackbar.LENGTH_SHORT).show();
        return;
    }
    /* 添加覆盖图层 */
    baiduMap.addOverlay(markerOptions);
    baiduMap.setMapStatus(MapStatusUpdateFactory.newLatLngZoom(p, 17F));
}
 
Example #5
Source File: OverlayManager.java    From react-native-baidu-map with MIT License 6 votes vote down vote up
/**
 * 设置显示在规定宽高中的地图地理范围
 */
public void zoomToSpanPaddingBounds(int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) {
    if (mBaiduMap == null) {
        return;
    }
    if (mOverlayList.size() > 0) {
        LatLngBounds.Builder builder = new LatLngBounds.Builder();
        for (Overlay overlay : mOverlayList) {
            // polyline 中的点可能太多,只按marker 缩放
            if (overlay instanceof Marker) {
                builder.include(((Marker) overlay).getPosition());
            }
        }

        mBaiduMap.setMapStatus(MapStatusUpdateFactory
                .newLatLngBounds(builder.build(), paddingLeft, paddingTop, paddingRight, paddingBottom));
    }
}
 
Example #6
Source File: OverlayManager.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
/**
 * 缩放地图,使所有Overlay都在合适的视野内
 * <p>
 * 注: 该方法只对Marker类型的overlay有效
 * </p>
 */
public void zoomToSpan() {
    if (mBaiduMap == null) {
        return;
    }
    if (mOverlayList.size() > 0) {
        LatLngBounds.Builder builder = new LatLngBounds.Builder();
        for (Overlay overlay : mOverlayList) {
            // polyline 中的点可能太多,只按marker 缩放
            if (overlay instanceof Marker) {
                builder.include(((Marker) overlay).getPosition());
            } else if (overlay instanceof Polyline) {
                Polyline polyline = (Polyline) overlay;
                if (null != polyline.getPoints() && !polyline.getPoints().isEmpty()) {
                    builder.include(polyline.getPoints().get(0));
                    builder.include(polyline.getPoints().get((polyline.getPoints().size() - 1) / 2));
                    if (polyline.getPoints().size() > 2) {
                        builder.include(polyline.getPoints().get(polyline.getPoints().size() - 1));
                    }
                }
            }
        }
        mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLngBounds(builder.build()));
    }
}
 
Example #7
Source File: OverlayManager.java    From react-native-baidu-map with MIT License 6 votes vote down vote up
/**
 * 缩放地图,使所有Overlay都在合适的视野内
 * <p>
 * 注: 该方法只对Marker类型的overlay有效
 * </p>
 */
public void zoomToSpan() {
    if (mBaiduMap == null) {
        return;
    }
    if (mOverlayList.size() > 0) {
        LatLngBounds.Builder builder = new LatLngBounds.Builder();
        for (Overlay overlay : mOverlayList) {
            // polyline 中的点可能太多,只按marker 缩放
            if (overlay instanceof Marker) {
                builder.include(((Marker) overlay).getPosition());
            }
        }
        MapStatus mapStatus = mBaiduMap.getMapStatus();
        if (null != mapStatus){
            int width = mapStatus.winRound.right - mBaiduMap.getMapStatus().winRound.left - 400;
            int height = mapStatus.winRound.bottom - mBaiduMap.getMapStatus().winRound.top - 400;
            mBaiduMap.setMapStatus(MapStatusUpdateFactory
                    .newLatLngBounds(builder.build(), width, height));
        }

    }
}
 
Example #8
Source File: OverlayManager.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 缩放地图,使所有Overlay都在合适的视野内
 * <p>
 * 注: 该方法只对Marker类型的overlay有效
 * </p>
 */
public void zoomToSpan() {
    if (mBaiduMap == null) {
        return;
    }
    if (mOverlayList.size() > 0) {
        LatLngBounds.Builder builder = new LatLngBounds.Builder();
        for (Overlay overlay : mOverlayList) {
            // polyline 中的点可能太多,只按marker 缩放
            if (overlay instanceof Marker) {
                builder.include(((Marker) overlay).getPosition());
            } else if (overlay instanceof Polyline) {
                Polyline polyline = (Polyline) overlay;
                if (null != polyline.getPoints() && !polyline.getPoints().isEmpty()) {
                    builder.include(polyline.getPoints().get(0));
                    builder.include(polyline.getPoints().get((polyline.getPoints().size() - 1) / 2));
                    if (polyline.getPoints().size() > 2) {
                        builder.include(polyline.getPoints().get(polyline.getPoints().size() - 1));
                    }
                }
            }
        }
        mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLngBounds(builder.build()));
    }
}
 
Example #9
Source File: TransitRouteOverlay.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
@Override
public final boolean onMarkerClick(Marker marker) {
    for (Overlay mMarker : mOverlayList) {
        if (mMarker instanceof Marker && mMarker.equals(marker)) {
            if (marker.getExtraInfo() != null) {
                onRouteNodeClick(marker.getExtraInfo().getInt("index"));
            }
        }
    }
    return true;
}
 
Example #10
Source File: FreightTrackMapWithWebViewFragment.java    From ESeal with Apache License 2.0 5 votes vote down vote up
@Override
public void showBaiduMap(LocationDetail locationDetail) {
    if (locationDetail == null || locationDetail.isInvalid()) {
        return;
    }
    LatLng lng = locationDetail.getLatLng();

    OverlayOptions markerOptions = new MarkerOptions().flat(true).icon(BitmapDescriptorFactory
            .fromResource(R.drawable.ic_location_on_white_48dp)).position(lng);
    mMoveMarker = (Marker) mBaiduMap.addOverlay(markerOptions);

    //设置中心点
    mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLngZoom(lng, 16));
}
 
Example #11
Source File: DefaultClusterRenderer.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
private void removeMarker(Marker m) {
    Cluster<T> cluster = mMarkerToCluster.get(m);
    mClusterToMarker.remove(cluster);
    mMarkerCache.remove(m);
    mMarkerToCluster.remove(m);
    mClusterManager.getMarkerManager().remove(m);
}
 
Example #12
Source File: DefaultClusterRenderer.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
/**
 * Removes a markerWithPosition some time in the future.
 *
 * @param priority whether this operation should have priority.
 * @param m        the markerWithPosition to remove.
 */
public void remove(boolean priority, Marker m) {
    lock.lock();
    sendEmptyMessage(BLANK);
    if (priority) {
        mOnScreenRemoveMarkerTasks.add(m);
    } else {
        mRemoveMarkerTasks.add(m);
    }
    lock.unlock();
}
 
Example #13
Source File: BikingRouteOverlay.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
@Override
public final boolean onMarkerClick(Marker marker) {
    for (Overlay mMarker : mOverlayList) {
        if (mMarker instanceof Marker && mMarker.equals(marker)) {
            if (marker.getExtraInfo() != null) {
                onRouteNodeClick(marker.getExtraInfo().getInt("index"));
            }
        }
    }
    return true;
}
 
Example #14
Source File: MarkerManager.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
@Override
public void onMarkerDragStart(Marker marker) {
    Collection collection = mAllMarkers.get(marker);
    if (collection != null && collection.mMarkerDragListener != null) {
        collection.mMarkerDragListener.onMarkerDragStart(marker);
    }
}
 
Example #15
Source File: DrivingRouteOverlay.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
@Override
public final boolean onMarkerClick(Marker marker) {
    for (Overlay mMarker : mOverlayList) {
        if (mMarker instanceof Marker && mMarker.equals(marker)) {
            if (marker.getExtraInfo() != null) {
                onRouteNodeClick(marker.getExtraInfo().getInt("index"));
            }
        }
    }
    return true;
}
 
Example #16
Source File: BusLineOverlay.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
public final boolean onMarkerClick(Marker marker) {
    if (mOverlayList != null && mOverlayList.contains(marker)) {
        return onBusStationClick(mOverlayList.indexOf(marker));
    } else {
        return false;
    }
    
}
 
Example #17
Source File: MarkerManager.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
@Override
public void onMarkerDragEnd(Marker marker) {
    Collection collection = mAllMarkers.get(marker);
    if (collection != null && collection.mMarkerDragListener != null) {
        collection.mMarkerDragListener.onMarkerDragEnd(marker);
    }
}
 
Example #18
Source File: PoiOverlay.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
@Override
public final boolean onMarkerClick(Marker marker) {
    if (!mOverlayList.contains(marker)) {
        return false;
    }

    if (marker.getExtraInfo() != null) {
        return onPoiClick(marker.getExtraInfo().getInt("index"));
    }

    return false;
}
 
Example #19
Source File: MarkerManager.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
@Override
public boolean onMarkerClick(Marker marker) {
    Collection collection = mAllMarkers.get(marker);
    if (collection != null && collection.mMarkerClickListener != null) {
        // you can set the click action
        return collection.mMarkerClickListener.onMarkerClick(marker);
    } else  {
        ; // click single maker out of cluster
    }
    return false;
}
 
Example #20
Source File: IndoorPoiOverlay.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
@Override
public final boolean onMarkerClick(Marker marker) {
    if (!mOverlayList.contains(marker)) {
        return false;
    }
    if (marker.getExtraInfo() != null) {
        return onPoiClick(marker.getExtraInfo().getInt("index"));
    }
    return false;
}
 
Example #21
Source File: MarkerManager.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
public boolean remove(Marker marker) {
    if (mMarkers.remove(marker)) {
        mAllMarkers.remove(marker);
        marker.remove();
        return true;
    }
    return false;
}
 
Example #22
Source File: FreightTrackGoogleMapFragment.java    From ESeal with Apache License 2.0 5 votes vote down vote up
private void showBaiduMap(LocationDetail locationDetail) {
    if (locationDetail == null || locationDetail.isInvalid()) {
        return;
    }
    LatLng lng = locationDetail.getLatLng();

    OverlayOptions markerOptions = new MarkerOptions().flat(true).icon(BitmapDescriptorFactory
            .fromResource(R.drawable.ic_location_on_white_48dp)).position(lng);
    mMoveMarker = (Marker) mBaiduMap.addOverlay(markerOptions);

    //设置中心点
    mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLngZoom(lng, 16));
}
 
Example #23
Source File: FreightTrackMapFragment.java    From ESeal with Apache License 2.0 5 votes vote down vote up
private void showBaiduMap(LocationDetail locationDetail) {
    if (locationDetail == null || locationDetail.isInvalid()) {
        return;
    }
    LatLng lng = locationDetail.getLatLng();

    OverlayOptions markerOptions = new MarkerOptions().flat(true).icon(BitmapDescriptorFactory
            .fromResource(R.drawable.ic_location_on_white_48dp)).position(lng);
    mMoveMarker = (Marker) mBaiduMap.addOverlay(markerOptions);

    //设置中心点
    mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLngZoom(lng, 16));
}
 
Example #24
Source File: WalkingRouteOverlay.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
@Override
public final boolean onMarkerClick(Marker marker) {
    for (Overlay mMarker : mOverlayList) {
        if (mMarker instanceof Marker && mMarker.equals(marker)) {
            if (marker.getExtraInfo() != null) {
                onRouteNodeClick(marker.getExtraInfo().getInt("index"));
            }
        }
    }
    return true;
}
 
Example #25
Source File: FreightTrackBaiduMapFragment.java    From ESeal with Apache License 2.0 5 votes vote down vote up
private void showBaiduMap(LocationDetail locationDetail) {
    if (locationDetail == null || locationDetail.isInvalid()) {
        return;
    }
    LatLng lng = locationDetail.getLatLng();

    OverlayOptions markerOptions = new MarkerOptions().flat(true).icon(BitmapDescriptorFactory
            .fromResource(R.drawable.ic_location_on_white_48dp)).position(lng);
    mMoveMarker = (Marker) mBaiduMap.addOverlay(markerOptions);

    //设置中心点
    mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLngZoom(lng, 16));
}
 
Example #26
Source File: MainActivity.java    From Mobike with Apache License 2.0 5 votes vote down vote up
private void initMarkerClickEvent() {
    // 对Marker的点击
    baiduMap.setOnMarkerClickListener(new BaiduMap.OnMarkerClickListener() {
        @Override
        public boolean onMarkerClick(final Marker marker) {
            // 获得marker中的数据
            if (marker != null && marker.getExtraInfo() != null) {
                BikeInfo bikeInfo = (BikeInfo) marker.getExtraInfo().get("info");
                if (bikeInfo != null)
                    updateBikeInfo(bikeInfo);
            }
            return true;
        }
    });
}
 
Example #27
Source File: BikingRouteOverlay.java    From Mobike with Apache License 2.0 5 votes vote down vote up
@Override
public final boolean onMarkerClick(Marker marker) {
    for (Overlay mMarker : mOverlayList) {
        if (mMarker instanceof Marker && mMarker.equals(marker)) {
            if (marker.getExtraInfo() != null) {
                onRouteNodeClick(marker.getExtraInfo().getInt("index"));
            }
        }
    }
    return true;
}
 
Example #28
Source File: DrivingRouteOverlay.java    From Mobike with Apache License 2.0 5 votes vote down vote up
@Override
public final boolean onMarkerClick(Marker marker) {
    for (Overlay mMarker : mOverlayList) {
        if (mMarker instanceof Marker && mMarker.equals(marker)) {
            if (marker.getExtraInfo() != null) {
                onRouteNodeClick(marker.getExtraInfo().getInt("index"));
            }
        }
    }
    return true;
}
 
Example #29
Source File: MarkerManager.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
public void clear() {
    for (Marker marker : mMarkers) {
        marker.remove();
        mAllMarkers.remove(marker);
    }
    mMarkers.clear();
}
 
Example #30
Source File: WalkingRouteOverlay.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
@Override
public final boolean onMarkerClick(Marker marker) {
    for (Overlay mMarker : mOverlayList) {
        if (mMarker instanceof Marker && mMarker.equals(marker)) {
            if (marker.getExtraInfo() != null) {
                onRouteNodeClick(marker.getExtraInfo().getInt("index"));
            }
        }
    }
    return true;
}