Skip to main content

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

Project description

Mapradar

Crates.io PyPI License: MIT

Turn addresses into coordinates and find nearby banks, hospitals, and other amenities.


What It Does

Mapradar is a location intelligence library. Give it an address like "Shibuya, Tokyo" and it returns:

  1. Coordinates - Latitude and longitude
  2. Nearby Services - Banks, hospitals, schools, fuel stations within a radius
  3. Distance - How far each service is from your location

Built in Rust. Works in both Python and Rust.


Installation

Python
uv add mapradar
Rust
[dependencies]
mapradar = { version = "0.1", default-features = false }
tokio = { version = "1", features = ["full"] }

Note: Use default-features = false for pure Rust (no Python bindings).

From Source

Python:

git clone https://github.com/iamprecieee/mapradar
cd mapradar
uv add maturin
maturin develop

Rust:

[dependencies]
mapradar = { git = "https://github.com/iamprecieee/mapradar" }

Usage

Python

import asyncio
from mapradar import MapradarClient, SearchQuery, ServiceType

async def main():
    client = MapradarClient("YOUR_GOOGLE_MAPS_API_KEY")
    
    # 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}")
    print(f"Country: {intel.location.country}")
    for service in intel.nearby_services:
        print(f"  {service.name} - {service.distance_km:.2f} km")

asyncio.run(main())
More Examples

Geocoding only:

location = await client.geocode("1 Marina, Lagos")
print(location.latitude, location.longitude, location.country)

Reverse geocoding:

location = await client.reverse_geocode(6.4541, 3.3947)
print(location.address, location.country)

JSON-RPC format (for microservices):

response = await client.geocode_rpc("Lekki, Lagos", id="req-123")
print(response.to_json())

Rust

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.
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

Service Types

Type Google Maps Category
Bank bank
Hospital hospital
School school
Market supermarket
Mall shopping_mall
Restaurant restaurant
FuelStation gas_station
BusStop bus_station
TrainStation train_station
TaxiStand taxi_stand
Landmark tourist_attraction

Configuration

Variable Description
GOOGLE_MAPS_API_KEY Your Google Maps API key. Enable Geocoding API and Places API.

FAQ

What APIs do I need enabled?

Enable these in Google Cloud Console:

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

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

Does caching persist across restarts?

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


License

MIT


Contributing | Security

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.1.0.tar.gz (27.8 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.1.0-cp312-cp312-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for mapradar-0.1.0.tar.gz
Algorithm Hash digest
SHA256 23c216c61d4300c698d6c09bb7e346715a32a2c16a21b33f6b7443c053a4e3c4
MD5 b40985cf8ea883343f1925be8d390a0a
BLAKE2b-256 77ac218a3bd8e99f1af00c252c4accd2a02f8d7696c1cdbbba37f7b155daeb3a

See more details on using hashes here.

File details

Details for the file mapradar-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mapradar-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1a3cb3936cf4f34e77b5273560d05f13304473e544c226344367f080fb0569de
MD5 02d5c57362bcbdd46c1687e49e0616f6
BLAKE2b-256 0cb8add129cf0e4f1be34f7348ec20883a9e104d3d631b2b5571222fedea9d1e

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