Basically what I have been trying to accomplish is passing the latitude and longitude to a google maps control to display the location. These coordinates were generated from a street address, city, state, zipcode using this following method
public static GeocoderLocation Locate(string query)
WebRequest request = WebRequest
using (WebResponse response = request.GetResponse())
using (Stream stream = response.GetResponseStream())
XDocument document = XDocument.Load(new StreamReader(stream));
XElement longitudeElement = document.Descendants("lng").FirstOrDefault();
XElement latitudeElement = document.Descendants("lat").FirstOrDefault();
if (longitudeElement != null && latitudeElement != null)
return new GeocoderLocation
Longitude = Double.Parse(longitudeElement.Value, CultureInfo.InvariantCulture),
Latitude = Double.Parse(latitudeElement.Value, CultureInfo.InvariantCulture)
At this point I am getting the following error:
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Cannot create an object of type 'System.Nullable`1[[System.Double, mscorlib, Version=220.127.116.11, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' from its string representation 'lat' for the 'Latitude' property.
At this point, I have been trying to figure this out through searching different solutions for around 20 hours over the past few days.
Any help would be appreciated. This is my first time doing anything with Google Maps API.
What I have tried:
On the source side of the aspx page I used the following code,
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<map:GoogleMap ID="GoogleMap1" runat="server" MapType="Hybrid" Zoom="8" Latitude="lat" Longitude="lng" CssClass="map" Width="100%" Height="100%" FullscreenControl="true" ApiKey="ApiKey">
however, it doesn't seem to be able to get the latlng coordinates from the aspx.cs file.