Results 1 to 2 of 2

Thread: Google Maps API with Coldfusion

  1. #1
    Join Date
    Aug 2007

    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")>

    <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>

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

    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA2T9ULX3VXDQQ5non2ODTaBR8iMsMmdX0MyDaNDEZUF_9W1iCfBS3EBD1ZW8Fgw SH0xImL7yEywv8Bw"
    <script type="text/javascript">
    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);
    } //]]>
    <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">
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google Maps JavaScript API Example</title>

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

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

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

  2. #2
    Join Date
    Mar 2005
    Sydney, Australia
    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