Ejemplo n.º 1
0
 /// <summary>
 /// Updates location pins on the map.
 /// </summary>
 private void UpdateLocations ()
 {
     assignmentViewModel.LoadAssignmentsAsync ().ContinueWith (_ => {
         RunOnUiThread (() => {
             int i = 0;
             foreach (var item in assignmentViewModel.Assignments) {
                 var overlay = new OverlayItem (new GeoPoint (item.Latitude.ToIntE6 (), item.Longitude.ToIntE6 ()),
                     item.CompanyName, string.Format ("{0} {1}, {2} {3}", item.Address, item.City, item.State, item.Zip));
                 Drawable drawable = null;
                 switch (item.Status) {
                     case AssignmentStatus.Hold:
                         drawable = Resources.GetDrawable (Resource.Drawable.AcceptedAssignmentIcon);
                         break;
                     default:
                         drawable = Resources.GetDrawable (Resource.Drawable.NewAssignmentIcon);
                         break;
                 }
                 var mapoverlay = new MapOverlayItem (this, drawable, overlay, mapView);
                 mapoverlay.AssignmentIndex = i;
                 mapView.Overlays.Add (mapoverlay);
                 i++;
             }
             if (assignmentViewModel.ActiveAssignment != null) {
                 var activeOverlay = new OverlayItem (new GeoPoint (assignmentViewModel.ActiveAssignment.Latitude.ToIntE6 (), assignmentViewModel.ActiveAssignment.Longitude.ToIntE6 ()),
                     assignmentViewModel.ActiveAssignment.CompanyName, string.Format ("{0} {1}, {2} {3}", assignmentViewModel.ActiveAssignment.Address,
                     assignmentViewModel.ActiveAssignment.City, assignmentViewModel.ActiveAssignment.State, assignmentViewModel.ActiveAssignment.Zip));
                 var mapoverlay = new MapOverlayItem (this, Resources.GetDrawable (Resource.Drawable.ActiveAssignmentIcon), activeOverlay, mapView);
                 mapoverlay.AssignmentIndex = -1;
                 mapView.Overlays.Add (mapoverlay);
             }
         });
     });
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Enable location tracking and place any overlays
        /// </summary>
        protected override void OnResume ()
        {
            base.OnResume ();
            myLocation.EnableMyLocation ();
            if (assignment != null) {
                var overlayItem = new OverlayItem (new GeoPoint (assignment.Latitude.ToIntE6 (), assignment.Longitude.ToIntE6 ()), assignment.CompanyName,
                    string.Format ("{0} {1}, {2} {3}", assignment.Address, assignment.City, assignment.State, assignment.Zip));
                MapOverlayItem overlay = new MapOverlayItem (this, Resources.GetDrawable (Resource.Drawable.ActiveAssignmentIcon), overlayItem, mapView, true);
                mapView.Overlays.Add (overlay);
            }

            var dialog = new AlertDialog.Builder (this)
                .SetTitle ("Google Maps")
                .SetMessage (Resources.GetString (Resource.String.GoogleMapsKeyIssue))
                .SetPositiveButton ("Ok", (sender, e) => { })
                .Show ();
        }