Leverage AI to generate and analyze map data with MapFi LLM.
MapFi LLM is an AI-powered tool based on large language models (LLMs) such as ChatGPT and Gemini. It enables users to interact with and implement 3DMapFi applications more easily by leveraging natural language understanding and code generation.
MapFi LLM acts as your intelligent assistant for all things mapping. It can understand your requests in plain English, generate code snippets, automate workflows, and analyze spatial data, making map development and analysis faster and more accessible.
You can access MapFi LLM via the web interface or integrate it into your workflow using the API.
Copy
// Example: Using MapFi LLM API to generate a map layerconst response = await fetch('/api/mapfi-llm', { method: 'POST', body: JSON.stringify({ prompt: 'Add a 3D building layer to my map' }), headers: { 'Content-Type': 'application/json' }});const { code } = await response.json();// Use the generated code in your applicationeval(code);
You can use MapFi LLM to automate repetitive or complex workflows. For example, batch-adding layers, updating styles based on data changes, or generating reports from spatial queries.
Copy
// Example: Automate adding multiple layersdocument.getElementById('run-llm').onclick = async () => { const prompts = [ 'Add a satellite imagery layer', 'Overlay a heatmap of traffic incidents', 'Highlight all schools in red' ]; for (const prompt of prompts) { const response = await fetch('/api/mapfi-llm', { method: 'POST', body: JSON.stringify({ prompt, conversationId }), headers: { 'Content-Type': 'application/json' } }); const { code } = await response.json(); eval(code); }};
To enable context-aware interactions, you can pass a conversationId with each API request. This allows MapFi LLM to remember previous prompts and responses, making multi-step workflows and iterative editing possible.
Copy
// Example: Using conversationId for a contextual sessionlet conversationId = null;async function sendPrompt(prompt) { const response = await fetch('/api/mapfi-llm', { method: 'POST', body: JSON.stringify({ prompt, conversationId }), headers: { 'Content-Type': 'application/json' } }); const result = await response.json(); conversationId = result.conversationId || conversationId; // Save for next turn eval(result.code); // Use the generated code}// Usage:await sendPrompt('Add a layer for bike lanes.');await sendPrompt('Make the bike lanes blue and increase their width.');
This approach ensures that each prompt builds on the previous context, enabling more natural and powerful map editing sessions.