private void SetUpMapIfNeeded(List<Feature> data) { if(null != _googleMap) return; CameraPosition.Builder builder = CameraPosition.InvokeBuilder (); if (string.Compare (_selectedCity, "warszawa") == 0) { LatLng location = new LatLng (52.2333, 21.0167); builder.Target (location); builder.Zoom (11); } if (string.Compare (_selectedCity, "czestochowa") == 0) { LatLng location = new LatLng (50.8000, 19.1167); builder.Target (location); builder.Zoom (11); } CameraPosition cameraPosition = builder.Build (); CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition (cameraPosition); var mapReadyCallback = new OnMapReadyClass(); mapReadyCallback.MapReady += (sender, e) => { _googleMap = ((OnMapReadyClass)sender).Map; _googleMap.MapType = GoogleMap.MapTypeNormal; _googleMap.AnimateCamera(cameraUpdate); GoogleMapHelpers.PlaceMarkersOnTheMap(data, _googleMap); _googleMap.SetInfoWindowAdapter(new CustomMarkerPopupAdapter(LayoutInflater)); }; try { if(_myMapFragment != null) _myMapFragment.GetMapAsync(mapReadyCallback); } catch (NullReferenceException ex) { Console.WriteLine(ex.Source); } }
private void SetUpMapIfNeeded() { if(null != _googleMap) return; CameraPosition.Builder builder = CameraPosition.InvokeBuilder (); LatLng location = new LatLng (Convert.ToDouble(_latitude), Convert.ToDouble(_longitude)); builder.Target (location); builder.Zoom (15); CameraPosition cameraPosition = builder.Build (); CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition (cameraPosition); var mapReadyCallback = new OnMapReadyClass(); mapReadyCallback.MapReady += (sender, e) => { _googleMap = ((OnMapReadyClass)sender).Map; _googleMap.MapType = GoogleMap.MapTypeNormal; _googleMap.AnimateCamera(cameraUpdate); List<Feature> data = new List<Feature>(); List<double> coord = new List<double> (); coord.Add (Convert.ToDouble(_longitude)); coord.Add (Convert.ToDouble(_latitude)); _toilet = new Feature () { type = "Feature", geometry = new Geometry() { coordinates = coord, type = "Point" }, properties = new Properties() { ranking = "0", id = "0", name = _name, icon = "znajdz_wc_logo_free_marker.png", isFree = _isFree, comment = _comment, photo = "", openHours = "", isVerified = false, } }; data.Add(_toilet); GoogleMapHelpers.PlaceMarkersOnTheMap(data, _googleMap); _googleMap.SetInfoWindowAdapter(new CustomMarkerPopupAdapter(LayoutInflater)); }; try { _myMapFragment.GetMapAsync(mapReadyCallback); } catch (NullReferenceException ex) { Console.WriteLine(ex.Source); } }