Search For Name of city

Topics: General
Sep 13, 2010 at 8:01 PM

Hi

How can I search for a city name or street name of a city ?

Regards

Coordinator
Sep 13, 2010 at 8:07 PM
GeoCoderStatusCode status = MainMap.SetCurrentPositionByKeywords(textBoxGeo.Text);
if(status != GeoCoderStatusCode.G_GEO_SUCCESS)
{
     MessageBox.Show("Google Maps Geocoder can't find: '" + textBoxGeo.Text  + "', reason: " + status.ToString(), "GMap.NET", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
Nov 25, 2010 at 10:05 AM

Hi,

How can I get the name of a city from coordinates. I have a set of point (lon/lat), and I'd like to know in which city they are.

Thanks

Coordinator
Nov 25, 2010 at 5:14 PM

map.Manager.GetPlacemarkFromGeocoder(map.Position);

Sep 13, 2012 at 10:03 AM

Hello Radioman

The answer here is how to get a PlaceMarkerName based on Position

But ist it possible to search a street by name and get the positions ?

 

Coordinator
Sep 13, 2012 at 10:22 AM

you search by whatever keywords you have ;} and pray google or some other provider returns something

Sep 13, 2012 at 10:41 AM

Hello radioman

Yes of course I can search whatever I need on Google

But as long it is possible for you to provide the name, city, postcode based on position why do yo not provide a method to return a collection of name based on a few parameter as Postcode, cityname, streetname and the seachr mode : City or Street ?

Or do you mean that it must be done by using Google api directly ?

Coordinator
Sep 13, 2012 at 10:51 AM

            List<Placemark> plc = null;
            var st = GMapProviders.GoogleMap.GetPlacemarks(new PointLatLng(54.6961334816182, 25.2985095977782), out plc);
            if(st == GeoCoderStatusCode.G_GEO_SUCCESS && plc != null)
            {
               foreach(var pl in plc)
               {
                  if(!string.IsNullOrEmpty(pl.PostalCodeNumber))
                  {
                     Debug.WriteLine("Accuracy: " + pl.Accuracy + ", " + pl.Address + ", PostalCodeNumber: " + pl.PostalCodeNumber);
                  }
               }
            }

Sep 13, 2012 at 11:05 AM

Thank you Radioman

But I thing there is a little misunderstanding here !

You are giving a method to get a list of name based on a location
What I need  to do is to get a a route base on a name

Let say I'm searching Avenue Montjoie, 1180 Uccle, Belgium

This street can be of course be represented by an array of point (same as you request a routing result between two point)
What I would like to have is :

1- A list of proposition (in case of ambiguity)
2- Select one in the list
3- Get the array of point for this one

Do we have some way to do that in GMap ?

Thanks for your help

 

Coordinator
Sep 13, 2012 at 11:14 AM

it has nothing to do with gmap ;}

Sep 13, 2012 at 11:26 AM

Ok thanks

But I do not understand why ?
You have routing method in GMap !
usualy a routing is made from two point ....
but those two point are usualy selected on two street,
so you usualy have to find the street to get the point

Alternatively do you have an idea of some WebService I can use to do such search ?

Coordinator
Sep 13, 2012 at 11:32 AM

if you know the start and the end positions you can get the route ;}

Sep 13, 2012 at 12:11 PM

Sorry but probably my english is not so good and my explaination are bad

 

Yes of course I can get the route with two point I know that and Gmap povide method to do that very good and I'm already using it
But I need to find those start and end position based on a name !

I'm NOT searching how to use point I'm searching how to get point based on name !  : A webservice to search street based on name in order to get the points of that street

Maybe I've find one :

http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Address_EU/GeocodeServer

But it still sound strange for that you says that it have nothing to do with Gmap

Oct 4, 2012 at 7:40 AM

I think I know what he means, is there any way to use say, Googles Autocomplete, or auto correct that compares what you have searched on googles servers for correct terms. For example if I search a street, many streets may have the same name, is there a way to bring up the list of streets found matching that name

Sep 4, 2013 at 7:46 AM
HI, i use a HttpWebRequest directly with google for a similar propose i think, like a "google maps validation" of your user input, and try to standar names before write info in database.

private string ValidaDireccionGoogleApi(string Direccion, PuntosGeolocalizados Punto )
    {
        string DireccionAConsultar = UriDeGoogleApis + Direccion + "&sensor=false";
        // Creates an HttpWebRequest with the specified URL. 
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(DireccionAConsultar);
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();

        using (var streamReader = new StreamReader(response.GetResponseStream()))
        {
            Stream result = new MemoryStream(UnicodeEncoding.UTF8.GetBytes(streamReader.ReadToEnd()));
            XmlTextReader reader = new XmlTextReader(result);
            XmlDocument xd = new XmlDocument();
            xd.Load(reader);

            XmlNodeList lista = xd.GetElementsByTagName("address_component");
            //PuntosGeolocalizados puntoPrueba = new PuntosGeolocalizados();
            foreach (XmlElement nodo in lista)
            {
                int i = 0;
                XmlNodeList nNombreLargo =
                nodo.GetElementsByTagName("long_name");

                XmlNodeList nTipo =
                nodo.GetElementsByTagName("type");

                switch (nTipo[i].InnerText)
                {
                    case "route":
                        Punto.Calle = nNombreLargo[i].InnerText;
                        break;

                    case "street_number":
                        Punto.Altura = nNombreLargo[i].InnerText;
                        break;

                    case "locality":
                        Punto.Localidad = nNombreLargo[i].InnerText;
                        break;

                    case "administrative_area_level_2":
                        Punto.Partido = nNombreLargo[i].InnerText;
                        break;
                    case "administrative_area_level_1":
                        Punto.Provincia = nNombreLargo[i].InnerText;
                        break;
                }

                i++;

            }
            reader.Close();

            return Punto.Calle + " " + Punto.Altura + " " + Punto.Localidad;

        }
    }