Code Monkey home page Code Monkey logo

Comments (14)

cronky78 avatar cronky78 commented on June 24, 2024

G'day ppaulerrol,

I had the same problem & have come up with a workaround, see below.

Instead of using the inbuilt GMapControl.SetPositionByKeywords() function, I wrote my own local version of based on almost the same code. Seems to work now, but is a bit slower than it was before. I'm not 100% sure why this works but it seems to !

Hope this helps ? Cheers :) Simon

public bool SetPositionByKeywords(string searchWord)
        {
            GeocodingProvider gp = GMap.NET.MapProviders.GMapProviders.OpenStreetMap as GeocodingProvider;

            if (gp != null)
            {
                GeoCoderStatusCode status = GeoCoderStatusCode.Unknow;

                Cursor.Current = Cursors.WaitCursor;
                var pt = gp.GetPoint(searchWord, out status);
                Cursor.Current = Cursors.Default;

                if (status == GeoCoderStatusCode.G_GEO_SUCCESS && pt.HasValue)
                {
                    this.gMapControl1.Position = pt.Value;

                    return true;
                }
                else
                {
                    // error
                    MessageBox.Show("Could not find \"" + searchWord + "\"");
                    return false;
                }
            }
            else
            {
                MessageBox.Show("Could not find \"" + searchWord + "\"");
                return false;
            }
        }

from gmap.net.

ppaulerrol avatar ppaulerrol commented on June 24, 2024

thank you bro! i used your code but it is just like the same.. i can't locate the places id like to see in gmap.net. is it a bug or an update error?.

from gmap.net.

cronky78 avatar cronky78 commented on June 24, 2024

Hmm that's strange, it works just fine for me. The trick is in forcing the GeocodingProvider
to be of type 'GMap.NET.MapProviders.GMapProviders.OpenStreetMap' instead of what you were using before (probably Google). Seems to me that Google have changed something their end recently. But by using OpenStreetMap specifically I am able to search again and it's working. Wonder if anyone else can try it too ?

from gmap.net.

judero01col avatar judero01col commented on June 24, 2024

Greetings, perform the test with the library method using Google Map Map Provider and OpenStreetMap and work without problems. It could indicate how you were using it and what provider, if you are using the sources or the nuget and if you are using an apikey. I leave an example as I am using it.

GeoCoderStatusCode status = MainMap.SetPositionByKeywords(textBoxGeo.Text);

            if (status != GeoCoderStatusCode.G_GEO_SUCCESS)
            {
                MessageBox.Show("Geocoder can't find: '" + textBoxGeo.Text + "', reason: " + status.ToString(), "GMap.NET", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

from gmap.net.

ppaulerrol avatar ppaulerrol commented on June 24, 2024

i think somethings wrong with Google map provider because when i use OpenStreetMap it works..

from gmap.net.

ppaulerrol avatar ppaulerrol commented on June 24, 2024

try using any map provider and it will work. but not google map.

from gmap.net.

judero01col avatar judero01col commented on June 24, 2024

Are you using a valid api key?

from gmap.net.

ppaulerrol avatar ppaulerrol commented on June 24, 2024

valid api key? i dont understand.

from gmap.net.

Maesetsure avatar Maesetsure commented on June 24, 2024

I have the same problem. With Google don't work but with other providers works fine.

from gmap.net.

prkrmx avatar prkrmx commented on June 24, 2024

for some reason it stopped working also with BingHybridMap
GeoCoderStatusCode returns ExeptionInCode

from gmap.net.

MartinStokelj avatar MartinStokelj commented on June 24, 2024

Was there any update on this problem? I made work around with OpenStreetMap but now even this do not work anymore...

    public GeoCoderStatusCode SetPositionByKeywords(string keys)
    {
        GeoCoderStatusCode status = GeoCoderStatusCode.Unknow;
        GeocodingProvider gp = MapProvider as GeocodingProvider;
        if (gp == null)
        {
            gp = GMapProviders.OpenStreetMap as GeocodingProvider;
        }

        if (gp != null)
        {
            var pt = gp.GetPoint(keys, out status);
            if (status == GeoCoderStatusCode.G_GEO_SUCCESS && pt.HasValue)
            {
                Position = pt.Value;
            }
            else
            {
                gp = GMapProviders.OpenStreetMap as GeocodingProvider;
                pt = gp.GetPoint(keys, out status);
                if (status == GeoCoderStatusCode.G_GEO_SUCCESS && pt.HasValue)
                {
                    Position = pt.Value;
                }
            }
        }

        if (status != GeoCoderStatusCode.G_GEO_SUCCESS && !gp.GetType().ToString().Contains("Google"))
        {
            var pt = GMapProviders.GoogleMap.GetPoint(keys, out status);
            if (status == GeoCoderStatusCode.G_GEO_SUCCESS && pt.HasValue)
            {
                Position = pt.Value;
            }
        }

        return status;
    }

from gmap.net.

MartinStokelj avatar MartinStokelj commented on June 24, 2024

Never mind i had to update also code for class OpenStreetMapProviderBase, after that it started to work.

from gmap.net.

judero01col avatar judero01col commented on June 24, 2024

I proceed with the closing of the issues, review issues #51

from gmap.net.

Saipula avatar Saipula commented on June 24, 2024

G'day ppaulerrol,

I had the same problem & have come up with a workaround, see below.

Instead of using the inbuilt GMapControl.SetPositionByKeywords() function, I wrote my own local version of based on almost the same code. Seems to work now, but is a bit slower than it was before. I'm not 100% sure why this works but it seems to !

Hope this helps ? Cheers :) Simon

public bool SetPositionByKeywords(string searchWord)
        {
            GeocodingProvider gp = GMap.NET.MapProviders.GMapProviders.OpenStreetMap as GeocodingProvider;

            if (gp != null)
            {
                GeoCoderStatusCode status = GeoCoderStatusCode.Unknow;

                Cursor.Current = Cursors.WaitCursor;
                var pt = gp.GetPoint(searchWord, out status);
                Cursor.Current = Cursors.Default;

                if (status == GeoCoderStatusCode.G_GEO_SUCCESS && pt.HasValue)
                {
                    this.gMapControl1.Position = pt.Value;

                    return true;
                }
                else
                {
                    // error
                    MessageBox.Show("Could not find \"" + searchWord + "\"");
                    return false;
                }
            }
            else
            {
                MessageBox.Show("Could not find \"" + searchWord + "\"");
                return false;
            }
        }

Thanks a lot! I wrote the same function myself, but for some reason it did not work for me. But yours is working <3

from gmap.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.