Google Fusion Table 热图嵌入式 iFrame 不显示多边形颜色
Google Fusion Table Heat Map Embedded iFrame Not Displaying Polygon Colors
我正在使用 PHP 通过 API 使用 KML 数据创建一个热图,显示每个县的计数。表、样式和模板的创建按预期工作。从我的 Google 驱动器查看地图并使用 Fusion Tables 打开它们时,它们显示正确。意思是,地图根据我通过 API.
创建的计数和桶显示每个县的不同多边形颜色
但是,我想使用嵌入式 iFrame 在不同的网页上显示这些地图。根据文档,嵌入使用默认样式。其中,恰好是我为它创建的。
但是,当查看带有嵌入式地图的页面时,多边形会出现但不会根据计数着色(如果您单击多边形就会显示)。直到我通过 Web 界面进入地图,单击发布,颜色才开始出现在嵌入页面上。我还注意到正在创建另一种样式,但它是我已经拥有的样式的副本(如下)。
所以问题是:有人 运行 关注这个问题吗?有没有办法使用 PHP 通过 API 设置发布?任何建议都会有所帮助。
第一个样式由 API
创建
Google_Service_Fusiontables_StyleSettingList {#1164
#collection_key: "items"
#itemsType: "Google_Service_Fusiontables_StyleSetting"
#itemsDataType: "array"
+kind: "fusiontables#styleSettingList"
+nextPageToken: null
+totalItems: 1
#internal_gapi_mappings: []
#modelData: array:1 [
"items" => array:1 [
0 => array:4 [
"kind" => "fusiontables#styleSetting"
"tableId" => "1v0Q9grONGtJZAolcaBNLoQh691onorw0GVthYyiL"
"styleId" => 1
"polygonOptions" => array:1 [
"fillColorStyler" => array:3 [
"kind" => "fusiontables#buckets"
"columnName" => "Count"
"buckets" => array:5 [
0 => array:4 [
"min" => 0.0
"max" => 25.0
"color" => "#0000ff"
"opacity" => 0.5
]
1 => array:4 [
"min" => 25.0
"max" => 57.0
"color" => "#33ffff"
"opacity" => 0.5
]
2 => array:4 [
"min" => 57.0
"max" => 161.0
"color" => "#ffff00"
"opacity" => 0.5
]
3 => array:4 [
"min" => 161.0
"max" => 365.0
"color" => "#ff6600"
"opacity" => 0.5
]
4 => array:4 [
"min" => 365.0
"max" => 20000.0
"color" => "#ff0000"
"opacity" => 0.5
]
]
]
]
]
]
]
#processed: []
}
使用地图控制台和发布后添加的第二种样式
Google_Service_Fusiontables_StyleSettingList {#1164
#collection_key: "items"
#itemsType: "Google_Service_Fusiontables_StyleSetting"
#itemsDataType: "array"
+kind: "fusiontables#styleSettingList"
+nextPageToken: null
+totalItems: 2
#internal_gapi_mappings: []
#modelData: array:1 [
"items" => array:2 [
0 => array:4 [
"kind" => "fusiontables#styleSetting"
"tableId" => "1v0Q9grONGtJZAolcaBNLoQh691onorw0GVthYyiL"
"styleId" => 1
"polygonOptions" => array:1 [
"fillColorStyler" => array:3 [
"kind" => "fusiontables#buckets"
"columnName" => "Count"
"buckets" => array:5 [
0 => array:4 [
"min" => 0.0
"max" => 25.0
"color" => "#0000ff"
"opacity" => 0.5
]
1 => array:4 [
"min" => 25.0
"max" => 57.0
"color" => "#33ffff"
"opacity" => 0.5
]
2 => array:4 [
"min" => 57.0
"max" => 161.0
"color" => "#ffff00"
"opacity" => 0.5
]
3 => array:4 [
"min" => 161.0
"max" => 365.0
"color" => "#ff6600"
"opacity" => 0.5
]
4 => array:4 [
"min" => 365.0
"max" => 20000.0
"color" => "#ff0000"
"opacity" => 0.5
]
]
]
]
]
1 => array:5 [
"kind" => "fusiontables#styleSetting"
"tableId" => "1v0Q9grONGtJZAolcaBNLoQh691onorw0GVthYyiL"
"styleId" => 2
"name" => "Map of Geometry"
"polygonOptions" => array:1 [
"fillColorStyler" => array:3 [
"kind" => "fusiontables#buckets"
"columnName" => "Count"
"buckets" => array:5 [
0 => array:4 [
"min" => 0.0
"max" => 25.0
"color" => "#0000ff"
"opacity" => 0.5
]
1 => array:4 [
"min" => 25.0
"max" => 57.0
"color" => "#33ffff"
"opacity" => 0.5
]
2 => array:4 [
"min" => 57.0
"max" => 161.0
"color" => "#ffff00"
"opacity" => 0.5
]
3 => array:4 [
"min" => 161.0
"max" => 365.0
"color" => "#ff6600"
"opacity" => 0.5
]
4 => array:4 [
"min" => 365.0
"max" => 20000.0
"color" => "#ff0000"
"opacity" => 0.5
]
]
]
]
]
]
]
#processed: []
}
在与 Google 技术人员交谈后,我发现 iFrame 代码使用了一个代表样式 ID 的变量 "y"。因此,在通过 API 创建样式并接收新 ID 时,您可以在地图的 iFrame 代码中使用它来确保分配了正确的样式。
<iframe width="700" height="500" scrolling="no" frameborder="no" src="https://fusiontables.google.com/embedviz?q=select+col2+from+{{ $project->fusion_table_id }}&viz=MAP&h=false&lat=34.72404554786575&lng=-93.08009375000002&t=1&z=3&l=col2&y={{ $project->fusion_style_id }}&tmplt={{ $project->fusion_template_id }}&hml=GEOCODE"></iframe>
我正在使用 PHP 通过 API 使用 KML 数据创建一个热图,显示每个县的计数。表、样式和模板的创建按预期工作。从我的 Google 驱动器查看地图并使用 Fusion Tables 打开它们时,它们显示正确。意思是,地图根据我通过 API.
创建的计数和桶显示每个县的不同多边形颜色但是,我想使用嵌入式 iFrame 在不同的网页上显示这些地图。根据文档,嵌入使用默认样式。其中,恰好是我为它创建的。
但是,当查看带有嵌入式地图的页面时,多边形会出现但不会根据计数着色(如果您单击多边形就会显示)。直到我通过 Web 界面进入地图,单击发布,颜色才开始出现在嵌入页面上。我还注意到正在创建另一种样式,但它是我已经拥有的样式的副本(如下)。
所以问题是:有人 运行 关注这个问题吗?有没有办法使用 PHP 通过 API 设置发布?任何建议都会有所帮助。
第一个样式由 API
创建 Google_Service_Fusiontables_StyleSettingList {#1164
#collection_key: "items"
#itemsType: "Google_Service_Fusiontables_StyleSetting"
#itemsDataType: "array"
+kind: "fusiontables#styleSettingList"
+nextPageToken: null
+totalItems: 1
#internal_gapi_mappings: []
#modelData: array:1 [
"items" => array:1 [
0 => array:4 [
"kind" => "fusiontables#styleSetting"
"tableId" => "1v0Q9grONGtJZAolcaBNLoQh691onorw0GVthYyiL"
"styleId" => 1
"polygonOptions" => array:1 [
"fillColorStyler" => array:3 [
"kind" => "fusiontables#buckets"
"columnName" => "Count"
"buckets" => array:5 [
0 => array:4 [
"min" => 0.0
"max" => 25.0
"color" => "#0000ff"
"opacity" => 0.5
]
1 => array:4 [
"min" => 25.0
"max" => 57.0
"color" => "#33ffff"
"opacity" => 0.5
]
2 => array:4 [
"min" => 57.0
"max" => 161.0
"color" => "#ffff00"
"opacity" => 0.5
]
3 => array:4 [
"min" => 161.0
"max" => 365.0
"color" => "#ff6600"
"opacity" => 0.5
]
4 => array:4 [
"min" => 365.0
"max" => 20000.0
"color" => "#ff0000"
"opacity" => 0.5
]
]
]
]
]
]
]
#processed: []
}
使用地图控制台和发布后添加的第二种样式
Google_Service_Fusiontables_StyleSettingList {#1164
#collection_key: "items"
#itemsType: "Google_Service_Fusiontables_StyleSetting"
#itemsDataType: "array"
+kind: "fusiontables#styleSettingList"
+nextPageToken: null
+totalItems: 2
#internal_gapi_mappings: []
#modelData: array:1 [
"items" => array:2 [
0 => array:4 [
"kind" => "fusiontables#styleSetting"
"tableId" => "1v0Q9grONGtJZAolcaBNLoQh691onorw0GVthYyiL"
"styleId" => 1
"polygonOptions" => array:1 [
"fillColorStyler" => array:3 [
"kind" => "fusiontables#buckets"
"columnName" => "Count"
"buckets" => array:5 [
0 => array:4 [
"min" => 0.0
"max" => 25.0
"color" => "#0000ff"
"opacity" => 0.5
]
1 => array:4 [
"min" => 25.0
"max" => 57.0
"color" => "#33ffff"
"opacity" => 0.5
]
2 => array:4 [
"min" => 57.0
"max" => 161.0
"color" => "#ffff00"
"opacity" => 0.5
]
3 => array:4 [
"min" => 161.0
"max" => 365.0
"color" => "#ff6600"
"opacity" => 0.5
]
4 => array:4 [
"min" => 365.0
"max" => 20000.0
"color" => "#ff0000"
"opacity" => 0.5
]
]
]
]
]
1 => array:5 [
"kind" => "fusiontables#styleSetting"
"tableId" => "1v0Q9grONGtJZAolcaBNLoQh691onorw0GVthYyiL"
"styleId" => 2
"name" => "Map of Geometry"
"polygonOptions" => array:1 [
"fillColorStyler" => array:3 [
"kind" => "fusiontables#buckets"
"columnName" => "Count"
"buckets" => array:5 [
0 => array:4 [
"min" => 0.0
"max" => 25.0
"color" => "#0000ff"
"opacity" => 0.5
]
1 => array:4 [
"min" => 25.0
"max" => 57.0
"color" => "#33ffff"
"opacity" => 0.5
]
2 => array:4 [
"min" => 57.0
"max" => 161.0
"color" => "#ffff00"
"opacity" => 0.5
]
3 => array:4 [
"min" => 161.0
"max" => 365.0
"color" => "#ff6600"
"opacity" => 0.5
]
4 => array:4 [
"min" => 365.0
"max" => 20000.0
"color" => "#ff0000"
"opacity" => 0.5
]
]
]
]
]
]
]
#processed: []
}
在与 Google 技术人员交谈后,我发现 iFrame 代码使用了一个代表样式 ID 的变量 "y"。因此,在通过 API 创建样式并接收新 ID 时,您可以在地图的 iFrame 代码中使用它来确保分配了正确的样式。
<iframe width="700" height="500" scrolling="no" frameborder="no" src="https://fusiontables.google.com/embedviz?q=select+col2+from+{{ $project->fusion_table_id }}&viz=MAP&h=false&lat=34.72404554786575&lng=-93.08009375000002&t=1&z=3&l=col2&y={{ $project->fusion_style_id }}&tmplt={{ $project->fusion_template_id }}&hml=GEOCODE"></iframe>