Exemplo n.º 1
0
 /// <summary>
 /// Shows the markers on map.
 /// </summary>
 /// <param name="friendList">Friend list.</param>
 private void ShowMarkersOnMap(List <User> friendList)
 {
     try
     {
         if (friendList.Count > 0)
         {
             InvokeOnMainThread(() =>
             {
                 mapView.Clear();
                 foreach (var user in friendList)
                 {
                     var latLng = new CLLocationCoordinate2D(double.Parse(user.Latitude), double.Parse(user.Longitude));
                     double price;
                     bool isDouble = Double.TryParse(user.Miles.ToString(), out price);
                     if (isDouble)
                     {
                         user.Distance = user.Miles;
                     }
                     CreatePins(user); // Create Annotations on map
                 }
                 CreateCircle();       // Radius circle on map
                 AnimateCamera();      //For focusing on current location
             });
         }
         else
         {
             CreateCircle();  // Radius circle on map
         }
     }
     catch (System.Exception e)
     {
         PrintLogDetails.instance.PrintLogDeatails("Map", "Friendlist", e.Message);
     }
 }
        async void HandleLongPress(object sender, GMSCoordEventArgs e)
        {
            //clearing previous markers
            mapView.Clear();
            CLLocationCoordinate2D coord = new CLLocationCoordinate2D(e.Coordinate.Latitude, e.Coordinate.Longitude);
            var marker = Marker.FromPosition(coord);

            //marker.Title = string.Format("Marker 1");
            marker.Layer.Frame = new CGRect(0, 0, 10, 10);
            //marker.Icon.
            marker.Icon = UIImage.FromBundle("add_loc_marker.png");
            //marker.Icon.Scale(new CGSize(marker.Icon.Size.Width, marker.Icon.Size.Height), 25F);
            //SetMarkerSize(ref marker);
            marker.Map    = mapView;
            lat_temporary = e.Coordinate.Latitude.ToString().Replace(',', '.');
            lng_temporary = e.Coordinate.Longitude.ToString().Replace(',', '.');
            CLLocation temp_coords = new CLLocation(e.Coordinate.Latitude, e.Coordinate.Longitude);

            //HomeAddressViewController.FullAddressStatic = await ReverseGeocodeToConsoleAsync(temp_coords);
            if (!String.IsNullOrEmpty(HomeAddressViewController.FullAddressTemp) && HomeAddressViewController.FullAddressTemp != " ")
            {
                address_textLabel.Text = HomeAddressViewController.FullAddressTemp;
                //address_textView.Hidden = false;
            }
        }
Exemplo n.º 3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.Frame            = UIScreen.MainScreen.Bounds;
            View.BackgroundColor  = UIColor.White;
            View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;

            SetupMap();

            //Setup button to clear map
            var btn = new UIButton(new RectangleF(0, 0, 100, 50));

            btn.Layer.BorderWidth  = 1;
            btn.Layer.CornerRadius = 5;
            btn.Layer.BorderColor  = UIColor.Black.CGColor;
            btn.SetTitle(@"Clear Map", UIControlState.Normal);
            btn.BackgroundColor = UIColor.Gray;
            btn.TouchUpInside  += (s, e) =>
            {
                _mapView.Clear();
                _mapDelegate.Lines.Clear();
                _mapDelegate.Locations.Clear();
            };


            _mapView.AddSubview(btn);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Populates current list of features on map and associates icon with each
        /// </summary>
        private void KML_WorkCompleted()
        {
            string  icon;
            Marker  marker;
            UIImage iconimage;

            this.InvokeOnMainThread(() =>
            {
                mapView.Clear();

                if (features != null)                 // may be null if invalid map url
                {
                    foreach (Feature feature in features.features)
                    {
                        icon            = feature.properties.iconurl;
                        icon            = icon.Substring(icon.LastIndexOf("/") + 1);
                        marker          = new Marker();
                        marker.Position = new CLLocationCoordinate2D(feature.geometry.coordinates[1], feature.geometry.coordinates[0]);
                        marker.Title    = feature.properties.title;
                        iconimage       = _mapIconManager.GetImageForIconName(icon);

                        if (iconimage != null)
                        {
                            marker.Icon = iconimage;
                        }
                        marker.Map = mapView;
                    }
                }

                // reset interval since it may have changed since the last time this was run
                _bgWorkerWrapper_MapFeatures.SetInterval(_watchTowerSettings.UpdateInterval);
            });
        }
Exemplo n.º 5
0
            protected override void HighlightRoutes()
            {
                _outer._btnRight.Enabled = _highlighedIndex != (_pointDrawingInfos.Count - 1);
                _outer._btnLeft.Enabled  = _highlighedIndex != 0;

                _outer._btnSelStart.SetTitle(_pointDrawingInfos [_highlighedIndex].Point.Name,
                                             UIControlState.Normal);

                MapView.Clear();
                _markers.Clear();
                _routeLines.Clear();

                foreach (var pdi in _pointDrawingInfos)
                {
                    // draw markers
                    var mPlace = pdi.Point;
                    var marker = new Marker()
                    {
                        Title    = mPlace.Name,
                        Position = Utils.GetCLLoc(mPlace.Loc),
                        Map      = MapView
                    };

                    if (pdi == _highlighedPoint)
                    {
                        MapView.SelectedMarker = marker;
                    }

                    _markers.Add(marker);

                    DrawPolyline(pdi.Polyline);
                }
            }
Exemplo n.º 6
0
    void DoAccept(ConfirmView v)
    {
        GameObject.Destroy(v.gameObject);
        isDisplayingConfirm = false;
        CardLevelSheet c        = cardLevelSheets[mediumCardView];
        Point          p        = selectedTileView.Location;
        Unit           u        = new Unit(c.Name, c.ID, c.Type, c.Subtype, c.Text, c.Text, c.Text, p);
        UnitView       unitView = (UnitView)((GameObject)Instantiate(UnitPrefab)).GetComponent("UnitView");

        unitView.MouseEnter = UnitViewEnter;
        unitView.MouseExit  = UnitViewExit;
        unitView.MouseOver  = UnitViewOver;
        unitView.SetPosition(mapView.GetTileViewAt(p).GetPosition());
        unitView.SetColor(Color.white);
        unitViews[u]    = unitView;
        units[unitView] = u;

        List <string> toRemove = new List <string>();

        foreach (CardView cv in cards)
        {
            if (cv.Id == c.ID)
            {
                toRemove.Add(cv.Id);
            }
        }

        foreach (string s in toRemove)
        {
            foreach (CardView cv in cards)
            {
                if (cv.Id == s)
                {
                    cards.Remove(cv);
                    GameObject.Destroy(cv.gameObject);
                    break;
                }
            }
        }

        mapView.Clear();
        cardLevelSheets.Remove(mediumCardView);
        playerActions.Add(new SummonAction(c, u.Location));
    }
Exemplo n.º 7
0
        async void RefreshClicked()
        {
            refreshText.Text = "Refreshing...";
            mapView.Clear();
            List <Data> data = await busData.GetBusData();

            foreach (Data element in data)
            {
                googleMaps.AddMarker(element.lat, element.lon, UIColor.FromRGB(0, 0, 0), element);
            }

            refreshText.Text = "Refreshed at " + busData.GetTimeNowString();
        }
 void HandleLongPress(object sender, GMSCoordEventArgs e)
 {
     mapView.Clear();
     var marker = new Marker()
     {
         Title = string.Format("Marker at: {0}, {1}", e.Coordinate.Latitude, e.Coordinate.Longitude),
         Position = e.Coordinate,
         AppearAnimation = MarkerAnimation.Pop,
         Map = mapView
     };
     //latti = e.Coordinate.Latitude;
     //longi = e.Coordinate.Longitude;
     // Add the new marker to the list of markers.
     //markers.Add(marker);
 }
Exemplo n.º 9
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var camera = CameraPosition.FromCamera(-37.81969, 144.966085, 4);

            mapView = MapView.FromCamera(CGRect.Empty, camera);
            AddDefaultMarkers();

            // Add a button which adds random markers to the map.
            var addButton   = new UIBarButtonItem(UIBarButtonSystemItem.Add, DidTapAdd);
            var clearButton = new UIBarButtonItem("Clear Markers", UIBarButtonItemStyle.Plain, (o, s) => {
                mapView.Clear();
                AddDefaultMarkers();
            });

            NavigationItem.RightBarButtonItems = new [] { addButton, clearButton };

            View = mapView;
        }
        async void HandleLongPress(object sender, GMSCoordEventArgs e)
        {
            //clearing previous markers
            mapView.Clear();
            CLLocationCoordinate2D coord = new CLLocationCoordinate2D(e.Coordinate.Latitude, e.Coordinate.Longitude);
            var marker = Marker.FromPosition(coord);

            //marker.Title = string.Format("Marker 1");
            marker.Icon = UIImage.FromBundle("add_loc_marker.png");
            marker.Map  = mapView;

            lat_temporary = e.Coordinate.Latitude.ToString().Replace(',', '.');
            lng_temporary = e.Coordinate.Longitude.ToString().Replace(',', '.');

            CLLocation temp_coords = new CLLocation(e.Coordinate.Latitude, e.Coordinate.Longitude);

            //CompanyAddressViewController.FullCompanyAddressStatic = await ReverseGeocodeToConsoleAsync(temp_coords);
            if (!String.IsNullOrEmpty(CompanyAddressViewController.FullCompanyAddressTemp) && CompanyAddressViewController.FullCompanyAddressTemp != " ")
            {
                address_textLabel.Text = CompanyAddressViewController.FullCompanyAddressTemp;
                //address_textView.Hidden = false;
            }
        }
Exemplo n.º 11
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName.Equals("VisibleRegion") && !isDrawn)
            {
                MapView.Clear();

                foreach (var pin in this.MapControl.ExtendedPins)
                {
                    var marker = new MarkerOptions();
                    marker.SetPosition(new LatLng(pin.Pin.Position.Latitude, pin.Pin.Position.Longitude));
                    marker.SetTitle(pin.Pin.Label);
                    marker.SetSnippet(pin.Pin.Address);

                    if (MapControl.GetPinViewDelegate != null)
                    {
                        var formsView = MapControl.GetPinViewDelegate(pin);
                        marker = marker.Anchor((float)formsView.AnchorX, (float)formsView.AnchorY);
                        //var nativeView = Utils.ConvertFormsToNative (formsView, new Rectangle (0, 0, (double)Utils.DpToPx ((float)formsView.WidthRequest), (double)Utils.DpToPx ((float)formsView.HeightRequest)));
                        var nativeView = WMapAuxiliarRenderer.LiveMapRenderer.GetNativeView(formsView);
                        Utils.FixImageSourceOfImageViews(nativeView as Android.Views.ViewGroup);

                        var otherView = new FrameLayout(this.Context);
                        nativeView.LayoutParameters = new FrameLayout.LayoutParams(Utils.DpToPx((float)formsView.WidthRequest), Utils.DpToPx((float)formsView.HeightRequest));
                        otherView.AddView(nativeView);

                        var bitmap = Utils.ConvertViewToBitmap(otherView);
                        marker.SetIcon(BitmapDescriptorFactory.FromBitmap(bitmap));
                    }

                    MapView.AddMarker(marker);
                }
                isDrawn = true;
            }
        }
Exemplo n.º 12
0
        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();
        }