Im building a winform project using Google maps api. im sending an address and i get the address coordinates as a result. However, im not getting the most accurate results... here is my code:
using System.Net;
using System.Runtime.Serialization.Json;
namespace WinForm_Project
{
class GoogleMaps
{
public static GeoResponse GetGeoCodedResults(string address) and uses google maps to retrieve the address's coordinates.
{
string url = string.Format("http://maps.google.com/maps/api/geocode/json?address={0}®ion=dk&sensor=false",HttpUtility.UrlEncode(address));
var request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate");
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(GeoResponse));
var res = (GeoResponse)serializer.ReadObject(request.GetResponse().GetResponseStream());
return res;
}
}
}
this part works just fine. (just to be clear - my winform app does not contain a google map) i noticed when i type an address on google maps's website i get certain coordinates - but the coordinates (Latitude, longitude) become more accurate when i zoom-in...
is there a way to change the request\\code to get from google a more accurate results? such as Max zoom-in will display on google maps.
Thanks
Using Google's JSON option, your result will contain something like this.
...
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 40.91525559999999,
"lng" : -73.70027209999999
},
"southwest" : {
"lat" : 40.495908,
"lng" : -74.2590879
}
},
"location" : {
"lat" : 40.7143528,
"lng" : -74.00597309999999
...
The exact 'point' will be under results-->geometry-->location. However, if your query is an area, say New York City, then you will get a bounding box for that area (results-->geometry-->bounds). If that's the case, the exact location given would probably be the center of that area or a commonly accepted point.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.