Pregunta

I developed a simple map control that uses google services instead of bing. It's windows phone 7.1. I need to get street name on a textblock by finding my location then getting its street name witch is shown on a textblock. help me guys :( .The code down belo shows all the methods to get the device's location.

public void StartLocationService(GeoPositionAccuracy accuracy)
    {
        Watcher = new GeoCoordinateWatcher(accuracy);
        Watcher.MovementThreshold = 10;
        Watcher.StatusChanged += Watcher_StatusChanged;
        Watcher.PositionChanged += Watcher_PositionChanged;
        Watcher.Start();
    }

    void Watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
    {
        Deployment.Current.Dispatcher.BeginInvoke(() => MyPositionChanged(e));
    }

    void Watcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
    {
        Deployment.Current.Dispatcher.BeginInvoke(() => MyStatusChanged(e));
    }

    void MyStatusChanged(GeoPositionStatusChangedEventArgs e)
    {
        switch (e.Status)
        {
            case GeoPositionStatus.Disabled:
                MessageBox.Show("Location is unsupported on this device", "Error", MessageBoxButton.OK);
                break;
            case GeoPositionStatus.Ready:
                break;
        }
    }

    void MyPositionChanged(GeoPositionChangedEventArgs<GeoCoordinate> e)
    {
        Pushpin p = new Pushpin();
        p.Background = new SolidColorBrush(Colors.Black);
        p.Foreground = new SolidColorBrush(Colors.White);
        p.Location = new GeoCoordinate(e.Position.Location.Latitude, e.Position.Location.Longitude);
        p.Content = "I'm Here";
        p.Tag = "pintag";
        if (MapControl1.Children.Contains(p))
        {

            var pushpin=MapControl1.Children.First(x => (x.GetType() == typeof(Pushpin) && ((Pushpin)x).Tag == "pintag"));
            MapControl1.Children.Remove(pushpin);
            MapControl1.Children.Add(p);
        }
        else
        {
            MapControl1.Children.Add(p);
        }
        MapControl1.SetView(new GeoCoordinate(e.Position.Location.Latitude, e.Position.Location.Longitude, 200), 18);
    }
¿Fue útil?

Solución

Try using geocoding google API

http://maps.googleapis.com/maps/api/geocode/json?latlng=19.333332,{1}&sensor=true

More information Here

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top