# Passing Google Map coordinates ASP/Javascript



## fizzle (Jun 22, 2005)

Hopefully someone can help me with this.

I have an Access db that contains coordinates (Longitude & Latitude) that I would like to query and use to plot markers on a Google Map.

Unfortunately, Google uses Javascript to do this task.
I am wondering if there is a way that I can integrate ASP into the task.

The Javascript code is as follows:
* var point = new GLatLng(64.834829,-147.738820);
var marker = createMarker(point,'







', marker1)
map.addOverlay(marker);*

I'd be a happy camper if I could just do this:
* var point = new GLatLng(<%=rs("latitude") %>,<%=rs("longitude") %>);
var marker = createMarker(point,'







', marker1)
map.addOverlay(marker);*
...but of course I'm just dreaming 

So my question is:
Is there a way that I can generate that bit of Javascript code for every row of data that the query returns ???
If it wasn't Javascript, I could capture every row in a table... but how can something like that be done with Javascript ?
(if at all)

I'm at a loss, so any help would be appreciated.
Thanks


----------



## GCDude (Apr 1, 2005)

why exactly cant you do-

var point = new GLatLng(<%=rs("latitude") %>,<%=rs("longitude") %>);

? Ive got a website that does exactly this. Well not exactly, im using -

var point = new GPoint(<%=rs("Long")%>,<%=rs("Lat")%>)

Seems to work fine.


----------



## fizzle (Jun 22, 2005)

GCDude said:


> why exactly cant you do-
> 
> var point = new GLatLng(<%=rs("latitude") %>,<%=rs("longitude") %>);
> 
> ...


Are you mapping just one set of coordinates, or are you mapping multiple coordinates?

My issue isn't the variable as much as it is in replicating the Javascript code that produces the map pointers.
If the result of the db query returns 10 coordinate pairs, then I need 10 instances of the Javscript code.
How do I generate a dynamic number of instances of the Javascript code and insert the resulting variables?
That's the real issue.

Are you doing something like that?
If so, would you mind sharing your technique with me?
(I am not Javascript literate, although I can usually tweak existing code if it's not too complicated)
Thanks


----------



## GCDude (Apr 1, 2005)

with multiple points, you just need to loop through your recordset adding multiple points. cut down code im using is, something like this:-


```
function onLoad() 
{	    			
   if (GBrowserIsCompatible()) 
   {								
      var map = new GMap(document.getElementById("map"));
      map.addControl(new GSmallMapControl());           

      var point;
      var marker;
<%

set rs = GetRecordSet(sql2call) 

while not rs.EOF 
%>
   point = new GPoint(<%=rs("Long")%>,<%=rs("Lat")%>);
   marker = createMarker(point, <%=enumData%>, '<%=Name%>', '', '' );
   map.addOverlay(marker);
<%
wend
rs.close()
%>
   }
}
```


----------



## fizzle (Jun 22, 2005)

Thanks GCDude !!!
That certaily seems logical enough.
And therefore it kinda embarrasses me that I hadn't put the Javascript within the loop just to see how that would respond.
I interpretted the onLoad function as a "run once" only process.... so I got a bit skittish about doing anything to mess with it.
(once again, my Javascript naivete shows through)

I'll give that a try with my code when I get a chance
(I'm severely limited with what I can do here at work, unfortunately)

Thanks again. I appreciate your efforts to help me with this.


----------



## GCDude (Apr 1, 2005)

no problem  any more help required, ask away.


----------

