dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Google Maps API with Coldfusion

  1. #1
    Join Date
    Aug 2007
    Posts
    58

    Google Maps API with Coldfusion

    Can someone tell me why my code says that load() and GUnload() is not defined. Also how do I define them.


    <cfset session.GoogleKey = "ABQIAAAA2T9ULX3VXDQQ5non2ODTaBR8iMsMmdX0MyDaNDEZUF_9W1iCfBS3EBD1ZW8FgwSH0xImL7yEywv8Bw">
    <cfif isdefined("form.address")>
    <cfset session.Address = "#form.address#">
    <cfset session.Gaddress = replace(session.Address, " ", "+", "ALL")>

    <cfoutput>
    <cfhttp url="http://maps.google.com/maps/geo?q=#session.Gaddress#&output=xml&key=#session.googleKey#" method="get" resolveurl="yes" redirect="yes" charset="utf-8"> </cfhttp>
    </cfoutput>

    <cfscript> xml = XMLParse(CFHTTP.FileContent); </cfscript>
    <CFOUTPUT>
    <cfset dLatitude = #ListGetAt(xml.kml.Response.Placemark.Point.coordinates.XmlText, 1)#>
    <cfset dLongitude = #ListGetAt(xml.kml.Response.Placemark.Point.coordinates.XmlText, 2)#>
    </CFOUTPUT>

    <cfoutput>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA2T9ULX3VXDQQ5non2ODTaBR8iMsMmdX0MyDaNDEZUF_9W1iCfBS3EBD1ZW8Fgw SH0xImL7yEywv8Bw"
    type="text/javascript"></script>
    <script type="text/javascript">
    <![CDATA[
    function load() {
    if (GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById("map"));
    map.setCenter(new GLatLng(#dLatitude#, #dLongitude#), 13);
    map.addControl(new GLargeMapControl());
    map.centerAndZoom(new GPoint(#dLongitude#, #dLatitude#), 3);
    var point = new GPoint(#dLongitude#, #dLatitude#);
    var marker = new GMarker(point);
    map.addOverlay(marker);
    }
    } //]]>
    </script>
    </cfoutput>
    <cfelse> <cfset session.address = ""> </cfif>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google Maps JavaScript API Example</title>

    </head>
    <body onLoad="load()" onUnload="GUnload()">

    <table width="900" border="0" cellspacing="0" cellpadding="5">
    <tr>
    <td>
    <table width="100%" border="0" cellspacing="0" cellpadding="5">
    <form action="" method="post" name="address">
    <tr>
    <td>Address</td>
    <td><input name="Address" type="text" id="Address" size="30" /></td>
    </tr>
    <tr>
    <td> </td>
    <td><input name="Submit" type="submit" id="Submit" value="Submit" /></td>
    </tr>
    </form>
    </table>
    </td>

    <td width="500">
    <div id="map" style="width: 500px; height: 300px"></div>
    </td>
    </tr>
    <tr>
    <td> </td>
    <td><div align="center">
    <cfif isdefined("session.address") and session.address neq "">
    <cfoutput>Laditude is #dLatitude#, Longitude is #dLongitude#</cfoutput>
    </cfif>
    </div>
    </td>
    </tr>
    </table>
    </body> </html>

  2. #2
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    They need to be defined either in the <body> tag as in Google's example or using window.onload and window.onuload in the JavaScript.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles