public override void ViewDidLoad () { base.ViewDidLoad (); // Perform any additional setup after loading the view, typically from a nib. View.Frame = UIScreen.MainScreen.Bounds; View.BackgroundColor = UIColor.White; View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; button = UIButton.FromType(UIButtonType.RoundedRect); button.Frame = new RectangleF( (float)(View.Frame.Width / 2 - buttonWidth / 2), buttonHeight, buttonWidth, buttonHeight); button.SetTitle("GO", UIControlState.Normal); textView = new UITextView(new RectangleF( (float)(View.Frame.Width / 2 - buttonWidth / 2), (float)((View.Frame.Height / 2 - buttonHeight / 2) - buttonHeight), buttonWidth, (float)((View.Frame.Height / 2 - buttonHeight / 2) - buttonHeight))); ArcGIS.ServiceModel.Serializers.JsonDotNetSerializer.Init(); var locator = new PortalGateway("http://geocode.arcgis.com/arcgis"); var geocode = new SingleInputGeocode("/World/GeocodeServer/".AsEndpoint()) { Text = "Wellington", SourceCountry = "NZL" }; var gateway = new PortalGateway("http://sampleserver3.arcgisonline.com/ArcGIS/"); var queryPoint = new Query(@"Earthquakes/EarthquakesFromLastSevenDays/MapServer/0".AsEndpoint()) { ReturnGeometry = false, Where = "MAGNITUDE > 4.5" }; button.TouchUpInside += async (object sender, EventArgs e) => { var geocodeResult = await locator.Geocode(geocode); var resultPoint = await gateway.Query<ArcGIS.ServiceModel.Common.Point>(queryPoint); textView.Text = string.Format("Query for earthquakes in last 7 days where magnitidue is more than 4.5, {0} features found. Geocode result for Wellington, NZ x:{1}, y:{2}", resultPoint.Features.Count(), geocodeResult.Results.First().Feature.Geometry.X, geocodeResult.Results.First().Feature.Geometry.Y); }; button.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleBottomMargin; View.AddSubview(button); View.Add(textView); }
public async Task CanGeocode() { var gateway = new GeocodeGateway(new ServiceStackSerializer()); var geocode = new SingleInputGeocode("/World/GeocodeServer/".AsEndpoint()) { Text = "100 Willis Street, Wellington", SourceCountry = "NZL" }; var response = await gateway.Geocode(geocode); Assert.Null(response.Error); Assert.NotNull(response.SpatialReference); Assert.NotNull(response.Results); Assert.True(response.Results.Any()); var result = response.Results.First(); Assert.NotNull(result.Feature); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // 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 Button button = FindViewById<Button>(Resource.Id.myButton); TextView textview = FindViewById<TextView>(Resource.Id.textView1); ArcGIS.ServiceModel.Serializers.JsonDotNetSerializer.Init(); var locator = new PortalGateway("http://geocode.arcgis.com/arcgis"); var geocode = new SingleInputGeocode("/World/GeocodeServer/".AsEndpoint()) { Text = "Wellington", SourceCountry = "NZL" }; var gateway = new PortalGateway("http://sampleserver3.arcgisonline.com/ArcGIS/"); var queryPoint = new Query(@"Earthquakes/EarthquakesFromLastSevenDays/MapServer/0".AsEndpoint()) { ReturnGeometry = false, Where = "MAGNITUDE > 4.5" }; button.Click += async delegate { var geocodeResult = await locator.Geocode(geocode); var resultPoint = await gateway.Query<Point>(queryPoint); textview.Text = string.Format("Query for earthquakes in last 7 days where magnitude is more than 4.5, {0} features found. Geocode result for Wellington, NZ x:{1}, y:{2}", resultPoint.Features.Count(), geocodeResult.Results.First().Feature.Geometry.X, geocodeResult.Results.First().Feature.Geometry.Y); }; }
public Task<SingleInputGeocodeResponse> Geocode(SingleInputGeocode geocode) { return Get<SingleInputGeocodeResponse, SingleInputGeocode>(geocode); }