公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。如果您在 2025 年 9 月 26 日之前未完成验证,您的访问权限可能会被暂停。
ee.FeatureCollection.getMap
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
一种命令式函数,用于返回适合生成地图叠加层的地图 ID 和令牌。
返回一个可传递给 ee.data.getTileUrl 或 ui.Map.addLayer 的对象,其中包含一个额外的“image”字段,该字段包含一个 Collection.draw 图片,该图片封装了一个包含相应要素的 FeatureCollection。如果指定了回调,则为未定义。
| 用法 | 返回 |
|---|
FeatureCollection.getMap(visParams, callback) | MapId|Object |
| 参数 | 类型 | 详细信息 |
|---|
此:featurecollection | FeatureCollection | FeatureCollection 实例。 |
visParams | 对象,可选 | 可视化图表参数。目前仅允许一个参数,即包含 RGB 颜色字符串的“color”。如果未指定 vis_params,则使用颜色 #000000。 |
callback | 函数(可选) | 异步回调。如果未提供,则以同步方式进行调用。 |
示例
代码编辑器 (JavaScript)
// FeatureCollection of power plants in Belgium.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants')
.filter('country_lg == "Belgium"');
// Get MapId for styled FeatureCollection.
var mapId = fc.getMap({color: '800080'});
print('mapId for styled FeatureCollection', mapId);
// MapId can be used as an input to Map.addLayer to display the layer.
Map.setCenter(4.56, 50.78, 7);
Map.addLayer(mapId);
// MapId can be used as an input to ee.data.getTileUrl to fetch map tiles.
print('URL for zoom level 6 tile that includes majority of points',
ee.data.getTileUrl(mapId, 32, 21, 6));
Python 设置
如需了解 Python API 和如何使用 geemap 进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
# FeatureCollection of power plants in Belgium.
fc = ee.FeatureCollection('WRI/GPPD/power_plants').filter(
'country_lg == "Belgium"'
)
# Get MapId for styled FeatureCollection.
map_id = fc.getMapId({'color': '800080'})
display('map_id for FeatureCollection', map_id)
# MapId can be used as an input to geemap.Map.add_layer to display the layer.
m = geemap.Map()
m.set_center(4.56, 50.78, 7)
m.add_layer(map_id['image'])
display(m)
# MapId can be used as an input to ee.data.getTileUrl to fetch map tiles.
display(
'URL for zoom level 6 tile that includes majority of points',
ee.data.getTileUrl(map_id, 32, 21, 6),
)
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-26。"],[],[]]