Styling layers
Last updated
Was this helpful?
Was this helpful?
# Your API token should look like this:
# FELT_API_TOKEN="felt_pat_ABCDEFUDQPAGGNBmX40YNhkCRvvLI3f8/BCwD/g8"
FELT_API_TOKEN="<YOUR_API_TOKEN>"
MAP_ID="<YOUR_MAP_ID>"
LAYER_ID="<YOUR_LAYER_ID>"
curl \
-H "Authorization: Bearer ${FELT_API_TOKEN}" \
"https://felt.com/api/v2/maps/${MAP_ID}/layers/${LAYER_ID}"import requests
# Your API token should look like this:
# api_token = "felt_pat_ABCDEFUDQPAGGNBmX40YNhkCRvvLI3f8/BCwD/g8"
api_token = "<YOUR_API_TOKEN>"
map_id = "<YOUR_MAP_ID>"
layer_id = "<YOUR_LAYER_ID>"
r = requests.get(
f"https://felt.com/api/v2/maps/{map_id}/layers/{layer_id}",
headers={"Authorization": f"Bearer {api_token}"}
)
assert r.ok
print(r.json())import os
from felt_python import get_layer_details
# Setting your API token as an env variable can save
# you from repeating it in every function call
os.environ["FELT_API_TOKEN"] = "<YOUR_API_TOKEN>"
map_id = "<YOUR_MAP_ID>"
layer_id = "<YOUR_LAYER_ID>"
layer_details = get_layer_details(map_id, layer_id)
current_style = layer_details["style"]curl \
-X POST \
"https://felt.com/api/v2/maps/${MAP_ID}/layers/${LAYER_ID}/update_style" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${FELT_API_TOKEN}" \
--data '{"style": {"paint": {"color": "green", "opacity": 0.9, "size": 30, "strokeColor": "auto", "strokeWidth": 1}, "legend": {}, "type": "simple", "version": "2.3.1"}}'new_fsl = {
"paint": {
"color": "green",
"opacity": 0.9,
"size": 30,
"strokeColor": "auto",
"strokeWidth": 1
},
"legend": {},
"type": "simple",
"version": "2.3.1"
}
r = requests.post(
f"https://felt.com/api/v2/maps/{map_id}/layers/{layer_id}/update_style",
json={"style": new_fsl},
headers={"Authorization": f"Bearer {api_token}"}
)
assert r.ok
print(r.json())from felt_python import update_layer_style
new_fsl = {
"paint": {
"color": "green",
"opacity": 0.9,
"size": 30,
"strokeColor": "auto",
"strokeWidth": 1
},
"legend": {},
"type": "simple",
"version": "2.3.1"
}
update_layer_style(
map_id=map_id,
layer_id=layer_id,
style=new_fsl,
)