/// <summary> /// All we do here is add a SupportMapFragment /// </summary> private void InitMap() { var mapOptions = new GoogleMapOptions() .InvokeMapType(GoogleMap.MapTypeSatellite) .InvokeZoomControlsEnabled(false) .InvokeCompassEnabled(true); var fragTx = SupportFragmentManager.BeginTransaction(); var mapFragment = SupportMapFragment.NewInstance(mapOptions); fragTx.Add(Resource.Id.map, mapFragment, "map"); fragTx.Commit(); }
private void InitMapFragment() { _mapFragment = SupportFragmentManager.FindFragmentByTag("map") as SupportMapFragment; if (_mapFragment == null) { GoogleMapOptions mapOptions = new GoogleMapOptions() .InvokeMapType(GoogleMap.MapTypeSatellite) .InvokeZoomControlsEnabled(false) .InvokeCompassEnabled(true); FragmentTransaction fragTx = SupportFragmentManager.BeginTransaction(); _mapFragment = SupportMapFragment.NewInstance(mapOptions); fragTx.Add(Resource.Id.map, _mapFragment, "map"); fragTx.Commit(); } }
public void createMapFragment() { _mapFragment = _outer.FragmentManager.FindFragmentByTag("map") as MapFragment; if (_mapFragment == null) { var mapOptions = new GoogleMapOptions() .InvokeMapType(GoogleMap.MapTypeNormal) .InvokeZoomControlsEnabled(false) .InvokeCompassEnabled(true); var fragTx = _outer.FragmentManager.BeginTransaction(); _mapFragment = MapFragment.NewInstance(mapOptions); fragTx.Add(Resource.Id.map, _mapFragment, "map"); fragTx.Commit(); } }
void Inicializa_MapFragment () { //RECUPERAMOS NUESTRO FrameLayout Y LO CONVERTIMOS EN UN MapFragment _mapFragment = FragmentManager.FindFragmentByTag("map") as MapFragment; if (_mapFragment == null) { //Configuramos las opciones con las cuales se cargara nuestro mapa, // asignamos el tipo de mapa a mostrar // habilitamos los botones de zoom // nos muestre el compas en el mapa GoogleMapOptions mapOptions = new GoogleMapOptions() .InvokeMapType(GoogleMap.MapTypeNormal) .InvokeZoomControlsEnabled(true) .InvokeCompassEnabled(true); //Realizamos la transaccion para cargar el MapFragment con las opciones que definimos var fragTx = FragmentManager.BeginTransaction(); _mapFragment = MapFragment.NewInstance(mapOptions); fragTx.Add(Resource.Id.map, _mapFragment, "map"); fragTx.Commit(); } }
public LocationView (MainActivity activity) : base (activity) { this.activity = activity; MapsInitializer.Initialize (activity); GoogleMapOptions mapOptions = new GoogleMapOptions() .InvokeMapType(GoogleMap.MapTypeNormal) .InvokeZoomControlsEnabled(false) .InvokeCompassEnabled(true); mapFragment = MapFragment.NewInstance (); mapFragment = MapFragment.NewInstance(mapOptions); var ft = activity.FragmentManager.BeginTransaction (); Id = View.GenerateViewId(); ft.Add (Id, mapFragment); ft.Commit (); DoMapStuff (); }
public void OnLocationChanged (Android.Locations.Location location) { currentLocation = location; if (map != null) { Console.WriteLine ("Latitude: " + location.Latitude.ToString ()); Console.WriteLine ("Longitude: " + location.Longitude.ToString ()); Console.WriteLine ("Provider: " + location.Provider.ToString ()); MarkerOptions markerOptions = new MarkerOptions (); markerOptions.SetPosition (new LatLng (location.Latitude, location.Longitude)); markerOptions.SetTitle ("CanchitApp"); map.AddMarker (markerOptions); GoogleMapOptions mapOptions = new GoogleMapOptions () .InvokeCamera (CameraPosition.FromLatLngZoom (new LatLng (location.Latitude, location.Longitude), 16)) .InvokeScrollGesturesEnabled (true) .InvokeMapType (GoogleMap.MapTypeNormal) .InvokeZoomControlsEnabled (true) .InvokeCompassEnabled (true); FragmentTransaction fragTx = FragmentManager.BeginTransaction (); mapFragment = MapFragment.NewInstance (mapOptions); fragTx.Add (Resource.Id.map, mapFragment, "map"); fragTx.Commit (); } }
private void InitMapFragment () { mapFragment = (MapFragment)FragmentManager.FindFragmentById (Resource.Id.map); // mapFragment.View.Visibility = ViewStates.Gone; map = mapFragment.Map; if (mode == "info") { if (mapFragment != null && mapFragment.View != null) { mapFragment.View.Visibility = ViewStates.Gone; } } if (map != null) { map.MapType = GoogleMap.MapTypeTerrain; map.UiSettings.ZoomControlsEnabled = true; map.UiSettings.CompassEnabled = true; map.UiSettings.ScrollGesturesEnabled = true; GoogleMapOptions mapOptions = new GoogleMapOptions () .InvokeCamera (CameraPosition.FromLatLngZoom (UPC, 16)) .InvokeScrollGesturesEnabled (true) .InvokeMapType (GoogleMap.MapTypeNormal) .InvokeZoomControlsEnabled (true) .InvokeCompassEnabled (true); FragmentTransaction fragTx = FragmentManager.BeginTransaction (); mapFragment = MapFragment.NewInstance (mapOptions); fragTx.Add (Resource.Id.map, mapFragment, "map"); fragTx.Commit (); /*CameraPosition.Builder builder = CameraPosition.InvokeBuilder(); builder.Target(UPC); builder.Zoom(16); CameraPosition cameraPosition = builder.Build(); CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition); map.MoveCamera(cameraUpdate);*/ MarkerOptions markerOptions = new MarkerOptions (); markerOptions.SetPosition (UPC); markerOptions.SetTitle ("CanchitApp"); map.AddMarker (markerOptions); } /*_mapFragment = FragmentManager.FindFragmentByTag ("map") as MapFragment; if (_mapFragment == null) { GoogleMapOptions mapOptions = new GoogleMapOptions () .InvokeCamera (CameraPosition.FromLatLngZoom (new LatLng (-12.103951800, -76.963278100), 16)) .InvokeScrollGesturesEnabled (true) .InvokeMapType (GoogleMap.MapTypeNormal) .InvokeZoomControlsEnabled (true) .InvokeCompassEnabled (true); // -12.103951800, -76.963278100 FragmentTransaction fragTx = FragmentManager.BeginTransaction (); _mapFragment = MapFragment.NewInstance (mapOptions); fragTx.Add (Resource.Id.map, _mapFragment, "map"); fragTx.Commit (); }*/ }
protected override void OnElementChanged(ElementChangedEventArgs<View> e) { base.OnElementChanged (e); MapView mapView1 = (MapView)this.Control; if (e.OldElement != null) { var formsMap = e.OldElement as LiteMap; ((ObservableCollection<Pin>)formsMap.Pins).CollectionChanged -= OnCollectionChanged; this.Map.MoveToRegionRequested -= this.MoveToRegionRequested; } if (e.NewElement != null) { this.Map.MoveToRegionRequested += this.MoveToRegionRequested; var options = new GoogleMapOptions (); options.InvokeLiteMode (true); MapView mapView2 = new MapView (this.Context, options); mapView2.OnCreate (LiteMapRenderer.bundle); mapView2.OnResume (); this.SetNativeControl (mapView2); mapView2.GetMapAsync (this); if (e.NewElement != null) { var formsMap = e.NewElement as LiteMap; ((ObservableCollection<Pin>)formsMap.Pins).CollectionChanged += OnCollectionChanged; } } }
private async void SetupMapIfNeeded() { if (_map == null && !_gettingMap) { // TODO À quoi sert cette variable ? On peut supprimer je pense. // a priori SetupMapIfNeeded peut-être appelé pluiseurs fois d'affilé, c'est pour prévenir ça _gettingMap = true; GoogleMapOptions mapOptions = new GoogleMapOptions() .InvokeMapType(GoogleMap.MapTypeNormal) //.InvokeZoomControlsEnabled(true) //.InvokeMapToolbarEnabled(true) .InvokeCompassEnabled(true) .InvokeCamera(await GetStartingCameraPosition()); _fragTx = FragmentManager.BeginTransaction(); _mapFragment = MapFragmentExtended.NewInstance(mapOptions); _fragTx.Add(Resource.Id.map, _mapFragment, "map"); _fragTx.Commit(); _mapFragment.GetMapAsync(this); } }