Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Hangs

$
0
0

Hi,

    I  have this code to get  location and address.   And I added the packages Xamarin.Forms.Maps for the 3 projects (Shared, Android and iOS).     

using System;

using Xamarin.Forms;
using Xamarin.Forms.Maps;
using System.Threading.Tasks;

namespace MyApp
{
public class GeoAddress
{
Geocoder _geoCoder;
string tmpValues;
public GeoAddress ()
{
var t = GetLatAndLong();
}

    public async Task GetLatAndLong()
    {

        _geoCoder = new Geocoder ();

        var myAddress = "394 Pacific Ave, San Francisco, California";
        var approximateLocation = await _geoCoder.GetPositionsForAddressAsync (myAddress);  

        foreach (var p in approximateLocation) {
            tmpValues += p.Latitude + ", " + p.Longitude + "\n";
        } 

        var fortMasonPosition = new Position (37.8044866, -122.4324132);
        var possibleAddresses = await _geoCoder.GetAddressesForPositionAsync (fortMasonPosition);
        foreach (var a in possibleAddresses){
            tmpValues += a + "\n";
        }
    }
}

}

Problem:
These code never return a value. It just hangs. Why? (I tried 2 different Android devices and my iPhone 5s. But the same problem. )

var approximateLocation = await _geoCoder.GetPositionsForAddressAsync (myAddress);
var possibleAddresses = await _geoCoder.GetAddressesForPositionAsync (fortMasonPosition);


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>