Comments (14)
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.
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.
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.
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.
i think somethings wrong with Google map provider because when i use OpenStreetMap it works..
from gmap.net.
try using any map provider and it will work. but not google map.
from gmap.net.
Are you using a valid api key?
from gmap.net.
valid api key? i dont understand.
from gmap.net.
I have the same problem. With Google don't work but with other providers works fine.
from gmap.net.
for some reason it stopped working also with BingHybridMap
GeoCoderStatusCode returns ExeptionInCode
from gmap.net.
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.
Never mind i had to update also code for class OpenStreetMapProviderBase, after that it started to work.
from gmap.net.
I proceed with the closing of the issues, review issues #51
from gmap.net.
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)
- .Net 7 support HOT 1
- All maps are in dark / purple mode HOT 2
- Tilt Down and Rotation in GMap.Net
- GMap.NET.Avalonia markers are not shown
- Caching maps on network location doesn't work because of SQLite
- Map bearing leads to white ghost lines
- DLL version mismatch GMap.NET.Core 2.1.7 .NET6 HOT 1
- Shape file (*.SHP) Support.
- GMapRoute can not change color in wpf
- Gmap load large markers cause no responding.
- ARM Support
- using other map providers HOT 1
- DrawMap throws InvalidCastException when switching between WinForms and WPF Control
- Problem with OpenStreetMap HOT 1
- Please use preferred tile.openstreetmap.org URL
- gmap.net winform show exception timeout HOT 5
- problem OSM
- Deprecated SHA1CryptoServiceProvider constructor causes visual studio 2022 designer problems
- G00gleMapProvider CacheType Error
- How to use Xamarin or Maui ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gmap.net.