コード例 #1
0
        public static void Init(Activity activity, Bundle bundle, PlatformConfig config = null, int MapStyleResourceId = 0)
        {
            if (IsInitialized)
            {
                return;
            }

            Context = activity;

            MapRenderer.Bundle = bundle;
            MapRenderer.Config = config ?? new PlatformConfig();
            ResourceId         = MapStyleResourceId;

#pragma warning disable 618
            if (GooglePlayServicesUtil.IsGooglePlayServicesAvailable(Context) == ConnectionResult.Success)
#pragma warning restore 618
            {
                try
                {
                    MapsInitializer.Initialize(Context);
                    IsInitialized = true;
                }
                catch (Exception e)
                {
                    Console.WriteLine("Google Play Services Not Found");
                    Console.WriteLine("Exception: {0}", e);
                }
            }

            GeocoderBackend.Register(Context);
        }
コード例 #2
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            MapsInitializer.Initialize(ApplicationContext);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            EditText username = (EditText)FindViewById(Resource.Id.username);
            EditText password = (EditText)FindViewById(Resource.Id.passwordInput);

            username.Text = pref.GetString("UserName", "");
            password.Text = pref.GetString("Password", "");
            var login = FindViewById(Resource.Id.loginButton);

            login.Click += TryLoginAsync;
            //if(pref.GetString("LoggedIn","false") == "true")
            //{
            //    StartActivity(typeof(SetUpProfileActivity));
            //}
            var register = FindViewById(Resource.Id.registerButton);

            register.Click += GoToRegister;
            var tester = FindViewById(Resource.Id.testButton);

            tester.Click += GoToTest;
        }
コード例 #3
0
        public static void Init(Activity activity, Bundle bundle)
        {
            if (IsInitialized)
            {
                return;
            }

            Context = activity;

            TKCustomMapRenderer.Bundle = bundle;

#pragma warning disable 618
            if (GooglePlayServicesUtil.IsGooglePlayServicesAvailable(Context) == ConnectionResult.Success)
#pragma warning restore 618
            {
                try
                {
                    MapsInitializer.Initialize(Context);
                    IsInitialized = true;
                }
                catch (Exception e)
                {
                    Console.WriteLine("Google Play Services Not Found");
                    Console.WriteLine("Exception: {0}", e);
                }
            }
        }
コード例 #4
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.map_fragment, container, false);

            mapView = view.FindViewById <MapView>(Resource.Id.map_view);
            mapView.OnCreate(savedInstanceState);
            mapView.OnResume();
            MapsInitializer.Initialize(Activity.ApplicationContext);

            var mapReadyCallback = new OnMapReadyCallback();

            mapReadyCallback.MapReady += (s, e) =>
            {
                map                                     = mapReadyCallback.Map;
                map.MapType                             = GoogleMap.MapTypeNormal;
                map.MyLocationEnabled                   = true;
                map.UiSettings.CompassEnabled           = true;
                map.UiSettings.IndoorLevelPickerEnabled = true;
                map.UiSettings.MapToolbarEnabled        = true;
                map.UiSettings.MyLocationButtonEnabled  = true;
                map.UiSettings.RotateGesturesEnabled    = true;
                map.UiSettings.ScrollGesturesEnabled    = true;
                map.UiSettings.TiltGesturesEnabled      = true;
                map.UiSettings.ZoomControlsEnabled      = true;
                map.UiSettings.ZoomGesturesEnabled      = true;
                map.MyLocationChange                   += (s1, e1) => MyLocation = new Location()
                {
                    lat = e1.Location.Latitude, lng = e1.Location.Longitude
                };
            };
            mapView.GetMapAsync(mapReadyCallback);

            return(view);
        }
コード例 #5
0
ファイル: MainActivity.cs プロジェクト: vikingcodes/OurPlace
        private async void GetCheckLogin()
        {
            if (!await Storage.InitializeLogin())
            {
                // Login invalid
                Analytics.TrackEvent("MainActivity_InvalidLogin");
                var suppress = AndroidUtils.ReturnToSignIn(this);
                return;
            }

            Analytics.TrackEvent("MainActivity_ValidLogin");

            UpdateTaskTypes();

            MapsInitializer.Initialize(this);
            MobileBarcodeScanner.Initialize(Application);

            global::Android.Net.Uri dataUri = base.Intent.Data;

            if (dataUri == null)
            {
                return;
            }

            string activityRef = dataUri.GetQueryParameter("code");

            if (!string.IsNullOrWhiteSpace(activityRef))
            {
                GetAndOpenActivity(activityRef);
            }
        }
コード例 #6
0
ファイル: UnifiedMap.cs プロジェクト: xamarinhub/UnifiedMaps
        public static void Init(Activity activity, Bundle bundle)
        {
            if (IsInitialized)
            {
                return;
            }

            IsInitialized             = true;
            Context                   = activity;
            UnifiedMapRenderer.Bundle = bundle;

            int resultCode = GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(Context);

            if (resultCode == ConnectionResult.Success)
            {
                try
                {
                    MapsInitializer.Initialize(Context);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Google Play Services Not Found");
                    Console.WriteLine("Exception: {0}", ex);
                }
            }
            else
            {
                Console.WriteLine("Google Play services not available");
            }
        }
コード例 #7
0
        public MapDetailView()
        {
            this.WhenActivated(d =>
            {
                this.WireUpControls();
                MapPosition.OnCreate(savedInstanceState);
                MapPosition.OnResume();
                MapsInitializer.Initialize(this);
                MapPosition.GetMapAsync(this);

                d(this.WhenAny(v => v.ViewModel.CurrentCoordinates, x => x.Value).Where(v => v != null).Subscribe(center =>
                {
                    LatLng location = new LatLng(center.Latitude, center.Longitude);
                    CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
                    builder.Target(location);
                    builder.Zoom(18);
                    if (center.Heading > -1)
                    {
                        builder.Bearing((float)center.Heading / 360.0f);
                    }
                    builder.Tilt(65);
                    CameraPosition cameraPosition = builder.Build();
                    CameraUpdate cameraUpdate     = CameraUpdateFactory.NewCameraPosition(cameraPosition);
                    map.MoveCamera(cameraUpdate);

                    MarkerOptions myPosition = new MarkerOptions();
                    myPosition.SetPosition(location);
                    myPosition.SetTitle("Aqui estamos!");
                    map.AddMarker(myPosition);
                }));
            });
        }
コード例 #8
0
        // override onCreateView
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View rootView = inflater.Inflate(Resource.Layout.fragment_maps, container, false);

            //instantieer de Google Map
            mMapView = (MapView)rootView.FindViewById(Resource.Id.mapView);
            mMapView.OnCreate(savedInstanceState);

            // Roep OnResume aan op de map om hem zo snel mogelijk te weergeven
            mMapView.OnResume();
            try
            {
                MapsInitializer.Initialize(Activity.ApplicationContext);
            }
            catch (Throwable e)
            {
                e.PrintStackTrace();
            }

            // Laad de map asynchroon
            mMapView.GetMapAsync(this);

            // Verberg de locatie button van Google
            View par            = ((View)mMapView.FindViewById(1).Parent);
            View LocationButton = par.FindViewById(2);

            LocationButton.LayoutParameters.Height = 0;
            return(rootView);
        }
コード例 #9
0
        public void OnMapReady(GoogleMap googleMap)
        {
            this.map = googleMap;
            MapsInitializer.Initialize(Activity.ApplicationContext);
            clusterManager          = new ClusterManager(Context, map);
            clusterManager.Renderer = new MoyeuClusterRenderer(Context, map, clusterManager);
            map.SetOnCameraIdleListener(clusterManager);

            // Default map initialization
            if (ContextCompat.CheckSelfPermission(Activity, Android.Manifest.Permission.AccessFineLocation) == Permission.Granted)
            {
                googleMap.MyLocationEnabled = true;
            }
            googleMap.UiSettings.MyLocationButtonEnabled = false;

            googleMap.SetMapStyle(MapStyleOptions.LoadRawResourceStyle(Context, Resource.Raw.GMapStyle));

            googleMap.MarkerClick += HandleMarkerClick;
            googleMap.MapClick    += HandleMapClick;
            var oldPosition = PreviousCameraPosition;

            if (oldPosition != null)
            {
                googleMap.MoveCamera(CameraUpdateFactory.NewCameraPosition(oldPosition));
            }
        }
コード例 #10
0
        public void OnMapReady(GoogleMap map)
        {
            googleMap = map;
            googleMap.UiSettings.CompassEnabled          = false;
            googleMap.UiSettings.MyLocationButtonEnabled = false;
            googleMap.UiSettings.MapToolbarEnabled       = false;

            if (googleMap == null)
            {
                return;
            }

            googleMap.Clear();

            try {
                MapsInitializer.Initialize(this);
            } catch (GooglePlayServicesNotAvailableException e) {
                Console.WriteLine("Google Play Services not available:" + e);
                return;
            }

            if (assignment == null)
            {
                return;
            }

            var markerOptions = GetMarkerOptionsForAssignment(assignment);

            googleMap.AddMarker(markerOptions).ShowInfoWindow();
            googleMap.CameraPosition.Target = markerOptions.Position;

            googleMap.MoveCamera(CameraUpdateFactory.NewLatLngZoom(markerOptions.Position, 15f));
        }
コード例 #11
0
ファイル: GMapFragment.cs プロジェクト: Fanuer/fitnessApp
        // initial setup for the map
        private void SetUpMap()
        {
            Map.AddMarker(new MarkerOptions().SetPosition(new LatLng(0, 0)).SetTitle("Marker"));
            Map.MyLocationEnabled = true;
            Map.UiSettings.CompassEnabled = true;
            Map.UiSettings.MapToolbarEnabled = true;

            MapsInitializer.Initialize(Activity);

            Map.MyLocationButtonClick += (sender, args) => {
                followPosition = true;

                if(lastPosition != null)
                    SetLocation(lastPosition.Latitude, lastPosition.Longitude);
            };

            Map.CameraChange += (sender, args) =>
            {
                // if positions are equal, the CameraChange event was triggered by the fragment itself and not by the user ( => follow mode still active)
                if (lastPosition != null)
                {
                    //Toast.MakeText(Activity, args.Position.Target.Latitude + " == " + lastPosition.Latitude, ToastLength.Long).Show();
                    if (Math.Round(args.Position.Target.Latitude,4) == Math.Round(lastPosition.Latitude, 4) && Math.Round(args.Position.Target.Longitude,4) == Math.Round(lastPosition.Longitude,4))
                        followPosition = true;
                    else
                        followPosition = false;
                }
            };
        }
コード例 #12
0
        public static void Init(Activity activity, Bundle bundle)
        {
            if (IsInitialized)
            {
                return;
            }
            IsInitialized = true;

#pragma warning disable 618 // Setting this to support custom code which may still depend on it
            Context = activity;
#pragma warning restore 618

            MapRenderer.Bundle = bundle;

#pragma warning disable 618
            if (GooglePlayServicesUtil.IsGooglePlayServicesAvailable(activity) == ConnectionResult.Success)
#pragma warning restore 618
            {
                try
                {
                    MapsInitializer.Initialize(activity);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Google Play Services Not Found");
                    Console.WriteLine("Exception: {0}", e);
                }
            }

            new GeocoderBackend(activity).Register();
        }
コード例 #13
0
        public void OnMapReady(GoogleMap googleMap)
        {
            MapsInitializer.Initialize(Application.ApplicationContext);
            GMap                   = googleMap;
            GMap.MapType           = GoogleMap.MapTypeHybrid;
            GMap.MyLocationEnabled = true;

            GMap.MyLocationChange += GMap_MyLocationChange;
            googleMap.MarkerClick += GoogleMap_MarkerClick;
            googleMap.MapClick    += GoogleMap_MapClick;

            // Load previously placed locations
            List <Map_Location> existing = JsonConvert.DeserializeObject <List <Map_Location> >(learningTask.CompletionData.JsonData);

            if (existing == null)
            {
                return;
            }

            foreach (Map_Location loc in existing)
            {
                AddMarker(loc);
            }
            learningTask.CompletionData.JsonData = "";
        }
コード例 #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="googleMap"></param>
        public void OnMapReady(GoogleMap googleMap)
        {
            GMap = googleMap;
            GMap.UiSettings.CompassEnabled          = true;
            GMap.UiSettings.MyLocationButtonEnabled = true;
            GMap.UiSettings.MapToolbarEnabled       = true;
            MapsInitializer.Initialize(this.Context);
            var ColombiaMarker = new MarkerOptions().SetTitle("Colombia");

            ColombiaMarker.SetPosition(new LatLng(5.156853, -74.039258));
            GMap.AddMarker(ColombiaMarker);
            var PanamaMarker = new MarkerOptions().SetTitle("Panamá");

            PanamaMarker.SetPosition(new LatLng(9.131443, -79.681025));
            GMap.AddMarker(PanamaMarker);
            var UsaMarker = new MarkerOptions().SetTitle("Estados Unidos");

            UsaMarker.SetPosition(new LatLng(40.343302, -102.066399));
            GMap.AddMarker(UsaMarker);
            GMap.UiSettings.ZoomControlsEnabled = true;
            LatLng       latlng2 = new LatLng(Convert.ToDouble(40.343302), Convert.ToDouble(-102.066399));
            CameraUpdate camera  = CameraUpdateFactory.NewLatLngZoom(latlng2, 0);

            GMap.MoveCamera(camera);
            GMap.MapType = GoogleMap.MapTypeNormal;
        }
コード例 #15
0
        public async void OnMapReady(GoogleMap googleMap)
        {
            try
            {
                //retrieve your current location and current station based on dataset
                UserCoordinates c = new UserCoordinates();
                c = await retrieveUserLocation();



                Activity.RunOnUiThread(() =>
                {
                    MapsInitializer.Initialize(Activity);
                    this.GMap = googleMap;

                    GMap.UiSettings.ZoomControlsEnabled = true;
                    LatLng latlng       = new LatLng(c.latitude, c.longitude);
                    CameraUpdate camera = CameraUpdateFactory.NewLatLngZoom(latlng, 18);
                    GMap.AnimateCamera(camera);
                    GMap.UiSettings.ZoomControlsEnabled = false;

                    options = new MarkerOptions().SetPosition(latlng).SetTitle("My location");
                    GMap.AddMarker(options);
                });
            }
            catch (Exception ex)
            {
                Toast.MakeText(Activity, ex.Message, ToastLength.Short).Show();
            }
        }
コード例 #16
0
 public HubwayMapFragment(Context context)
 {
     MapsInitializer.Initialize(context);
     this.pinFactory = new PinFactory(context);
     this.favManager = FavoriteManager.Obtain(context);
     HasOptionsMenu  = true;
 }
コード例 #17
0
        public async void OnMapReady(GoogleMap googleMap)
        {
            //EMILY TEST MWAHAHAHHAHAHAHA
            _GoogleMap = googleMap;

            _GoogleMap.UiSettings.MapToolbarEnabled = true;

            _GoogleMap.UiSettings.ZoomControlsEnabled = true;
            _GoogleMap.UiSettings.SetAllGesturesEnabled(true);
            //TESTING TESTING

            // attempt to get the lat and lon for the address
            _GeocodedLocation = await GetPositionAsync();

            if (_GeocodedLocation != null)
            {
                // because we now have coordinates, show the get directions action image view, and wire up its click handler
                _GetDirectionsActionImageView.Visibility = ViewStates.Visible;

                // initialze the map
                MapsInitializer.Initialize(this);

                // display the map region that contains the point. (the zoom level has been defined on the map layout in AcquaintanceDetail.axml)
                _GoogleMap.MoveCamera(CameraUpdateFactory.NewLatLng(_GeocodedLocation));

                // create a new pin
                var marker = new MarkerOptions();

                // set the pin's position
                marker.SetPosition(new LatLng(_GeocodedLocation.Latitude, _GeocodedLocation.Longitude));

                // add the pin to the map
                _GoogleMap.AddMarker(marker);
            }
        }
コード例 #18
0
        public void OnMapReady(GoogleMap googleMap)
        {
            MapsInitializer.Initialize(this.Activity);
            LatLng sydney = new LatLng(-33.852, 151.211);

            googleMap.AddMarker(new MarkerOptions().SetPosition(sydney));
            googleMap.MoveCamera(CameraUpdateFactory.NewLatLng(sydney));
        }
コード例 #19
0
 protected override void OnStart()
 {
     base.OnStart();
     CalculateDistance();
     new GetUnReadMessage().GetUnReadMessageCount(MessageCount, this);
     RatingDurumYenile();
     InitMapFragment(); //Map Ayarlarını yap markerleri datamodele yerleştir
     MapsInitializer.Initialize(this.ApplicationContext);
 }
コード例 #20
0
ファイル: RouteViewHolder.cs プロジェクト: del77/BSc-Thesis
        public void OnMapReady(GoogleMap googleMap)
        {
            MapsInitializer.Initialize(_context);
            GoogleMap = googleMap;
            AddCheckpointsToMap();
            var middleCheckpoint = Route.Checkpoints[Route.Checkpoints.Count / 2];

            GoogleMap.MoveCamera(CameraUpdateFactory.NewCameraPosition(CameraPosition.FromLatLngZoom(new LatLng(middleCheckpoint.Latitude, middleCheckpoint.Longitude), 15)));
        }
コード例 #21
0
        public MapPresenter()
        {
            _internalMapView = new GoogleMapView(ContextHelper.Current, new GoogleMapOptions());

            MapsInitializer.Initialize(ContextHelper.Current);

            _internalMapView.GetMapAsync(_callback = new MapReadyCallback(OnMapReady));

            _internalMapView.OnCreate(null);             // This otherwise the map does not appear
        }
コード例 #22
0
 public void OnMapReady(GoogleMap googleMap)
 {
     MapsInitializer.Initialize(Context);
     m_GoogleMap                 = googleMap;
     googleMap.MapType           = GoogleMap.MapTypeNormal;
     googleMap.MyLocationEnabled = true;
     googleMap.Clear();
     addMarksFromServer();
     googleMap.MyLocationChange += GoogleMap_MyLocationChange;
 }
コード例 #23
0
 public void OnMapReady(GoogleMap googleMap)
 {
     MapsInitializer.Initialize(Application.Context);
     GMap = googleMap;
     GMap.UiSettings.CompassEnabled          = false;
     GMap.UiSettings.MyLocationButtonEnabled = false;
     GMap.UiSettings.MapToolbarEnabled       = false;
     DrawMap();
     //           SetMapLocation();
 }
コード例 #24
0
            public void OnMapReady(GoogleMap googleMap)
            {
                MapsInitializer.Initialize(Context);
                Map = googleMap;
                var data = (NamedLocation)MapView.Tag;

                if (data != null)
                {
                    setMapLocation(Map, data);
                }
            }
コード例 #25
0
ファイル: MapFragment.cs プロジェクト: DharshanV/ELocation
        private void Inilitize()
        {
            watch            = new Stopwatch();
            busesInformation = new List <BusInformation>();
            locationManager  = (LocationManager)Context.GetSystemService(Context.LocationService);
            try { MapsInitializer.Initialize(Activity.ApplicationContext); }
            catch (Exception e) { Console.WriteLine(e.Message); }

            try { GPSEnabled = locationManager.IsProviderEnabled(LocationManager.GpsProvider); }
            catch (Exception e) { Console.WriteLine(e.Message); }
        }
コード例 #26
0
        /// <summary>
        /// Attempts to initialize maps.
        /// </summary>
        /// <param name="context"></param>
        /// <returns>
        /// Returns a result code from Android.Gms.Common.ResultCode where a 0 is
        /// a success.
        /// </returns>
        public int Initialize(Activity context, IBindingMapAdapter adapter = null, Bundle savedInstanceState = null)
        {
            MapsInitializer.Initialize(context);
            var resultCode = GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(context);

            if (resultCode == ConnectionResult.Success)
            {
                GetMapAsync(adapter, savedInstanceState);
            }
            return(resultCode);
        }
コード例 #27
0
        public void OnMapReady(GoogleMap googleMap)
        {
            this.googleMap = googleMap;

            this.googleMap.UiSettings.CompassEnabled          = false;
            this.googleMap.UiSettings.MyLocationButtonEnabled = false;
            this.googleMap.UiSettings.MapToolbarEnabled       = false;

            MapsInitializer.Initialize(this.Context);

            this.MoveToRegion(((LiteMap)this.Element).VisibleRegion, false);
        }
コード例 #28
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            MapsInitializer.Initialize(this);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            InitMapFragment();
        }
コード例 #29
0
ファイル: AdsFacebook.cs プロジェクト: gdsghost/BasedOnRate
 public static void Initialize(Context context)
 {
     try
     {
         MapsInitializer.Initialize(context);
         AudienceNetworkAds.Initialize(context);
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
コード例 #30
0
        partial void InitializePartial()
        {
            _internalMapView = new GoogleMapView(ContextHelper.Current, new GoogleMapOptions());

            MapsInitializer.Initialize(ContextHelper.Current);

            _internalMapView.GetMapAsync(_callback = new MapReadyCallback(OnMapReady));

            _internalMapView.OnCreate(null);             // This otherwise the map does not appear

            Loaded   += (s, e) => OnControlLoaded();
            Unloaded += (s, e) => OnControlUnloaded();
        }