Exemplo n.º 1
0
        public NewJobLocation(Job Job) : base(Job)
        {
            var rlayout = new RelativeLayout();

            map = new Xamarin.Forms.GoogleMaps.Map();
            MapInitializer.StyleMap(map);
            _ = MapInitializer.CenterOnUserAsync(map);
            StackLayout.Children.Add(rlayout);
            Title = "Pick the location!";

            rlayout.Children.Add(map,
                                 Constraint.Constant(0),
                                 Constraint.Constant(0),
                                 Constraint.RelativeToParent(rl => rl.Width),
                                 Constraint.RelativeToParent(rl => rl.Height));

            var center_on_location_button = new ImageButton()
            {
                Source          = "target.png",
                BackgroundColor = new Color(0, 0, 0, 0),
            };

            center_on_location_button.Clicked += CenterOnLocationAsync;
            rlayout.Children.Add(center_on_location_button,
                                 Constraint.RelativeToParent(rl => rl.Width - rl.Width * 0.16),
                                 Constraint.RelativeToParent(rl => rl.Width * 0.04),
                                 Constraint.RelativeToParent(rl => rl.Width * 0.12),
                                 Constraint.RelativeToParent(rl => rl.Width * 0.12));


            var pin = new Image()
            {
                Source = "map_pin_red.png",
            };

            rlayout.Children.Add(pin,
                                 Constraint.RelativeToParent(rl => rl.Width / 2 - rl.Width * 0.05),
                                 Constraint.RelativeToParent(rl => rl.Height / 2 - rl.Width * 0.10),
                                 Constraint.RelativeToParent(rl => rl.Width * 0.10),
                                 Constraint.RelativeToParent(rl => rl.Width * 0.10));
        }
Exemplo n.º 2
0
        async void UpdateMap()
        {
            MainMap.Pins.Clear();

            await MapInitializer.CenterOnUserAsync(MainMap);



            MainMap.InfoWindowClicked += InfoWindowClicked;
            //adding pins where jobs are
            ServiceManager.GetService <JobService>().GetAllJobs()
            .ForEach(job => {
                var pin = new Pin()
                {
                    Label          = job.Title,
                    Position       = job.Location,
                    BindingContext = job,
                    Icon           = BitmapDescriptorFactory.FromBundle("map_pin")
                };
                MainMap.Pins.Add(pin);
            });
        }