private void InitOverlay() { var map = FindViewById<MapView>(Resource.Id.bmapView); var mBaiduMap = map.Map; //位置 LatLng hotelLatLng = new LatLng(ViewModel.HotelData.Latitude, ViewModel.HotelData.Longitude); OverlayOptions hotelOverlayOptions = new MarkerOptions() .InvokeIcon(_hotelBitmap) .InvokePosition(hotelLatLng) .InvokeZIndex(9); mBaiduMap.AddOverlay(hotelOverlayOptions).JavaCast<Marker>(); #region 当前位置 //LatLng locationLatLng = new LatLng(CurrentData.Latitude, CurrentData.Longitude); //OverlayOptions locationOverlayOptions = new MarkerOptions() // .InvokeIcon(_localtionBitmap) // .InvokePosition(locationLatLng) // .InvokeZIndex(9); //Marker locationMarker = _mBaiduMap.AddOverlay(locationOverlayOptions).JavaCast<Marker>(); ; //设置居中 var mMapStatusUpdate = MapStatusUpdateFactory.NewLatLng(hotelLatLng); //改变地图状态 mBaiduMap.SetMapStatus(mMapStatusUpdate); #endregion 当前位置 }
public void InitOverlay() { // add marker overlay LatLng llA = new LatLng(39.963175, 116.400244); LatLng llB = new LatLng(39.942821, 116.369199); LatLng llC = new LatLng(39.939723, 116.425541); LatLng llD = new LatLng(39.906965, 116.401394); OverlayOptions ooA = new MarkerOptions().InvokePosition(llA).InvokeIcon(bdA) .InvokeZIndex(9); mMarkerA = Android.Runtime.Extensions.JavaCast<Marker>(mBaiduMap.AddOverlay(ooA)); OverlayOptions ooB = new MarkerOptions().InvokePosition(llB).InvokeIcon(bdB) .InvokeZIndex(5); mMarkerB = Android.Runtime.Extensions.JavaCast<Marker>(mBaiduMap.AddOverlay(ooB)); OverlayOptions ooC = new MarkerOptions().InvokePosition(llC).InvokeIcon(bdC) .Perspective(false).Anchor(0.5f, 0.5f).InvokeRotate(30).InvokeZIndex(7); mMarkerC = Android.Runtime.Extensions.JavaCast<Marker>(mBaiduMap.AddOverlay(ooC)); OverlayOptions ooD = new MarkerOptions().InvokePosition(llD).InvokeIcon(bdD) .Perspective(false).InvokeZIndex(7); mMarkerD = Android.Runtime.Extensions.JavaCast<Marker>(mBaiduMap.AddOverlay(ooD)); // add ground overlay LatLng southwest = new LatLng(39.92235, 116.380338); LatLng northeast = new LatLng(39.947246, 116.414977); LatLngBounds bounds = new LatLngBounds.Builder().Include(northeast) .Include(southwest).Build(); OverlayOptions ooGround = new GroundOverlayOptions() .PositionFromBounds(bounds).InvokeImage(bdGround).InvokeTransparency(0.8f); mBaiduMap.AddOverlay(ooGround); MapStatusUpdate u = MapStatusUpdateFactory .NewLatLng(bounds.Center); mBaiduMap.SetMapStatus(u); }
private void InitView() { //设置标题栏 var img_header_back = FindViewById<ImageView> (Resource.Id.img_header_back); img_header_back.Click += (sender, e) => { this.Finish(); OverridePendingTransition(Android.Resource.Animation.SlideInLeft,Android.Resource.Animation.SlideOutRight); }; var bundle = Intent.Extras; var alarmPosition = bundle.GetString ("alarmPosition"); if (!string.IsNullOrEmpty (alarmPosition) && alarmPosition.Contains (",")) { var Positions = alarmPosition.Split(new char[]{','}); nPosition = Convert.ToDouble(Positions [0].Substring (1)); ePosition = Convert.ToDouble(Positions [1].Substring (1)); } var tv_back = FindViewById<TextView> (Resource.Id.tv_back); tv_back.Text = "报警详细"; var tv_desc = FindViewById<TextView> (Resource.Id.tv_desc); tv_desc.Text = "报警位置显示"; mMapView = FindViewById<MapView> (Resource.Id.bmap_view); bdMap = mMapView.Map; bdMap.MapType = BaiduMap.MapTypeNormal; LatLng sourceLatLng = new LatLng(nPosition,ePosition); // 将GPS设备采集的原始GPS坐标转换成百度坐标 CoordinateConverter converter = new CoordinateConverter(); converter.From(Com.Baidu.Mapapi.Utils.CoordinateConverter.CoordType.Gps); // sourceLatLng待转换坐标 converter.Coord(sourceLatLng); LatLng desLatLng = converter.Convert(); //构建MarkerOption,用于在地图上添加Marker //构建Marker图标 BitmapDescriptor bitmap = BitmapDescriptorFactory .FromResource(Resource.Drawable.ic_map); OverlayOptions option = new MarkerOptions().InvokePosition (desLatLng).InvokeIcon(bitmap).Draggable(true).InvokeZIndex(9); //在地图上添加Marker,并显示 bdMap.AddOverlay(option); // 将地图移动到覆盖物位置 MapStatusUpdate u = MapStatusUpdateFactory.NewLatLng(desLatLng); bdMap.SetMapStatus(u); }
public void OnGetSearchResult(CloudSearchResult result, int error) { if (result != null && result.PoiList != null && result.PoiList.Count > 0) { Log.Debug(LTAG, "onGetSearchResult, result length: " + result.PoiList.Count); mBaiduMap.Clear(); BitmapDescriptor bd = BitmapDescriptorFactory.FromResource(Resource.Drawable.icon_gcoding); LatLng ll; LatLngBounds.Builder builder = new LatLngBounds.Builder(); foreach (CloudPoiInfo info in result.PoiList) { ll = new LatLng(info.Latitude, info.Longitude); OverlayOptions oo = new MarkerOptions().InvokeIcon(bd).InvokePosition(ll); mBaiduMap.AddOverlay(oo); builder.Include(ll); } LatLngBounds bounds = builder.Build(); MapStatusUpdate u = MapStatusUpdateFactory.NewLatLngBounds(bounds); mBaiduMap.AnimateMapStatus(u); } }
private void InitOverlay() { var map = FindViewById<MapView>(Resource.Id.bmapView); var mBaiduMap = map.Map; //位置 LatLng hotelLatLng = new LatLng(ViewModel.OrderData.Base.BaiduLat, ViewModel.OrderData.Base.BaiduLon); OverlayOptions hotelOverlayOptions = new MarkerOptions() .InvokeIcon(_hotelBitmap) .InvokePosition(hotelLatLng) .InvokeZIndex(9); Marker hotelMarker = mBaiduMap.AddOverlay(hotelOverlayOptions).JavaCast<Marker>(); #region 当前位置 LatLng locationLatLng = new LatLng(CurrentData.Latitude, CurrentData.Longitude); OverlayOptions locationOverlayOptions = new MarkerOptions() .InvokeIcon(_localtionBitmap) .InvokePosition(locationLatLng) .InvokeZIndex(9); Marker locationMarker = mBaiduMap.AddOverlay(locationOverlayOptions).JavaCast<Marker>(); var zoomLevel = BaseHelper.GetZoomLevel(ViewModel.OrderData.Base.Distance/1000); //设置居中 var mMapStatusUpdate = MapStatusUpdateFactory.NewLatLngZoom(hotelLatLng, zoomLevel); //改变地图状态 mBaiduMap.SetMapStatus(mMapStatusUpdate); #endregion 当前位置 }
private void InitOverlay() { //位置 LatLng hotelLatLng = new LatLng(_hotelEntity.Latitude, _hotelEntity.Longitude); OverlayOptions hotelOverlayOptions = new MarkerOptions() .InvokeIcon(_hotelBitmap) .InvokePosition(hotelLatLng) .InvokeZIndex(9); Marker hotelMarker = _mBaiduMap.AddOverlay(hotelOverlayOptions).JavaCast<Marker>(); Bundle bundle = new Bundle(); bundle.PutSerializable("info", _hotelEntity); hotelMarker.ExtraInfo = bundle; #region 当前位置 LatLng locationLatLng = new LatLng(CurrentData.Latitude, CurrentData.Longitude); OverlayOptions locationOverlayOptions = new MarkerOptions() .InvokeIcon(_localtionBitmap) .InvokePosition(locationLatLng) .InvokeZIndex(9); Marker locationMarker = _mBaiduMap.AddOverlay(locationOverlayOptions).JavaCast<Marker>(); ; //设置居中 MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory.NewLatLng(locationLatLng); //改变地图状态 _mBaiduMap.SetMapStatus(mMapStatusUpdate); #endregion 当前位置 }