<jupyter_start><jupyter_text>Warning: Before running below cells please make sure you have API key and XYZ access token.                 Please see README.md for more info on API key and XYZ access token.<jupyter_code>import os

os.environ["LS_API_KEY"] = "MY-API-KEY"  # replace your API key here.
os.environ["XYZ_TOKEN"] = "MY-XYZ-TOKEN"  # replace your XYZ access token here.
import json

with open("india_district.json", "r") as f:
    data = json.load(f)
from xyzspaces import XYZ
import os
from geojson import FeatureCollection

# Make a python object to interact with Data Hub APIs
xyz_token = os.environ["XYZ_TOKEN"]
xyz = XYZ(credentials=xyz_token)

# Create a new space
title = "India districts space"
description = "India districts space"
space = xyz.spaces.new(title=title, description=description)

resp = space.add_features(features=data, features_size=50)
from here_map_widget import TileLayer, XYZ, FullscreenControl
from here_map_widget import Map
import os

m = Map(api_key=os.environ["LS_API_KEY"], center=[19.16153, 72.85618], zoom=4)
provider = XYZ(space_id=space.info["id"], token=xyz_token)
space_layer = TileLayer(provider=provider)
m.add_layer(space_layer)
fc = FullscreenControl()
m.add_control(fc)
m
from here_map_widget import Point, InfoBubble


def update_bubble(properties, **kwargs):
    content = """<h3><b> {}</b></h3>
                 <h4>{}</h4>
              """.format(
        properties["properties.NAME_2"], properties["properties.NAME_1"]
    )
    info = InfoBubble(
        position=Point(lat=kwargs["position"]["lat"], lng=kwargs["position"]["lng"]),
        content=content,
    )
    m.bubbles = []
    m.add_bubble(info)


provider.on_click(update_bubble)
space.delete()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12356979405034325, 'fraction_numerical': 0.013157894736842105, 'mean_word_length': 4.570063694267516, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '257893', 'license': 'MIT', 'n_tokens_mistral': 606, 'n_tokens_neox': 584, 'n_words': 147, 'path': 'examples/datahub_space.ipynb', 'repo_name': 'heremaps/here-map-widget-for-jupyter', 'size': '1748'}