A single npm package that makes it extremely easy for developers to display geospatial datasets (CLU, SSURGO, CDL, PLSS, etc.) in interactive maps.
- 🗺️ Drop-in map component - Get started in minutes with
<LandMap /> - 🌾 Built-in land datasets - CLU, SSURGO soils, CDL crops, PLSS boundaries
- 🎛️ Interactive legend - Toggle layer visibility with built-in controls
- 📐 AOI Query Tool - Draw areas of interest and query features within them
- 📊 Smart Results - Get detailed summaries and statistics for queried areas
- 📦 Multiple adapters - Works with both MapLibre GL JS and Mapbox GL JS
- 🎯 TypeScript support - Full type safety and IntelliSense
- 🚀 Bundle efficient - Peer dependencies externalized, tree-shakeable
npm install landmapmagic maplibre-gl react react-domimport { LandMap } from "landmapmagic";
export default function App() {
return (
<LandMap
apiKey="your-api-key-here"
/>
);
}Here's a comprehensive example showing all available props and how to use them:
import { LandMap } from "landmapmagic";
export default function App() {
return (
<LandMap
// API Configuration
apiKey="your-api-key-here" // Your API key
// Map Configuration
initialCenter={[-93.5, 42.0]} // [longitude, latitude] - defaults to US center
initialZoom={12} // Zoom level (0-22) - defaults to 4
style="mapbox://styles/mapbox/satellite-v9" // Map style URL or object
// Layer Configuration
availableLayers={['clu', 'ssurgo', 'cdl', 'plss']} // Which layers users can toggle
initialVisibleLayers={['clu', 'ssurgo']} // Layers visible on load
// UI Configuration
showLegend={true} // Show layer toggle legend - defaults to true
showClickInfo={true} // Show feature info on click - defaults to true
// Styling
className="my-custom-map" // CSS class name
height="600px" // Map height - defaults to '500px'
width="100%" // Map width - defaults to '100%'
/>
);
}'clu'- Common Land Units (field boundaries)'ssurgo'- SSURGO soil data'cdl'- Cropland Data Layer'plss'- Public Land Survey System'states'- US state boundaries
// Minimal setup - just CLU layer
<LandMap apiKey="your-key" />
// Multiple layers visible on load
<LandMap
apiKey="your-key"
availableLayers={['clu', 'ssurgo', 'plss']}
initialVisibleLayers={['clu', 'ssurgo']}
/>
// Custom size and no legend
<LandMap
apiKey="your-key"
height="800px"
width="100%"
showLegend={false}
/>
// Focused on specific area
<LandMap
apiKey="your-key"
initialCenter={[-93.5, 42.0]} // Iowa
initialZoom={14}
availableLayers={['clu', 'ssurgo']}
initialVisibleLayers={['clu']}
/>For Flask, Django, PHP, or plain HTML apps, use the CDN version:
<!-- Add the script -->
<script src="https://landmapmagic.com/js/landmap-latest.min.js"></script>
<!-- Create a map container -->
<div id="map" style="width: 100%; height: 500px;"></div>
<!-- Initialize the map -->
<script>
LandMapMagic.createMap('map', {
apiKey: 'your-api-key',
initialVisibleLayers: ['clu']
});
</script><!-- Use a specific version that won't auto-update -->
<script src="https://landmapmagic.com/js/landmap-1.2.3.min.js"></script>Check Releases for the latest version number.
Built with ❤️ for the agricultural and geospatial communities.
For local development and examples, create a .env.local file in the examples/ directory:
# Copy env.example to .env.local in the examples/ directory
cd examples
cp env.example .env.localThen edit .env.local and add your API keys:
# Google Maps API Key (required for Google Maps examples)
# Get your key at: https://console.cloud.google.com/google/maps-apis
VITE_GOOGLE_MAPS_API_KEY=your_google_maps_api_key_here
# LandMapMagic API Key
# Get your key at: https://api.landmapmagic.com/admin
VITE_LAND_MAP_MAGIC_API_KEY=your_landmap_api_key_here
# Mapbox Access Token (required for Mapbox examples)
VITE_MAPBOX_TOKEN=your_mapbox_token_hereDevelopment Environment:
- For local testing with a development API instance, you can use
VITE_LAND_MAP_MAGIC_API_KEY=dev - This only works with API instances that have
ENVIRONMENT=developmentset - Typically used with
http://localhost:8787or local development servers
Staging/Production Environments:
- You must use a real API key obtained from the admin portal
- The
devkey will not work with staging or production APIs - Register at your API URL's
/adminendpoint to get an API key
When you run npm run dev in the examples/ directory, Vite will:
- Load these environment variables from
.env.local - Inject them into the HTML examples at build time
- Replace placeholders like
%VITE_LAND_MAP_MAGIC_API_KEY%with actual values
Note: After creating or modifying .env.local, restart the Vite dev server.
See examples/SETUP.md for detailed setup instructions.
Already have a MapLibre map? Add CLU boundaries in 3 lines of code: docs/maplibre/README.md
Need to overlay CLU boundaries on an existing Google Maps implementation? Follow the step-by-step guide in docs/google-maps/README.md.
