private void FinishButton_Click(object sender, System.EventArgs e)
        {
            Map_Location[] locations = new Map_Location[selectedMarkers.Count];
            for (int i = 0; i < selectedMarkers.Count; i++)
            {
                locations[i] = new Map_Location(selectedMarkers[i].Position.Latitude, selectedMarkers[i].Position.Longitude, 15);
            }
            string locJson = JsonConvert.SerializeObject(locations);

            progressDialog?.Dismiss();

            Dictionary <string, string> properties = new Dictionary <string, string>
            {
                { "TaskId", learningTask.Id.ToString() },
                { "NumLocs", locations.Length.ToString() }
            };

            Analytics.TrackEvent("LocationMarkerActivity_Finish", properties);

            Intent myIntent = new Intent(this, typeof(ActTaskListActivity));

            myIntent.PutExtra("TASK_ID", learningTask.Id);
            myIntent.PutExtra("LOCATIONS", locJson);
            SetResult(Result.Ok, myIntent);
            Finish();
        }
Beispiel #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.CreateChooseLocationActivity);

            string chosenData = Intent.GetStringExtra("CHOSEN") ?? "";

            previouslyChosen = !string.IsNullOrWhiteSpace(chosenData) ?
                               JsonConvert.DeserializeObject <List <Place> >(chosenData) :
                               new List <Place>();

            dialog = new ProgressDialog(this);
            dialog.SetMessage(Resources.GetString(Resource.String.Connecting));
            dialog.Show();

            string targetData = Intent.GetStringExtra("TARGET") ?? "";

            if (!string.IsNullOrWhiteSpace(targetData))
            {
                targetLoc = JsonConvert.DeserializeObject <Map_Location>(targetData);
                LoadData();
            }
            else
            {
                if (AndroidUtils.IsGooglePlayServicesInstalled(this) && googleApiClient == null)
                {
                    googleApiClient = new GoogleApiClient.Builder(this)
                                      .AddConnectionCallbacks(this)
                                      .AddOnConnectionFailedListener(this)
                                      .AddApi(LocationServices.API)
                                      .Build();
                }
            }
        }
 private void GoogleMap_MapClick(object sender, GoogleMap.MapClickEventArgs e)
 {
     if (!taskData.UserLocationOnly)
     {
         if (CanPlaceMarkers())
         {
             Map_Location selected = new Map_Location(
                 e.Point.Latitude,
                 e.Point.Longitude,
                 GMap.CameraPosition.Zoom);
             AddMarker(selected);
         }
         else
         {
             string maxMessage = string.Format(Resources.GetString(Resource.String.ChosenMaxLocations),
                                               taskData.MaxNumMarkers,
                                               (taskData.MaxNumMarkers > 1) ? "s" : "");
             Toast.MakeText(this, maxMessage, ToastLength.Long).Show();
         }
     }
     else if (CanPlaceMarkers())
     {
         Toast.MakeText(this, Resources.GetString(Resource.String.UserLocationOnly), ToastLength.Short).Show();
     }
 }
Beispiel #4
0
 public void OnConnected(Bundle connectionHint)
 {
     global::Android.Locations.Location lastKnown = LocationServices.FusedLocationApi.GetLastLocation(googleApiClient);
     if (lastKnown != null)
     {
         targetLoc = new Map_Location(lastKnown.Latitude, lastKnown.Longitude, 15);
         LoadData();
     }
 }
        private void MarkBtn_Click(object sender, System.EventArgs e)
        {
            Map_Location selected = new Map_Location(
                GMap.MyLocation.Latitude,
                GMap.MyLocation.Longitude,
                GMap.CameraPosition.Zoom
                );

            AddMarker(selected);
        }
        private void AddMarker(Map_Location newLoc)
        {
            MarkerOptions opts = new MarkerOptions();

            opts.SetPosition(new LatLng(newLoc.Lat, newLoc.Long));
            selectedMarkers.Add(GMap.AddMarker(opts));

            UpdateText();
            UpdateButton();
        }
        private void FinishButtonPressed(object sender, EventArgs e)
        {
            Map_Location[] locs = new Map_Location[markers.Count];
            for (int i = 0; i < markers.Count; i++)
            {
                locs[i] = new Map_Location(markers[i].Position.Latitude, markers[i].Position.Longitude, 15);
            }
            string locJson = JsonConvert.SerializeObject(locs);

            ReturnWithData(locJson);
        }
        public void UnwindToLocationHunt(UIStoryboardSegue segue)
        {
            var sourceController = segue.SourceViewController as Create_ChooseLocationController;

            if (sourceController != null && sourceController.chosenLocation != null)
            {
                thisLocation = sourceController.chosenLocation;

                ChosenLocationLabel.Text = string.Format("{0}, {1}", thisLocation.Lat, thisLocation.Long);
            }
        }
        private void PlaceMarkerAtCoord(CLLocationCoordinate2D coord)
        {
            var color = UIColor.FromHSBA((float)AppUtils.GetRandomNumber(), 1, 1, 1.0f);

            if (currentMarker != null)
            {
                currentMarker.Map = null;
            }

            currentMarker = Marker.FromPosition(coord);
            currentMarker.AppearAnimation = MarkerAnimation.Pop;
            currentMarker.Icon            = Marker.MarkerImage(color);
            currentMarker.Map             = mapView;
            chosenLocation = new Map_Location(coord.Latitude, coord.Longitude, 15f);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            if (!string.IsNullOrWhiteSpace(thisTask?.JsonData))
            {
                var data = JsonConvert.DeserializeObject <LocationHuntLocation>(thisTask.JsonData);

                thisLocation = new Map_Location(data.Lat, data.Long, data.Zoom);

                allowMap.On = (data.MapAvailable != null) && (bool)data.MapAvailable;

                ChosenLocationLabel.Text = string.Format("{0}, {1}", thisLocation.Lat, thisLocation.Long);
            }
        }