Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Session Var to Google Maps API

Status
Not open for further replies.

xcaliber2222

Programmer
Apr 10, 2008
70
0
0
US
Hello, I couldn't find a Google apps forum here but I'm using Classic ASP with the Google Maps API so I hope it is ok to post here. I have geocodes (lat, lng) I'm (trying) to pass in from a Session var. I can grab the value in a response.write but when I try to insert the session var in the Google Map API code it doesn't return a value. I am doing this (throughout my code):

Code:
Dim lat, lng
	
(grabbing from recordset I'm looping through):
Session("lat") = rs2("lat")			
Session("lng") = rs2("lng")

//Display map, with some controls and set initial location 
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
(line below returns empty):
map.setCenter(new GLatLng(<%=lat%>, <%=lng%>), 13); 
				
//Set up marker with info window
(line below returns empty):
var point = new GLatLng(<%=lat%>, <%=lng%>);
var marker = createMarker(point,'Stuff to display')
map.addOverlay(marker);

(Getting values ok here):
LAT <%Response.Write(Session("lat"))%>
LNG <%Response.Write(Session("lng"))%>

Any help would be great.

Thanks,
Alejandro
 
map.setCenter(new GLatLng(<%=lat%>, <%=lng%>), 13);

Is it as simple as spaces?

map.setCenter(new GLatLng(<%= lat %>, <%= lng %>), 13);
 
or maybe even

<% Response.write "map.setCenter(new GLatLng(" & lat & ", " & lng & "), 13);" %>

 
Hi BigRed,

Thanks for trying. Still getting no values.

Alejandro
 
First thing I would try is hard coding it just to see if that works... might be barking up the wrong tree.
 
Unless I'm just not seeing something correctly, at no point do you set the variables "lat" and "lng" to any value. So perhaps:
Code:
map.setCenter(new GLatLng(<%=[COLOR=red]Session("[/color]lat[COLOR=red]")[/color]%>, <%=[COLOR=red]Session("[/color]lng[COLOR=red]")[/color]%>), 13);
var point = new GLatLng(<%=[COLOR=red]Session("[/color]lat[COLOR=red]")[/color]%>, <%=[COLOR=red]Session("[/color]lng[COLOR=red]")[/color]%>);

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top