Skip to main content

Turn addresses into coordinates and find nearby amenities using Google Maps API

Project description

Mapradar

Crates.io PyPI License: MIT

Mapradar is a location intelligence library that converts addresses to coordinates, finds nearby services (banks, hospitals), and calculates travel distances via Google Maps APIs.


Installation

Primary Method

Python

uv add mapradar

Rust

[dependencies]
mapradar = "0.5.0"
tokio = { version = "1", features = ["full"] }

CLI Tool

cargo install mapradar
From Source
git clone https://github.com/iamprecieee/mapradar
cd mapradar

# Python
uv add maturin
maturin develop

# Rust
cargo build

Usage

CLI Commands

# Geocode an address
mapradar geocode "1600 Amphitheatre Parkway, Mountain View, CA"

# Find nearby amenities (JSON output)
mapradar nearby --lat 6.6018 --lng 3.3515 --radius 500 --type bank,school

# Export nearby amenities to GeoJSON or CSV
mapradar nearby --lat 6.6018 --lng 3.3515 --radius 500 --type bank,school --format geojson

# Distance calculation
mapradar distance --origin-addr "Shibuya, Tokyo" --dest-addr "Shinjuku, Tokyo" --mode drive

# Geofence (Point in radius)
mapradar within-radius --lat 6.6018 --lng 3.3515 --target-address "Yaba, Lagos" -r 5.0

# Location Scoring
mapradar score --address "Yaba, Lagos" -r 3.0
Library Usage

Python Example

import asyncio
from mapradar import MapradarClient, SearchQuery, ServiceType, TravelParameters

async def main():
    client = MapradarClient("YOUR_GOOGLE_MAPS_API_KEY")
    
    # Calculate travel distance between two points
    params = TravelParameters(
        origin_address="Shibuya, Tokyo",
        destination_address="Shinjuku, Tokyo"
    )
    distance = await client.calculate_travel_distance(params)
    print(f"Distance: {distance:.2f} km")

    # Find banks and hospitals near an address
    query = SearchQuery.from_address("Shibuya, Tokyo")
    intel = await client.fetch_intelligence(
        query,
        service_types=[ServiceType.Bank, ServiceType.Hospital],
        radius_km=3.0
    )
    print(f"Location: {intel.location.address}")

    # Export to GeoJSON
    import mapradar
    geojson = mapradar.export_intelligence(intel, "geojson")
    
    # Location Scoring
    score = await client.score_location(query, radius_km=5.0)
    print(f"Overall Score: {score.overall_score:.2f}")

asyncio.run(main())

Rust Example

use mapradar::client::MapradarClient;
use mapradar::models::{SearchQuery, ServiceType};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = MapradarClient::new("YOUR_API_KEY".to_string());
    let location = client.geocode_async("Times Square, NYC").await?;
    println!("{}, {} ({})", location.latitude, location.longitude, location.country);
    Ok(())
}

Features

Feature Description
Geocoding Convert addresses to coordinates
Reverse Geocoding Convert coordinates to addresses
Nearby Search Find banks, hospitals, schools, etc.
Distance Fetching Fast travel/Haversine distance with address fallthrough
Parallel Fetching Search multiple service types at once
Caching Automatic in-memory cache reduces API calls
JSON-RPC 2.0 Built-in format for microservice APIs

Configuration

Option Default Description
GOOGLE_MAPS_API_KEY None Your Google Maps API key. Enable Geocoding API, Places API (New), and Routes API.
max_results 20 Maximum number of places returned per category.
radius 5.0 Search radius in kilometers.
--mode drive Transit mode for distance calculation (e.g. drive, okada, auto, ojek, danfo, angkot).

FAQ

What APIs do I need enabled?

Enable these in Google Cloud Console:

  • Geocoding API
  • Places API (New)
  • Routes API (V2)
Is there rate limiting?

Mapradar does not rate limit locally. Your Google Maps API quota applies. Use the built-in Moka cache to reduce outbound calls.

Does caching persist across restarts?

No. Cache is in-memory only. It persists for the lifetime of your MapradarClient instance to ensure maximum security.


License

MIT


Contributing | Security | Code of Conduct

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mapradar-0.5.0.tar.gz (41.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mapradar-0.5.0-cp39-abi3-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

Details for the file mapradar-0.5.0.tar.gz.

File metadata

  • Download URL: mapradar-0.5.0.tar.gz
  • Upload date:
  • Size: 41.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.11.5

File hashes

Hashes for mapradar-0.5.0.tar.gz
Algorithm Hash digest
SHA256 b1b5e9ee5ad98dd1a976de9b02772338f331f98af3f11e9f2b0f2c0ad858a563
MD5 40d34966efc00f3c5457329fc6141a35
BLAKE2b-256 23e6585c4327ee849a995ccc2bc109e47d3be51a50b23c1a30a4a82009823768

See more details on using hashes here.

File details

Details for the file mapradar-0.5.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mapradar-0.5.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 74c1eaa6ca3c553d9b762cf9126c1369daecca584f6d55e5014d2d6d247d5dcc
MD5 4b5466b34f990b64672f6514e188c7e2
BLAKE2b-256 d2bcc4b6e55b227fa197b12eae18f6683f2605f259e89a1057aa947837a53b92

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page