ee.FeatureCollection.getMap

ฟังก์ชันที่จำเป็นซึ่งแสดงผลรหัสและโทเค็นแผนที่ เหมาะสำหรับการสร้างการวางซ้อนแผนที่

แสดงผลออบเจ็กต์ที่อาจส่งไปยัง ee.data.getTileUrl หรือ ui.Map.addLayer ซึ่งรวมถึงฟิลด์ "image" เพิ่มเติมที่มีรูปภาพ Collection.draw ที่ครอบคลุม FeatureCollection ที่มีฟีเจอร์นี้ ไม่ระบุหากมีการระบุการเรียกกลับ

การใช้งานการคืนสินค้า
FeatureCollection.getMap(visParams, callback)MapId|Object
อาร์กิวเมนต์ประเภทรายละเอียด
ดังนี้ featurecollectionFeatureCollectionอินสแตนซ์ FeatureCollection
visParamsออบเจ็กต์ (ไม่บังคับ)พารามิเตอร์การแสดงภาพ ปัจจุบันอนุญาตให้มีพารามิเตอร์ได้เพียง 1 รายการเท่านั้น ซึ่งก็คือ "color" ที่มีสตริงสี RGB หากไม่ได้ระบุ 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),
)