WPF GMaps.Instance.GetLatLngFromGeocoder()

Topics: WPF
Sep 12, 2013 at 7:24 PM
Good afternoon, I'm developing with gmaps GMap.NET.WindowsPresentation v 1.5.5.5 for wpf application.

This is my code in load event
        gmap.Manager.Mode = AccessMode.ServerAndCache;
        gmap.MapProvider = GMapProviders.GoogleMap;
        gmap.SetCurrentPositionByKeywords("Córdoba, Argentina");
        gmap.MinZoom = 7;
        gmap.MaxZoom = 24;
        gmap.Zoom = 11;
        gmap.ShowCenter = false;
        gmap.DragButton = MouseButton.Left;

        GeoCoderStatusCode status = GeoCoderStatusCode.Unknow;
        PointLatLng? city = GMaps.Instance.GetLatLngFromGeocoder("Galicia 2567, Córdoba, Argentina", out    status);
        if (city != null && status == GeoCoderStatusCode.G_GEO_SUCCESS)
        {
            GMapMarker it = new GMapMarker(city.Value);
            it.ZIndex = 55;
            it.Shape = new CustomMaker(this, it, "");

            gmap.Markers.Add(it);
        }
My problem is that I can not create any lead, but never finds GeoCoderStatusCode status position and returns me an exception. Probre with version 1.6 and I get the same thing.

how could insert a marker for an address?
Sep 13, 2013 at 8:20 AM
1.6 is old too, try hot build
Sep 13, 2013 at 3:57 PM
Thanks radioman, I tried the version 1.7 hot build and runs ok, I find the directions.
But I have a problem with the markers do not appear on the map.
this is my code

Main window

gmap.Manager.Mode = AccessMode.ServerAndCache;
        gmap.MapProvider = GMapProviders.GoogleMap;
        gmap.Position = new PointLatLng(-31.416358, -64.184044);
        gmap.MinZoom = 7;
        gmap.MaxZoom = 24;
        gmap.Zoom = 11;
        gmap.ShowCenter = false;
        gmap.DragButton = MouseButton.Left;




        GeoCoderStatusCode status = GeoCoderStatusCode.Unknow;

        PointLatLng? city = GMapProviders.GoogleMap.GetPoint("Lavalleja 256, Córdoba, Argentina", out status);
        if (city != null && status == GeoCoderStatusCode.G_GEO_SUCCESS)
        {
            GMapMarker it = new GMapMarker(city.Value);
            {
                it.ZIndex = 105;
                it.Shape = new CurrentMarker(this, it, "");
            }
            gmap.Markers.Add(it);

        }

And CurrentMarker

public partial class CurrentMarker : UserControl
{
    Popup Popup;
    Label Label;
    GMapMarker Marker;
    MainWindow MainWindow;
    public CurrentMarker(MainWindow window, GMapMarker marker, string title)
    {
        InitializeComponent();

        this.MainWindow = window;
        this.Marker = marker;

        Popup = new Popup();
        Label = new Label();

        this.Loaded += new RoutedEventHandler(CustomMarkerDemo_Loaded);
        this.SizeChanged += new SizeChangedEventHandler(CustomMarkerDemo_SizeChanged);
        this.MouseEnter += new MouseEventHandler(MarkerControl_MouseEnter);
        this.MouseLeave += new MouseEventHandler(MarkerControl_MouseLeave);
        this.MouseMove += new MouseEventHandler(CustomMarkerDemo_MouseMove);
        this.MouseLeftButtonUp += new MouseButtonEventHandler(CustomMarkerDemo_MouseLeftButtonUp);
        this.MouseLeftButtonDown += new MouseButtonEventHandler(CustomMarkerDemo_MouseLeftButtonDown);

        Popup.Placement = PlacementMode.Mouse;
        {
            Label.Background = Brushes.Blue;
            Label.Foreground = Brushes.White;
            Label.BorderBrush = Brushes.WhiteSmoke;
            Label.BorderThickness = new Thickness(2);
            Label.Padding = new Thickness(5);
            Label.FontSize = 22;
            Label.Content = title;
        }
        Popup.Child = Label;

    }

    void CustomMarkerDemo_Loaded(object sender, RoutedEventArgs e)
    {
        if (icon.Source.CanFreeze)
        {
            icon.Source.Freeze();
        }
    }

    void CustomMarkerDemo_SizeChanged(object sender, SizeChangedEventArgs e)
    {
        Marker.Offset = new Point(-e.NewSize.Width / 2, -e.NewSize.Height);
    }

    void CustomMarkerDemo_MouseMove(object sender, MouseEventArgs e)
    {
        if (e.LeftButton == MouseButtonState.Pressed && IsMouseCaptured)
        {
            Point p = e.GetPosition(MainWindow.gmap);
            Marker.Position = MainWindow.gmap.FromLocalToLatLng((int)p.X, (int)p.Y);
        }
    }

    void CustomMarkerDemo_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        if (!IsMouseCaptured)
        {
            Mouse.Capture(this);
        }
    }

    void CustomMarkerDemo_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {
        if (IsMouseCaptured)
        {
            Mouse.Capture(null);
        }
    }

    void MarkerControl_MouseLeave(object sender, MouseEventArgs e)
    {
        Marker.ZIndex -= 10000;
        Popup.IsOpen = false;
    }

    void MarkerControl_MouseEnter(object sender, MouseEventArgs e)
    {
        Marker.ZIndex += 10000;
        Popup.IsOpen = true;
    }


}
my marker, dont show in the map.
Sep 13, 2013 at 4:13 PM
maybe provider returned unsuccessful response, check GeoCoderStatusCode
Sep 13, 2013 at 5:27 PM
GMap.NET.GeoCoderStatusCode.G_GEO_SUCCESS me back, so I do not know why I did not add the marker. My control map has one marker count, but not shown.