/** * 定位接收到的地址 **/ 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)); }
/** * 缩放地图,使所有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())); } }
/** * 缩放地图,使所有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())); } }
private void toggleInfoWindow(Marker marker) { if (marker == null || mapView == null || mapView.getMap() == null) return; if (isInfoWindowShown) { mapView.getMap().hideInfoWindow(); isInfoWindowShown = false; } else { // sdk示例代码是用application context来创建infoWindow上的View的 // 如果该view直接放在activity上,重复执行show/hide/show会出错 View view = LayoutInflater.from(getApplicationContext()) .inflate(R.layout.locatino_map_point, null); TextView textView = (TextView) view.findViewById(R.id.textView); textView.setText(marker.getTitle()); int yOffset = (int) (0.5f + TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 40, getResources().getDisplayMetrics())); mapView.getMap().showInfoWindow(new InfoWindow( BitmapDescriptorFactory.fromView(textView), new LatLng(latitude, longitude), -yOffset, null)); isInfoWindowShown = true; } }
private void initMarkerClickEvent() { mBaiduMap.setOnMarkerClickListener(new OnMarkerClickListener() { @Override public boolean onMarkerClick(final Marker marker) { LatLng markerLat = marker.getPosition(); Point p = mBaiduMap.getProjection().toScreenLocation(markerLat); //mMarkerInfoLy.setVisibility(View.VISIBLE); View location = getPopCameraView(); p.y = -83; mInfoWindow = new InfoWindow(location, markerLat,p.y); mBaiduMap.showInfoWindow(mInfoWindow); // Log.d("wang","setOnMarkerClickListener location.latitude is " + markerLat.latitude + " location.longitude is " + markerLat.longitude); judgeClickCamera(markerLat); flag = true; return true; } }); }
/** * ���ŵ�ͼ��ʹ����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())); } }
@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; }
@Override public void updateMarker(MarkerInfo markerInfo, boolean isDraggable) { // if the drone hasn't received a gps signal yet final LatLong coord = markerInfo.getPosition(); if (coord == null) { return; } final LatLng position = DroneHelper.CoordToBaiduLatLang(coord); Marker marker = mBiMarkersMap.getValue(markerInfo); if (marker == null) { // Generate the marker generateMarker(markerInfo, position, isDraggable); } else { // Update the marker updateMarker(marker, markerInfo, position, isDraggable); } }
private void generateMarker(MarkerInfo markerInfo, LatLng position, boolean isDraggable) { Log.v("123","SSSSSSSSSSSSSSSSSSSSSSSSSSSSS"); final MarkerOptions markerOptions = new MarkerOptions() .position(position) .draggable(isDraggable) .anchor(markerInfo.getAnchorU(), markerInfo.getAnchorV()) .title(markerInfo.getSnippet()).title(markerInfo.getTitle()); final Bitmap markerIcon = markerInfo.getIcon(getResources()); if (markerIcon != null) { markerOptions.icon(BitmapDescriptorFactory.fromBitmap(markerIcon)); } else { markerOptions.icon(BitmapDescriptorFactory .fromResource(R.drawable.ic_marker_white)); } Marker marker = (Marker)getBaiduMap().addOverlay(markerOptions); mBiMarkersMap.put(markerInfo, marker); }
private void initMaker() { for (FootInfo info : mFootList) { if (info.geo != null) { Double lat = Double.valueOf(info.geo.latitude); Double lon = Double.valueOf(info.geo.longitude); // 定义Maker坐标点 LatLng point = new LatLng(lat,lon); // 构建Marker图标 BitmapDescriptor bitmap = BitmapDescriptorFactory .fromResource(R.drawable.icon_gcoding); // 构建MarkerOption,用于在地图上添加Marker OverlayOptions option = new MarkerOptions().position(point) .icon(bitmap).zIndex(19); marker = (Marker)baiduMap.addOverlay(option); } } mMapView.invalidate(); }
private void initMarkerClickEvent() { // 对Marker的点击 mBaiduMap.setOnMarkerClickListener(new OnMarkerClickListener() { @Override public boolean onMarkerClick(final Marker marker) { // 将marker所在的经纬度的信息转化成屏幕上的坐标 System.out.println("点击marker:" + marker.getPosition() + marker.toString()); final LatLng ll = marker.getPosition(); int index = marker.getZIndex(); if (index == 2) { float tempZoom = 18; if (curZoom != 17) tempZoom = curZoom + 1.0f; showCurrtenStroeOnMap(ll, tempZoom); } else { // 获得marker中的数据 StoreData info = (StoreData) marker.getExtraInfo().get("info"); Bundle pBundle = new Bundle(); pBundle.putSerializable("data", info); openActivity(StoreInformationActivity.class, pBundle); } return true; } }); }
@Override public boolean onMarkerClick(final Marker marker) { final LatLng ll = marker.getPosition(); Point p = mBaiduMap.getProjection().toScreenLocation(ll); p.y -= 47; LatLng llInfo = mBaiduMap.getProjection().fromScreenLocation(p); Button button = new Button(getApplicationContext()); if (marker == mMarker) { button.setText(marker.getPosition().latitude + " // " + marker.getPosition().longitude); } InfoWindow mInfoWindow = new InfoWindow(button, llInfo, mOnInfoWindowClickListener); mBaiduMap.showInfoWindow(mInfoWindow); return true; }
@Override public boolean onMarkerClick(final Marker marker) { final LatLng ll = marker.getPosition(); Point p = mBaiduMap.getProjection().toScreenLocation(ll); p.y -= 47; LatLng llInfo = mBaiduMap.getProjection().fromScreenLocation(p); Button button = new Button(getApplicationContext()); if (marker == mMarkerA) { button.setText(marker.getPosition().latitude + " // " + marker.getPosition().longitude); } else if (marker == mMarkerB) { button.setText(getDistanceMsg(mCenterLatLng, ll)); } else if (marker == mMarkerC) { button.setText(getDistanceMsg(mCenterLatLng, ll)); } InfoWindow mInfoWindow = new InfoWindow(button, llInfo, mOnInfoWindowClickListener); mBaiduMap.showInfoWindow(mInfoWindow); return true; }
@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; }
@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; }
public final boolean onMarkerClick(Marker marker) { if (mOverlayList != null && mOverlayList.contains(marker)) { return onBusStationClick(mOverlayList.indexOf(marker)); } else { return false; } }
private void initMarkerClickEvent() { // 对Marker的点击 mBaiduMap.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; } }); }
/** * 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(); }
private void removeMarker(Marker m) { Cluster<T> cluster = mMarkerToCluster.get(m); mClusterToMarker.remove(cluster); mMarkerCache.remove(m); mMarkerToCluster.remove(m); mClusterManager.getMarkerManager().remove(m); }
@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; }
@Override public void onMarkerDragStart(Marker marker) { Collection collection = mAllMarkers.get(marker); if (collection != null && collection.mMarkerDragListener != null) { collection.mMarkerDragListener.onMarkerDragStart(marker); } }
@Override public void onMarkerDrag(Marker marker) { Collection collection = mAllMarkers.get(marker); if (collection != null && collection.mMarkerDragListener != null) { collection.mMarkerDragListener.onMarkerDrag(marker); } }
@Override public void onMarkerDragEnd(Marker marker) { Collection collection = mAllMarkers.get(marker); if (collection != null && collection.mMarkerDragListener != null) { collection.mMarkerDragListener.onMarkerDragEnd(marker); } }
public boolean remove(Marker marker) { if (mMarkers.remove(marker)) { mAllMarkers.remove(marker); marker.remove(); return true; } return false; }
public void clear() { for (Marker marker : mMarkers) { marker.remove(); mAllMarkers.remove(marker); } mMarkers.clear(); }