Beispiel #1
0
        public override void LoadView()
        {
            base.LoadView();

            var camera = CameraPosition.FromCamera(latitude: 54.1815305,
                                                   longitude: 45.1812519,
                                                   zoom: 14.0f);

            _mapView = MapView.FromCamera(RectangleF.Empty, camera);
            _mapView.MyLocationEnabled = true;

            _mapViewWrapper = new MonoTouchGoogleMapsView(_mapView);

            this.View = _mapView;

            _vehicleMarkerManager   = new VehicleMarkerManager(_mapViewWrapper);
            _routeStopMarkerManager = new RouteStopMarkerManager(_mapViewWrapper);
            _mapLocationManager     = new MapLocationManager(_mapViewWrapper);

            var set = this.CreateBindingSet <MainView, HomeViewModel>();

            set.Bind(_vehicleMarkerManager).For(m => m.ItemsSource).To(vm => vm.Vehicles);
            set.Bind(_routeStopMarkerManager).For(m => m.ItemsSource).To(vm => vm.Stops);
            set.Bind(_mapLocationManager).For(m => m.Location).To(vm => vm.Location);
            set.Bind(_mapViewWrapper).For(x => x.Zoom)
            .To(vm => vm.MarkerSize)
            .WithConversion(new ZoomToMarkerSizeConverter());

            set.Apply();
        }
Beispiel #2
0
    void Start()
    {
        nodeNum = nodeManager.nodeList.IndexOf(gameObject);

        SetupMyNeighborhood();
        myLocManager = myNeighborhood.GetComponent <MapLocationManager>();

        if (NodeManager.nodeGangs[nodeNum] == null || NodeManager.nodeGangs[nodeNum] == "")
        {
            NodeManager.nodeGangs[nodeNum] = myLocManager.gangControllingLoc;
        }
        SetMyGangInfluence();
    }
Beispiel #3
0
        public void OnMapReady(GoogleMap map)
        {
            map.MyLocationButtonClick += (s, a) =>
            {
                if (_myLocationMarker != null)
                {
                    var point = _myLocationMarker.Position.ToGeoPoint();
                    this.MapViewModel.UpdateMapCenterCommand.Execute(new Tuple <GeoPoint, bool>(point, true));
                }
            };

            var locationProvider = Mvx.Resolve <ILocationService>();

            var lastLocation = locationProvider.GetLastLocation();

            if (!lastLocation.Equals(GeoPoint.Empty))
            {
                var myLocationMarkerOptions = new MarkerOptions();
                myLocationMarkerOptions.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.my_location));
                myLocationMarkerOptions.Flat(true);
                myLocationMarkerOptions.SetPosition(lastLocation.ToLatLng());
                _myLocationMarker = map.AddMarker(myLocationMarkerOptions);
            }

            locationProvider.LocationUpdated += this.OnLocationUpdated;
            map.SetLocationSource(locationProvider as ILocationSource);

            if (_mapViewWrapper == null)
            {
                _mapViewWrapper = new MonoDroidGoogleMapsView(map);
                _mapViewWrapper.MarkerClicked += (s, a) =>
                {
                    if (this.MapViewModel != null)
                    {
                        var routeStopVM = _routeStopMarkerManager.GetDataForMarker <RouteStopMapViewModel>(a.Marker);
                        if (routeStopVM != null)
                        {
                            this.MapViewModel.SelectRouteStopCommand.Execute(routeStopVM.Model.Id);
                        }
                        else
                        {
                            var vehicleVM = _vehicleMarkerManager.GetDataForMarker <VehicleViewModel>(a.Marker);
                            if (vehicleVM != null)
                            {
                                this.MapViewModel.SelectVehicleCommand.Execute(vehicleVM.VehicleId);
                            }
                        }
                    }
                };

                _mapViewWrapper.MapClicked += (s, a) =>
                {
                    this.RaiseMapClickedEvent();
                    this.MapViewModel.ClearSelectionCommand.Execute();
                };

                _mapViewWrapper.CameraLocationChanged += (s, a) => this.MapViewModel.UpdateMapCenterCommand.Execute(new Tuple <GeoPoint, bool>(a.Location, false));
            }

            if (_vehicleMarkerManager == null)
            {
                _vehicleMarkerManager = new VehicleMarkerManager(_mapViewWrapper, this.MapViewModel.MapVehiclesViewModel);
            }

            if (_routeStopMarkerManager == null)
            {
                _routeStopMarkerManager = new RouteStopMarkerManager(_mapViewWrapper, this.MapViewModel.MapRouteStopsViewModel);
            }

            if (_mapLocationManager == null)
            {
                _mapLocationManager = new MapLocationManager(_mapViewWrapper);
            }

            var set = this.CreateBindingSet <MapView, MapViewModel>();

            set.Bind(map)
            .For(m => m.MyLocationEnabled)
            .To(vm => vm.DetectedArea);

            set.Bind(_mapLocationManager)
            .For(m => m.Location)
            .To(vm => vm.MapCenter);

            set.Bind(_mapViewWrapper)
            .For(m => m.Zoom)
            .To(vm => vm.Zoom);

            set.Bind(_mapViewWrapper)
            .For(m => m.VisibleRegion)
            .To(vm => vm.VisibleRegion);

            set.Apply();

            (this.ViewModel as MapViewModel).Zoom = map.CameraPosition.Zoom;
        }