All skills
mapbox avatar

/mapbox-search-integration

@65bab68 official
by mapboxmapbox/mapbox-agent-skills80 stars
17

Complete workflow for implementing Mapbox search in applications - from discovery questions to production-ready integration with best practices

Use this Skill: https://skilld.dev/gh/mapbox/mapbox-agent-skills/mapbox-search-integration

This session only. Nothing lands on disk.

referencespitfalls.md

≈859 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Common Pitfalls and How to Avoid Them

Pitfall 1: No Debouncing

Problem:

input.addEventListener('input', (e) => {
  performSearch(e.target.value); // API call on EVERY keystroke!
});

Impact:

  • Expensive (hundreds of unnecessary API calls)
  • Slow (race conditions, outdated results)
  • Rate limiting (429 errors)

Solution: Always debounce (see Best Practices #1)

Pitfall 2: Ignoring Session Tokens

Problem:

// No session token = each request charged separately
fetch('...suggest?q=query&access_token=xxx');

Impact:

  • Costs 10-100x more than necessary
  • Budget blown on redundant charges

Solution: Use session tokens (see Best Practices #2)

Pitfall 3: No Geographic Context

Problem:

// Searching globally for "Paris"
{
  q: 'Paris';
} // Paris, France? Paris, Texas? Paris, Kentucky?

Impact:

  • Confusing results (wrong country)
  • Slower responses
  • Poor user experience

Solution:

// Much better
{ q: 'Paris', country: 'US', proximity: user_location }

Pitfall 4: Poor Mobile UX

Problem:

<!-- Tiny touch targets -->
<div style="height: 20px; padding: 2px;">Search result</div>

Impact:

  • Frustrating to tap
  • Accidental selections
  • Bad reviews

Solution:

.search-result {
  min-height: 48px; /* Android minimum */
  padding: 12px;
  margin: 4px 0;
}

Pitfall 5: Not Handling Empty Results

Problem:

// Just shows empty container
displayResults([]); // User sees blank space - is it loading? broken?

Impact:

  • User confusion
  • Is it working?

Solution:

if (results.length === 0) {
  showMessage('No results found. Try a different search term.');
}

Pitfall 6: Blocking on Slow Networks

Problem:

// No timeout = waits forever on slow network
await fetch(searchUrl);

Impact:

  • Appears frozen
  • User frustration

Solution:

const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 5000);

fetch(searchUrl, { signal: controller.signal }).finally(() => clearTimeout(timeout));

Pitfall 7: Ignoring Result Types

Problem:

// Treating all results the same
displayResult(result.name); // But is it an address? POI? Region?

Impact:

  • Unclear what was selected
  • Wrong zoom level
  • Inappropriate markers

Solution:

function handleResult(result) {
  const type = result.feature_type;

  if (type === 'poi') {
    map.flyTo({ center: coords, zoom: 17 }); // Close zoom
    addPOIMarker(result);
  } else if (type === 'address') {
    map.flyTo({ center: coords, zoom: 16 });
    addAddressMarker(result);
  } else if (type === 'place') {
    map.flyTo({ center: coords, zoom: 12 }); // Wider view for city
  }
}

Pitfall 8: Race Conditions

Problem:

// Fast typing: "san francisco"
// API responses arrive out of order:
// "san f" results arrive AFTER "san francisco" results

Impact:

  • Wrong results displayed
  • Confusing UX

Solution:

let searchCounter = 0;

async function performSearch(query) {
  const currentSearch = ++searchCounter;
  const results = await fetchResults(query);

  // Only display if this is still the latest search
  if (currentSearch === searchCounter) {
    displayResults(results);
  }
}

Source: SKILL.md on GitHub

No alerts15d5 checks · Risk SAFE
  • Gen Agent Trust Hub15d

    The mapbox-search-integration skill is a professional implementation guide for Mapbox search services. It adheres to security best practices, uses official Mapbox SDKs and APIs, and provides clear guidance on secure credential handling.

  • Socket15d

    No alerts

  • Snyk15d

    Risk: LOW · No issues

  • Runlayer6mo

    1/1 file flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 65bab68. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 5 hours ago.

Activeupdated 6 months ago
  • API
  • React
  • mapbox
  • search
  • geocoding
  • location
  • web
  • ios
  • android
  • autocomplete

README badge

README badge for mapbox/mapbox-agent-skills/mapbox-search-integration

Guides implementation of Mapbox search through discovery questions, product selection, and production-ready integration patterns. Covers Search Box API for interactive address and POI search, Geocoding API for batch geocoding, and platform-specific SDKs for web, React, iOS, and Android.

Generated from the current SKILL.md.

Should I use the Search Box API or Geocoding API?
Use Search Box API for all interactive/user-facing search, including address search, autocomplete, and POI search. Use Geocoding API only for batch server-side geocoding or maintaining an existing Geocoding API integration.
What's the difference between Search JS React, Search JS Web, and Search JS Core?
Search JS React is a React library with built-in UI (easiest for React apps). Search JS Web is a Web Components library with UI for vanilla JS. Search JS Core is a JavaScript wrapper for the API where you build your own UI.
Do I need to implement debouncing and session tokens?
Yes. Debouncing (300ms recommended) reduces API calls during typing, and session tokens are required for proper billing on every suggest/retrieve request in interactive flows.
Which platform SDK should I use?
Use Mapbox Search JS for web apps (with React/Web/Core variants), Search SDK for iOS for native iOS apps, and Search SDK for Android for native Android apps. Avoid direct API calls in favor of SDKs to handle debouncing and session management automatically.
What geographic filtering options are available?
You can use the country parameter for single/multiple countries, bbox parameter for bounding box constraints, and proximity parameter for location-based filtering.

Generated from the current SKILL.md. These answers refresh after source changes.