Last post Sep 09, 2010 10:16 PM by decker dong - msft
Sep 08, 2010 05:41 PM|cubangt|LINK
We are looking to add GoogleMaps to our application. With that said we are going to be using the geocoding api to pass in the lat and long values to pin point locations on the the map.
Reading thru the documentation we can pass in the values via XML, so we would like to see how we can take the lat and long values from our gridview and pass that to the API if and when somone clicks on the button to show the map..
The process will work like so, you arrive at the search page, you complete a search, in most if not all cases, you will always get multiple results presented in a gridview. If you should to view them all on the map, you click button and it needs to map out
each location on the map. So is there anyway to pull from the gridview the lat, long and description to pass into the API?
Any links to sites that i can review would be great.
Sep 08, 2010 06:34 PM|PeteNet|LINK
here's a snippet that should help to start (using Linq to Xml):
XElement xml = new XElement("GridValues",
from g in GridView1.Rows.Cast<GridViewRow>()
select new XElement("Position",
new XAttribute("Latitude", g.Cells.Text),
new XAttribute("Longitude", g.Cells.Text))
the output would be:
<Position Latitude="0" Longitude="0" />
<Position Latitude="1" Longitude="1" />
<Position Latitude="2" Longitude="2" />
<Position Latitude="3" Longitude="3" />
<Position Latitude="4" Longitude="4" />
In case you have TemplateFields you would use the FindControl method in the query.
for the example my markup was:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="true">
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
Sep 09, 2010 11:46 AM|cubangt|LINK
Question, the requirements are to open the map in a new window, so im thinking that i need to be able to access the gridview data and build the XML prior to opening the new window where the map will be displayed. So would it be better to generate XML and
store it for use within the map and then get rid of it once the map is closed or if the gridview is bound again.
Or can the data be accessed from the new window without having to store the xml?
Sep 09, 2010 12:17 PM|PeteNet|LINK
(actually it also depends on your implementation with google maps) technically, you could use a Session variable.
Sep 09, 2010 10:16 PM|Decker Dong - MSFT|LINK
If necessary, you can put your data you get into DataTable, and use WriteXML to a file.