The Easiest Way to Save and Share Code Snippets on the web

Google Maps API via Coldfusion

cfm | by: Dreamstarter697

posted: Jul, 20th 2011 | jump to bottom

<cfimport taglib="tags" prefix="gm">
<cfquery name="storeAddress" datasource="addresser">
INSERT	address 
		(address1, address2, city, state, zip, country)
VALUES	('#form.address1#', '#form.address2#', '#form.city#', '#form.state#', '#form.zipcode#', '#form.country#')
</cfquery>
 
<cfquery name="getAddress" datasource="addresser">
SELECT *
From	address
</cfquery>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
   <style type="text/css">
   body, td {
      font-family: Arial;
      font-size: 12px;
      }
   th {
      font-family: Arial;
      font-size: 14px;
      font-weight: bold;
      background-color:#dcdcdc;
      }
   .small{font-size:10px;}
   h1 {font-size:22px;color:#ffffff;background-color:#000000; padding: 3 3 3 10;}
   h2 {font-size:18px;}
   a {color:#0000ff;text-decoration:none;}
   a:hover {text-decoration:underline;color:#ff0000}
   </style>
</head>
 
<body>
 
   <h1>Multiple Points on a Google Map</h1>
   <div style="width:800px;height:600px">
      <gm:googlemap width="790" height="500" key="#gmapkey#" maptype="map" fitPointsToMap="true">
     <cfloop query="getAddress">
      <cfset variables.obj.geo = createObject("component","geo")>
      <cfset variables.sArgs.address1 = "#address1#">
      <cfset variables.sArgs.city   = "#city#">
      <cfset variables.sArgs.state = "#state#">
      <cfset variables.sArgs.postalCode = "#zipcode#">
      <cfset variables.sArgs.countryCode = "#country#">
      <cfset variables.sArgs.googleMapKey = #gmapkey#>
      <cfdump var="#variables.sArgs#" label="Arguments">
      <br/>
      <br/>
      <cfset variables.sAddress = variables.obj.geo.Geocode(argumentCollection=variables.sArgs)>
      <cfdump var="#variables.sAddress#" label="Results">
      <br />
			<cfset fulladdress = "#address1#, #address2#, #city#, #state# #zipcode#, #country#">
            <gm:googlemappoint title="Home" address="#fulladdress#" lon="#sAddress.lon#" lat="#sAddress.lat#" zoom="40">
        </cfloop>
      </gm:googlemap>
   </div>
<gm:googlemapshow>
200 views