Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Send variable to Google Maps to display location?

Quote Reply
Send variable to Google Maps to display location?

I do have created a couple of new colums for the entries, like: address, zip, city, ... Now it would be very nice to have a small map shown (maybe google maps) where the place is. As I do have the variable already it should be possible to "give" them to Google Maps to show the location.
Has anybody ever done something like this with GLinks or an idea how this can be done?

Quote Reply
Re: [sun112] Send variable to Google Maps to display location? In reply to

I was searching for some info on the forum about Google maps + Glinks with the hope of improving my site when I found your post, I hope this helps.

I have placed a 'basic' Google map function to display a location map on each 'detailed' page.


This is how I did this (putting together bits of code I found on the Google maps api pages)

In Glinks, links table I created fields for: latitude & longitude

Then inseted the folowing code into 'detailed.html'

This code goes into the <head> section (note you wil need to paste your Google map key into the code)

<script src="http://maps.google.com/...v=2&amp;key=THIS IS WHERE YOU PASTE YOUR GOOGLE MAP KEY CODE"
<script type="text/javascript">
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(<%Latitude%>, <%Longitude%>), 10);

Edit the <body> tag to this (someting to do with memory)

<body id="detailed" onload="load()" onunload="GUnload()">
Place this code on the page where you want the map to be displayed.

<div id="map" style="width: 500px; height: 300px"></div>

Colin Thompson