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); }
/** * ��ӵ㡢�ߡ�����Ρ�Բ������ */ public void AddCustomElementsDemo() { // ������� LatLng p1 = new LatLng(39.97923, 116.357428); LatLng p2 = new LatLng(39.94923, 116.397428); LatLng p3 = new LatLng(39.97923, 116.437428); IList<LatLng> points = new List<LatLng>(); points.Add(p1); points.Add(p2); points.Add(p3); // Android.Graphics.Color.Argb(0xAA, 0xFF, 0x00, 0x00).ToArgb(); // Android.Graphics.Color.ParseColor("#AAFF0000").ToArgb(); OverlayOptions ooPolyline = new PolylineOptions().InvokeWidth(10) .InvokeColor(Android.Graphics.Color.ParseColor("#AAFF0000").ToArgb()).InvokePoints(points); mBaiduMap.AddOverlay(ooPolyline); // ��ӻ��� OverlayOptions ooArc = new ArcOptions().InvokeColor(Android.Graphics.Color.ParseColor("#AA00FF00").ToArgb()).InvokeWidth(4) .Points(p1, p2, p3); mBaiduMap.AddOverlay(ooArc); // ���Բ LatLng llCircle = new LatLng(39.90923, 116.447428); OverlayOptions ooCircle = new CircleOptions().InvokeFillColor(0x000000FF) .InvokeCenter(llCircle).InvokeStroke(new Stroke(5, Android.Graphics.Color.ParseColor("#AA000000").ToArgb())) .InvokeRadius(1400); mBaiduMap.AddOverlay(ooCircle); LatLng llDot = new LatLng(39.98923, 116.397428); OverlayOptions ooDot = new DotOptions().InvokeCenter(llDot).InvokeRadius(6) .InvokeColor(Android.Graphics.Color.ParseColor("#FF0000FF").ToArgb()); mBaiduMap.AddOverlay(ooDot); // ��Ӷ���� LatLng pt1 = new LatLng(39.93923, 116.357428); LatLng pt2 = new LatLng(39.91923, 116.327428); LatLng pt3 = new LatLng(39.89923, 116.347428); LatLng pt4 = new LatLng(39.89923, 116.367428); LatLng pt5 = new LatLng(39.91923, 116.387428); List<LatLng> pts = new List<LatLng>(); pts.Add(pt1); pts.Add(pt2); pts.Add(pt3); pts.Add(pt4); pts.Add(pt5); OverlayOptions ooPolygon = new PolygonOptions().InvokePoints(pts) .InvokeStroke(new Stroke(5, Android.Graphics.Color.ParseColor("#AA00FF00").ToArgb())).InvokeFillColor(Android.Graphics.Color.ParseColor("#AAFFFF00").ToArgb()); mBaiduMap.AddOverlay(ooPolygon); // ������� LatLng llText = new LatLng(39.86923, 116.397428); OverlayOptions ooText = new TextOptions().InvokeBgColor(Android.Graphics.Color.ParseColor("#AAFFFF00").ToArgb()) .InvokeFontSize(24).InvokeFontColor(Android.Graphics.Color.ParseColor("#FFFF00FF").ToArgb()).InvokeText("�ٶȵ�ͼSDK").InvokeRotate(-30) .InvokePosition(llText); mBaiduMap.AddOverlay(ooText); }
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); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Intent intent = Intent; if (intent.HasExtra("x") && intent.HasExtra("y")) { // 当用intent参数时,设置中心点为指定点 Bundle b = intent.Extras; LatLng p = new LatLng(b.GetDouble("y"), b.GetDouble("x")); mMapView = new MapView(this, new BaiduMapOptions().MapStatus(new MapStatus.Builder() .Target(p).Build())); } else { mMapView = new MapView(this, new BaiduMapOptions()); } SetContentView(mMapView); mBaiduMap = mMapView.Map; }
public void SearchButtonProcess(View v) { if (v.Id == Resource.Id.reversegeocode) { EditText lat = FindViewById<EditText>(Resource.Id.lat); EditText lon = FindViewById<EditText>(Resource.Id.lon); LatLng ptCenter = new LatLng((float.Parse(lat.Text .ToString())), (float.Parse(lon.Text.ToString()))); // ��Geo���� mSearch.ReverseGeoCode(new ReverseGeoCodeOption() .Location(ptCenter)); } else if (v.Id == Resource.Id.geocode) { EditText editCity = FindViewById<EditText>(Resource.Id.city); EditText editGeoCodeKey = FindViewById<EditText>(Resource.Id.geocodekey); // Geo���� mSearch.Geocode(new GeoCodeOption().City( editCity.Text.ToString()).Address( editGeoCodeKey.Text.ToString())); } }
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); } }
public void OnReceiveLocation(BDLocation location) { // map view 销毁后不在处理新接收的位置 if (location == null || _Activity.mMapView == null) return; MyLocationData locData = new MyLocationData.Builder() .Accuracy(location.Radius) // 此处设置开发者获取到的方向信息,顺时针0-360 .Direction(100).Latitude(location.Latitude) .Longitude(location.Longitude).Build(); _Activity.mBaiduMap.SetMyLocationData(locData); if (_Activity.isFirstLoc) { _Activity.isFirstLoc = false; LatLng ll = new LatLng(location.Latitude, location.Longitude); MapStatusUpdate u = MapStatusUpdateFactory.NewLatLng(ll); _Activity.mBaiduMap.AnimateMapStatus(u); } }
public void OnMapClick(LatLng point) { mBaiduMap.HideInfoWindow(); }
public void OnInfoWindowClick() { LatLng llNew = new LatLng(ll.Latitude + 0.005, ll.Longitude + 0.005); marker.Position = llNew; iOnMarkerClickListenerImpl.overlayDemo.mBaiduMap.HideInfoWindow(); }
public void OnMapLongClick(LatLng point) { mapControlDemo.touchType = "����"; mapControlDemo.currentPt = point; mapControlDemo.UpdateMapState(); }
public void StartNavi(View view) { LatLng pt1 = new LatLng(mLat1, mLon1); LatLng pt2 = new LatLng(mLat2, mLon2); // ���� �������� NaviPara para = new NaviPara(); para.StartPoint = pt1; para.StartName = "�����↑ʼ"; para.EndPoint = pt2; para.EndName = "���������"; try { BaiduMapNavigation.OpenBaiduMapNavi(para, this); } catch (BaiduMapAppNotSupportNaviException e) { e.PrintStackTrace(); // ��Ȼ����ԭ������, ������IKVM��bug, Ҳ����������������, ��, �����ָ· // ������� RuntimeException + if/else �ǶԵ���, �ӵ� } catch (RuntimeException e) { // (imknown ע)����ԭ�������������� : e.Message // Android.Runtime.Extensions.JavaCast<BaiduMapAppNotSupportNaviException>(e); // Android.Runtime.Extensions.JavaCast<IllegalNaviArgumentException>(e); string currentExceptionSimpleName = e.Class.SimpleName; string classBaiduMapAppNotSupportNaviExceptionSimpleName = typeof(BaiduMapAppNotSupportNaviException).Name; // string classIllegalNaviArgumentExceptionSimpleName = typeof(IllegalNaviArgumentException).Name; if (classBaiduMapAppNotSupportNaviExceptionSimpleName == currentExceptionSimpleName) { e.PrintStackTrace(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetMessage("����δ��װ�ٶȵ�ͼapp��app�汾���ͣ����ȷ�ϰ�װ��"); builder.SetTitle("��ʾ"); // builder.SetPositiveButton("ȷ��", delegate {}); // builder.SetPositiveButton("ȷ��", delegate(object sender, DialogClickEventArgs args) {int which = args.Which;}); // builder.SetPositiveButton("ȷ��", (sender, args) => {int which = args.Which;}); // builder.SetPositiveButton("ȷ��", (object sender, DialogClickEventArgs args) => {int which = args.Which;}); builder.SetPositiveButton("ȷ��", (sender, args) => { IDialogInterface dialog = (IDialogInterface)sender; // IDialogInterface dialog = Android.Runtime.Extensions.JavaCast<IDialogInterface>(sender); dialog.Dismiss(); BaiduMapNavigation.GetLatestBaiduMapApp(this); }); builder.SetNegativeButton("ȡ��", (sender, args) => { IDialogInterface dialog = (IDialogInterface)sender; dialog.Dismiss(); }); builder.Create().Show(); } } }
public void StartWebNavi(View view) { LatLng pt1 = new LatLng(mLat1, mLon1); LatLng pt2 = new LatLng(mLat2, mLon2); // ���� �������� NaviPara para = new NaviPara(); para.StartPoint = pt1; para.EndPoint = pt2; BaiduMapNavigation.OpenWebBaiduMapNavi(para, this); }
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 当前位置 }
public void OnReceiveLocation(Com.Baidu.Location.BDLocation location) { var context = (BaiduMapSample)Context; var locData = new MyLocationData.Builder() .Accuracy(location.Radius).Latitude(location.Latitude) .Longitude(location.Longitude).Build(); context.mBaiduMap.SetMyLocationData(locData); var latlng = new LatLng(location.Latitude, location.Longitude); var update = MapStatusUpdateFactory.NewLatLng(latlng); context.mBaiduMap.AnimateMapStatus(update); }
public IOnInfoWindowClickListenerImplA(IOnMarkerClickListenerImpl iOnMarkerClickListenerImpl, LatLng ll, Marker marker) { this.iOnMarkerClickListenerImpl = iOnMarkerClickListenerImpl; this.ll = ll; this.marker = marker; }
public void OnReceiveLocation(BDLocation location) { // map view ���ٺ��ڴ����½��յ�λ�� if (location == null || locationOverlayDemo.mMapView == null) return; MyLocationData locData = new MyLocationData.Builder() .Accuracy(location.Radius) // �˴����ÿ�����ȡ���ķ�����Ϣ��˳ʱ��0-360 .Direction(100).Latitude(location.Latitude) .Longitude(location.Longitude).Build(); locationOverlayDemo.mBaiduMap.SetMyLocationData(locData); if (locationOverlayDemo.isFirstLoc) { locationOverlayDemo.isFirstLoc = false; LatLng ll = new LatLng(location.Latitude, location.Longitude); MapStatusUpdate u = MapStatusUpdateFactory.NewLatLng(ll); locationOverlayDemo.mBaiduMap.AnimateMapStatus(u); } }