ColdFusion9支持Google MAP

   ColdFusion9開始,可以支持Google MAP。這個在Flex/Flash中早已經支持這一特徵,現在輪到CF9,其實CF9是使用Google Map API for Javascript處理的。

  例子文件:

  welcome.cfm

 

<cfajaximport params="#{googlemapkey='註冊一個google map key'}#">
<cfmap
centerlatitude="28.0670"
centerlongitude="117.1370"
zoomlevel="14"
name="map1"
type="map"
tip="不要指俺家"
zoomControl="small3D"
markerbind="cfc:c008.getMapData({cfmapname}, {cfmaplatitude}, {cfmaplongitude}, {cfmapaddress})"
showmarkerwindow = true
showallmarkers=false>
<cfmapitem name="m2" latitude="40.46" longitude="117.05" showmarkerwindow=true tip="八達嶺長城, 北京">
</cfmap>

 

  c008.cfc 處理標記顯示

 

 <cfcomponent>
<cffunction name="getMapData" access="remote">
<cfargument name="cfmapname">
<cfargument name="cfmaplatitude">
<cfargument name="cfmaplongitude">
<cfargument name="cfmapaddress">
<cfsavecontent variable="markup">
<br>
<cfoutput>
<table>
<tr>
<td bgcolor='red'><h4><font color='white'>俺的測試例子</font></td>
</tr>
</table>
Map Name: #cfmapname#<br>
Latitude, Longitude: (#DecimalFormat(cfmaplatitude)#,#DecimalFormat(cfmaplongitude)#)<br>
Address: #cfmapaddress#<br>
</cfoutput>
</cfsavecontent>
<cfreturn markup>
</cffunction>
</cfcomponent>

 

 

主要語句說明:

<cfajaximport params="#{googlemapkey='註冊一個google map key'}#">

 指定一個google map key'

 

cfmap屬性

centerlatitude:地圖中心經度

centerlongitude:地圖中心緯度

markerbind:標記數據處理組件

 

cfmapitem標籤指示指定義的地圖標籤

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章