public override void OnResume() { base.OnResume(); GMap = FragmentManager.FindFragmentById <GMapFragment>(Resource.Id.gmap8485315486415); GPlaces = new GPlacesHandler(); // registers to map events for adding the places GMap.mapReadyCallback.MapReady += (sender, args) => { var map = ((GMapHandler)sender).Map; map.CameraChange += async(s, a) => { var jsonval = await GPlaces.GetPlacesAsJSON(map.CameraPosition.Target.Latitude, map.CameraPosition.Target.Longitude, map.Projection.VisibleRegion.LatLngBounds); var gyms = Gym.InstatiateManyFromGeoJson(jsonval); if (gyms != null) { foreach (var gym in gyms) { Log.Debug("JSON", "" + gym); map.AddMarker(new MarkerOptions().SetPosition(new LatLng(gym.lat, gym.lng)).SetTitle(gym.name)); } } }; }; }
public static Gym InstatiateFromGeoJson(JToken jGym) { var latlng = jGym["geometry"]["location"]; var gym = new Gym(); gym.lat = latlng["lat"].ToObject<double>(); gym.lng = latlng["lng"].ToObject<double>(); gym.name = jGym["name"].ToString(); return gym; }
public static Gym InstatiateFromGeoJson(JToken jGym) { var latlng = jGym["geometry"]["location"]; var gym = new Gym(); gym.lat = latlng["lat"].ToObject <double>(); gym.lng = latlng["lng"].ToObject <double>(); gym.name = jGym["name"].ToString(); return(gym); }