Geographic Utilities
Edge-Utils provides powerful geographic utilities for location-aware applications, enabling intelligent routing, location detection, and geographic optimizations.Features
- Location Detection: Automatic user location detection
- Nearest Endpoint Routing: Route to closest endpoints
- Geographic Load Balancing: Distribute load based on geography
- Distance Calculations: Calculate distances between coordinates
- Geocoding: Convert addresses to coordinates
- Region Optimization: Optimize for regional performance
Location Detection
Automatically detect user location from requests.Advanced Location Detection
Nearest Endpoint Routing
Route requests to the nearest available endpoint.Advanced Routing
Geographic Load Balancing
Distribute traffic based on geographic factors.Dynamic Load Balancing
Distance Calculations
Calculate distances between geographic coordinates.Advanced Distance Calculations
Geocoding
Convert addresses to geographic coordinates.Reverse Geocoding
Region Optimization
Optimize applications for specific geographic regions.Geographic Caching
Cache content based on geographic location.Platform-Specific Geographic Features
Cloudflare Workers
Vercel Edge Functions
Best Practices
1. Privacy Considerations
2. Fallback Strategies
3. Performance Optimization
API Reference
LocationDetector
detect(request, options)
- Detect location from requestdetectByIP(ip)
- Detect location from IP addressenhance(location)
- Enhance location data with additional infohasConsent(request)
- Check if user has consented to location tracking
NearestEndpointRouter
findNearest(coordinates)
- Find nearest endpointfindNearestHealthy(coordinates)
- Find nearest healthy endpointfindNearestBalanced(coordinates, options)
- Find nearest with load balancing
GeoLoadBalancer
selectEndpoint(location)
- Select optimal endpoint for locationupdateLatency(endpointId, latency)
- Update endpoint latencyadjustWeight(regionId, weight)
- Adjust region weight
DistanceCalculator
haversine(point1, point2)
- Calculate haversine distancevincenty(point1, point2)
- Calculate vincenty distancebatchCalculate(origin, points)
- Calculate distances to multiple points
Geocoder
geocode(address)
- Convert address to coordinatesreverseGeocode(coordinates)
- Convert coordinates to addressbatchGeocode(addresses)
- Geocode multiple addresses