Friday, February 10, 2012

Calling Google map web service API using asp.net MVC?

I found the following code to call Google map web service API:-

public static class Geocoder{

private static string _GoogleMapsKey = Config.getAppSetting(“GoogleMapsKey”);

public static Geolocation? ResolveAddress(string query)

{if (string.IsNullOrEmpty(_GoogleMapsKey))

_GoogleMapsKey = ConfigurationManager.AppSettings["Google…

string url = “http://maps.google.com/maps/geo?q={0}%26amp;output=xml%26amp;key=” + _GoogleMapsKey;

url = String.Format(url, query);

XmlNode coords = null;

try{

string xmlString = GetUrl(url);

XmlDocument xd = new XmlDocument();

xd.LoadXml(xmlString);

XmlNamespaceManager xnm = new XmlNamespaceManager(xd.NameTable);

coords = xd.GetElementsByTagName(“coordinates”)[0…

}catch { }

Geolocation? gl = null;

if (coords != null){

string[] coordinateArray = coords.InnerText.Split(‘,’);

if (coordinateArray.Length %26gt;= 2)

{gl = new Geolocation(Convert.ToDecimal(coordinate… Convert.ToDecimal(coordinateArray[0].ToS…

}

}return gl;

}public static Geolocation? ResolveAddress(string address, string city, string state, string postcode, string country)

{return ResolveAddress(address + “,” + city + “,” + state + “,” + postcode + ” “ + country);}

private static string GetUrl(string url)

{string result = string.Empty;

System.Net.WebClient Client = new WebClient();

using (Stream strm = Client.OpenRead(url))

{StreamReader sr = new StreamReader(strm);

result = sr.ReadToEnd();

}return result;}}

public struct Geolocation

{public decimal Lat;

public decimal Lon;

public Geolocation(decimal lat, decimal lon){

Lat = lat;

Lon = lon;}

public override string ToString()

{return “Latitude: “ + Lat.ToString() + ” Longitude: “ + Lon.ToString();

}public string ToQueryString()

{return “+to:” + Lat + “%2B” + Lon;}}

So i created a new model class that contains that following code, and to test my work i have wrote the following in the controller

Geocoder.ResolveAddress(“University road”,”rajkot”,”gujarat”,”",”India”)



But i still do not know how to create the associated view to display the map?

Thanks in advance for any help.Calling Google map web service API using asp.net MVC?
check this link

http://code.google.com/apis/maps/

Google Static Maps API Locates to Wrong Location?

In a project I am using both the Javascript and Static Google Maps APIs. The problem I am running into is that the Static Maps API is locating to the wrong location. I am sending it Latitude and Longitude coordinates and it will ends trying to convert it to an address or something.



Try putting: 37.133212 -113.504478 into maps.google.com and you will see what I mean, I want it to show the green arrow location not the red marker location.



Any help would be appreciated.Google Static Maps API Locates to Wrong Location?
Calling directly from maps.google.com is not the same as calling to maps.google.com/staticmap. Are you declaring your lat-long pair using the markers parameter? I don't use the static maps, since I want the more flexible options of the JS API, but here's an example that I verified in Firefox:



%26lt;html%26gt;

%26lt;head%26gt;%26lt;/head%26gt;

%26lt;body%26gt;

%26lt;p%26gt;

%26lt;img src="http://maps.google.com/staticmap?ce鈥?/%26gt;

%26lt;/p%26gt;

%26lt;/body%26gt;

%26lt;/html%26gt;



The service URL for the request is:



http://maps.google.com/staticmap



Since Y!A will no doubt truncate the href due to length and lack of blanks, the parameters of the URL for the href are:



center = 37.133212, -113.504478

size = 512x512

maptype = mobile

markers = 37.133212, -113.504478, reda %7C37.133212, -113.504478

key = {your key}



Remove all the blanks and glue these parameters together in URL form.Google Static Maps API Locates to Wrong Location?
Google is not perfect. You need to notify them of any errors you find.



I once was searching for motels in Burbank, CA, and it showed me a really nice Best Western at a very specific address -- except that when I called that motel, it was in Pleasanton, CA, about 300 miles away!



I checked and rechecked, and it just kept coming up Best Western Pleasanton, in Burbank.



I notified Google about the problem, but I have no idea if they ever fixed it. (Ended up staying at a Radisson Suites)

Calling Google map web service API using asp.net MVC?

I found the following code to call Google map web service API:-

public static class Geocoder{

private static string _GoogleMapsKey = Config.getAppSetting(“GoogleMapsKey”);

public static Geolocation? ResolveAddress(string query)

{if (string.IsNullOrEmpty(_GoogleMapsKey))

_GoogleMapsKey = ConfigurationManager.AppSettings["Google…

string url = “http://maps.google.com/maps/geo?q={0}%26amp;output=xml%26amp;key=” + _GoogleMapsKey;

url = String.Format(url, query);

XmlNode coords = null;

try{

string xmlString = GetUrl(url);

XmlDocument xd = new XmlDocument();

xd.LoadXml(xmlString);

XmlNamespaceManager xnm = new XmlNamespaceManager(xd.NameTable);

coords = xd.GetElementsByTagName(“coordinates”)[0…

}catch { }

Geolocation? gl = null;

if (coords != null){

string[] coordinateArray = coords.InnerText.Split(‘,’);

if (coordinateArray.Length %26gt;= 2)

{gl = new Geolocation(Convert.ToDecimal(coordinate… Convert.ToDecimal(coordinateArray[0].ToS…

}

}return gl;

}public static Geolocation? ResolveAddress(string address, string city, string state, string postcode, string country)

{return ResolveAddress(address + “,” + city + “,” + state + “,” + postcode + ” “ + country);}

private static string GetUrl(string url)

{string result = string.Empty;

System.Net.WebClient Client = new WebClient();

using (Stream strm = Client.OpenRead(url))

{StreamReader sr = new StreamReader(strm);

result = sr.ReadToEnd();

}return result;}}

public struct Geolocation

{public decimal Lat;

public decimal Lon;

public Geolocation(decimal lat, decimal lon){

Lat = lat;

Lon = lon;}

public override string ToString()

{return “Latitude: “ + Lat.ToString() + ” Longitude: “ + Lon.ToString();

}public string ToQueryString()

{return “+to:” + Lat + “%2B” + Lon;}}



So i created a new model class that contains that above code, and to test my work i have wrote the following in the controller



Geocoder.ResolveAddress(“University road”,”rajkot”,”gujarat”,”",”India”)



But i still do not know how to create the associated view to display the map?

Thanks in advance for any help.Calling Google map web service API using asp.net MVC?
the code is it clear , try to organize it up.

How to find out the exact distance in feet, miles, etc., between points on Google Earth?

I've got a number of frequently visited pointed "thumbtacked" on Google Earth and was wondering if it's possible to find out the exact distance between points, not just the latitude and longitude. Or is there another site that could complement Google Earth that would give the distance between points in feet, yards, miles, etc.?How to find out the exact distance in feet, miles, etc., between points on Google Earth?
Hey Jesus

http://geodistance.com

I have samsung galaxy s. my battery drains out in morning completely even I had slept for just 4 hours.?

Battery was fully charged. Strange fact is, it works fine during the day. But I guess battery drains out when phone is idle. I have wi-fi sleep policy is set to 'never'. Wifi is off most of the time. Never used google latitude. Can any one tell me please the solution. :( If it cant be cured should I leave my phone on charge whole night?I have samsung galaxy s. my battery drains out in morning completely even I had slept for just 4 hours.?
just look for applications that might have been open.
  • cosmetic products
  • Car GPS inside Google Earth !?

    Hallow people, I tried everything and just didn't get it right !!

    I really want to make some project using google earth and i really want to use my car GPS. I found out that inside of the device, it has a place that shows the latitude and longitude.

    Exemple:

    Latitude: S21.20608o

    Longitude: O47.80757o

    The real question is: how can i translate this information that I had from my car GPS into informations that can be used inside Google Earth?

    Thanks for your attention.

    :)Car GPS inside Google Earth !?
    Take just the latitude and longitude numbers, no letters or o signs.

    If the Latitude is south put a - in front of it.

    If the Longitude is west put a - in front of it.

    Put them into the google earth search box latitude then longitude with a coma between them.



    That should work.

    Goggle earth can cope with both decimal degrees (21.20308) and degrees, minutes, seconds (21'12"13.34) and should know how to convert between them if it needs to.Car GPS inside Google Earth !?
    Hopefully you can answer me back-%26gt;

    What do you mean "inside the device"?



    Based on what you said, Here is what I can tell you.

    First, if you simply get the Lat/Long from the device, you can put it into Google Earth and find the location based on the Search feature.

    I am not sure, on my supercomputer I have split myself into the GE files and made the search feature awesome :P

    How do I figure out how to convert latitude and longitude?

    I am working on a project for work and am sifting through reports that have various different types of latitude/longitude formats. I have to input them in decimal form ( eg.36.6521, -82.7722)...problem is - for one I will get ( eg N 33 2 33.8177, 0824149W ) and then yet another form ( eg. 36'36'35'.21N, 89'39'00.10W) I can't tell the difference or figure out how to even input the last two types of numbers into a converter in order to get the decimal form...and I particularly don't understand what the difference between the two last types is. I've found stuff talking about minutes, seconds, etc., and just ended up more confused. Google maps didn't help, I check my locations after converting the numbers and they were on the opposite side of the state that I was working in..any help?How do I figure out how to convert latitude and longitude?
    I don't know about the second one, but the last one is in Degrees, minutes, seconds (or DMS) form. There are 60 minutes in a degree and 60 seconds in a minute. So to convert from

    100d 30' 0s You multiply 30' times 1/60 of a degree to get 30/60 or .5 of a degree.



    There are calculators out there to do this for you if you want:

    http://www.satsig.net/degrees-minutes-se鈥?/a>



    The second format might still be DMS, but hard to tell.



    Finally, just the raw lat/lon numbers aren't sufficient to specify a place. You also have to have a datum with it. It's common to see something like WGS-84, but that's not always true. Other datums like NAD-27 will have offsets.