void SetNearestEventMarkers() { System.Threading.ThreadPool.QueueUserWorkItem(delegate { ShowLoadingView(PortableLibrary.Constants.MSG_LOADING_ALL_MARKERS); MemberModel.rootMember = GetUserObject(); mEventMarker = GetNearestEventMarkers(AppSettings.UserID); //mEventMarker = GetAllMarkers("58aafae816528b16d898a1f3"); HideLoadingView(); InvokeOnMainThread(() => { var boundPoints = new List <CLLocationCoordinate2D>(); if (mEventMarker != null && mEventMarker.markers.Count > 0) { for (int i = 0; i < mEventMarker.markers.Count; i++) { var point = mEventMarker.markers[i]; var imgPin = GetPinIconByType(point.type); var pointLocation = new CLLocationCoordinate2D(point.lat, point.lng); boundPoints.Add(pointLocation); AddMapPin(pointLocation, imgPin, i); } } if (boundPoints.Count > 0) { var mapBounds = new CoordinateBounds(); var myLocation = LocationHelper.GetLocationResult(); var myLocation2D = new CLLocationCoordinate2D(myLocation.Latitude, myLocation.Longitude); boundPoints.Add(myLocation2D); foreach (var bound in boundPoints) { mapBounds = mapBounds.Including(bound); } mMapView.MoveCamera(CameraUpdate.FitBounds(mapBounds, 50.0f)); } }); }); }
public bool DidTapCluster(GMUClusterManager clusterManager, IGMUCluster cluster) { // zoom to expand the cluster var bounds = new CoordinateBounds(cluster.Position, cluster.Position); foreach (var item in cluster.Items) { bounds = bounds.Including(item.Position); } try { var cameraUpdate = CameraUpdate.FitBounds(bounds, 100); mapView.MoveCamera(cameraUpdate); } catch (System.Exception ex) { Console.WriteLine(ex.StackTrace); } return(true); }
void GetMarkersAndPoints() { System.Threading.ThreadPool.QueueUserWorkItem(delegate { ShowLoadingView(PortableLibrary.Constants.MSG_LOADING_ALL_MARKERS); mEventMarker = GetAllMarkers(eventID); var trackPoints = GetTrackPoints(eventID); HideLoadingView(); InvokeOnMainThread(() => { var boundPoints = new List <CLLocationCoordinate2D>(); if (mEventMarker != null && mEventMarker.markers.Count > 0) { for (int i = 0; i < mEventMarker.markers.Count; i++) { var point = mEventMarker.markers[i]; var imgPin = GetPinIconByType(point.type); var pointLocation = new CLLocationCoordinate2D(point.lat, point.lng); boundPoints.Add(pointLocation); AddMapPin(pointLocation, imgPin, i); } } if (trackPoints != null && trackPoints.Count > 0) { if (trackPoints[0].Count > 0) { var startPoint = trackPoints[0][0]; var endPoint = trackPoints[trackPoints.Count - 1][trackPoints[trackPoints.Count - 1].Count - 1]; var startLocation = new CLLocationCoordinate2D(startPoint.Latitude, startPoint.Longitude); var endLocation = new CLLocationCoordinate2D(endPoint.Latitude, endPoint.Longitude); AddMapPin(startLocation, GetPinIconByType("pSTART"), -1); AddMapPin(endLocation, GetPinIconByType("pFINISH"), -1); } for (int i = 0; i < trackPoints.Count; i++) { var tPoints = trackPoints[i]; var path = new MutablePath(); var polyline = new Polyline(); for (int j = 0; j < tPoints.Count; j++) { var tPoint = tPoints[j]; var tLocation = new CLLocationCoordinate2D(tPoint.Latitude, tPoint.Longitude); if (j < tPoints.Count - 1) { var distance = DistanceAtoB(tPoint, tPoints[j + 1]); if (PortableLibrary.Constants.AVAILABLE_DISTANCE_MAP > distance) { var nPoint = tPoints[j + 1]; path.AddCoordinate(tLocation); } else { polyline.Path = path; polyline.StrokeColor = GetRandomColor(i); polyline.StrokeWidth = 5; polyline.Geodesic = true; polyline.Map = mMapView; path = new MutablePath(); polyline = new Polyline(); } } polyline.Path = path; polyline.StrokeColor = GetRandomColor(i); polyline.StrokeWidth = 5; polyline.Geodesic = true; polyline.Map = mMapView; boundPoints.Add(tLocation); } } } if (boundPoints.Count == 0) { var camera = CameraPosition.FromCamera(PortableLibrary.Constants.LOCATION_ISURAEL[0], PortableLibrary.Constants.LOCATION_ISURAEL[1], zoom: PortableLibrary.Constants.MAP_ZOOM_LEVEL); mMapView = MapView.FromCamera(RectangleF.Empty, camera); } else { var mapBounds = new CoordinateBounds(); foreach (var bound in boundPoints) { mapBounds = mapBounds.Including(bound); } mMapView.MoveCamera(CameraUpdate.FitBounds(mapBounds, 50.0f)); } }); }); }
private async void GetMyValidBookedReservations() { ShowLoadingView("Loading data..."); _pickups = new List <Dictionary <string, string> > (); try { var lResult = LocationHelper.GetLocationResult(); if (_selectedMarker != null) { _selectedMarker.Map = null; mapView.Clear(); } if (_currentMarkers != null) { foreach (var marker in _currentMarkers) { marker.Map = null; } _currentMarkers.Clear(); mapView.MarkerInfoWindow = null; } NSDateFormatter dateFormat = new NSDateFormatter(); dateFormat.DateFormat = "MM/dd/yyyy"; NSDate now = NSDate.FromTimeIntervalSinceReferenceDate((DateTime.Now - (new DateTime(2001, 1, 1, 0, 0, 0))).TotalSeconds); var strNow = dateFormat.ToString(now); var customerID = AppSettings.UserID; // please take a look it, Pavel var dic = new Dictionary <String, String> { { Constant.GETREADYFORPICKUPLIST_CUSTOMERID, "553890" }, { Constant.GETREADYFORPICKUPLIST_CURRENTDATE, "2/13/2015" } }; //var dic = new Dictionary<String, String> //{ // {Constant.GETREADYFORPICKUPLIST_CUSTOMERID, customerID}, // {Constant.GETREADYFORPICKUPLIST_CURRENTDATE, strNow} //}; var result = await AppData.ApiCall(Constant.GETREADYFORPICKUPLIST, dic); var tt = (GetReadyForPickupListResponse)AppData.ParseResponse(Constant.GETREADYFORPICKUPLIST, result); var availableReservations = tt.PickupList; for (int i = 0; i < availableReservations.Count; i++) { var reservation = availableReservations[i]; Task runSync = Task.Factory.StartNew(async() => { var pickupData = await GetPickupDataForReservation(reservation); _pickups.Add(pickupData); }).Unwrap(); runSync.Wait(); } var bounds = new CoordinateBounds(); var listReservations = new List <KeyValuePair <object, string> >(); listReservations.Add(new KeyValuePair <object, string>("0", "Ready for all rides")); foreach (Dictionary <String, String> pickup in _pickups) { var marker = new Marker { Position = new CLLocationCoordinate2D(double.Parse(pickup["Latitude"]), double.Parse(pickup["Longitude"])), Map = mapView, Icon = rotateImage(UIImage.FromBundle(getMapVehicleIconByServiceID(pickup["ServiceID"])), float.Parse(pickup["Angle"])), ZIndex = int.Parse(pickup["ResID"]) }; _currentMarkers.Add(marker); bounds = bounds.Including(marker.Position); listReservations.Add(new KeyValuePair <object, string>(pickup["ResID"], pickup["DisplayTxt"])); //string.Format("Shared Van (7 Passengers) \n 3:45 Pick-Up to Los Angeles", pickup["ResID"], pickup["ResType"]))); } if (_pickups.Count > 0) { btnReadyPickup.BackgroundColor = UIColor.Green; btnReadyPickup.SetTitle(string.Format("READY FOR PICKUP ({0})", _pickups.Count.ToString()), UIControlState.Normal); SetupReadyPickup(txtBtnReadyPickup, listReservations, CallForReadyPickup); } else { btnReadyPickup.BackgroundColor = UIColor.Gray; btnReadyPickup.SetTitle("READY FOR PICKUP", UIControlState.Normal); } bounds = bounds.Including(new CLLocationCoordinate2D(lResult.Latitude, lResult.Longitude)); _selectedMarker = new Marker { Position = new CLLocationCoordinate2D(lResult.Latitude, lResult.Longitude), Map = mapView, Icon = UIImage.FromBundle("icon_mylocation.png") }; mapView.SelectedMarker = _selectedMarker; if (_pickups.Count > 0) { mapView.Animate(CameraUpdate.FitBounds(bounds, 100f)); } mapView.TappedMarker = (map, maker) => { mapView.MarkerInfoWindow = new GMSInfoFor(markerInfoWindow); return(false); }; } catch (Exception ex) { CrashReporter.Report(ex); HideLoadingView(); return; } HideLoadingView(); }