gistda-sphere-react

useTags

Display POI markers by category on the map

Display POI markers by category on the map. Tags are predefined groups of POIs from the Sphere database.

Food & Dining
Services
Tourism
0 active
import { useTags } from 'gistda-sphere-react';

function TagsComponent() {
  const { add, remove, clear, list, isReady } = useTags();

  const showRestaurants = () => {
    add('อาหารไทย');
    add('อาหารญี่ปุ่น');
  };

  return (
    <div>
      <button onClick={showRestaurants}>Show Restaurants</button>
      <button onClick={clear}>Clear All</button>
      <p>Active: {list().join(', ')}</p>
    </div>
  );
}

Functions

FunctionParametersReturnsDescription
isReady-booleanTag service initialized
set(tag, options?)voidClear all and set a new tag
add(tag, options?)voidAdd a tag
remove(tag)voidRemove a tag
clear()voidRemove all tags
list()string[]Active tag names
size()numberNumber of active tags
enablePopup(state)voidToggle popups
setLanguage(lang: "th" | "en")voidSet display language: "th" or "en"

Tip

Use "%" as the tag name to load all available POIs.

Available tag categories

CategoryTag IDEnglish Label
FoodอาหารไทยThai Food
Foodอาหารญี่ปุ่นJapanese
FoodอาหารจีนChinese
FoodอาหารเกาหลีKorean
FoodอาหารอินเดียIndian
FoodอาหารอิตาลีItalian
ServicesธนาคารBank
ServicesATMATM
ServicesโรงพยาบาลHospital
Servicesปั๊มน้ำมันGas Station
TourismโรงแรมHotel
TourismวัดTemple
Tourismพิพิธภัณฑ์Museum
Tourismห้างสรรพสินค้าShopping Mall

Using TAG_CATEGORIES

import { TAG_CATEGORIES } from 'gistda-sphere-react';

function TagSelector() {
  const { add } = useTags();

  return (
    <div>
      {TAG_CATEGORIES.map((category) => (
        <div key={category.name}>
          <h3>{category.name}</h3>
          {category.tags.map((tag) => (
            <button key={tag.id} onClick={() => add(tag.id)}>
              {tag.label}
            </button>
          ))}
        </div>
      ))}
    </div>
  );
}

On this page