arraypress/mapkit
Composer 安装命令:
composer require arraypress/mapkit
包简介
A PHP library for generating map URLs for various services including Google Maps, Apple Maps, Bing Maps, OpenStreetMap, Waze, and Yandex Maps, with support for coordinates, directions, and search functionality.
关键字:
README 文档
README
A comprehensive PHP library for generating URLs and embeds for various map services including Google Maps, Bing Maps, and Apple Maps. Provides a fluent interface for building map URLs with support for coordinates, search, directions, custom views, and more.
Features
- 🗺️ Multi-Service Support: Generate URLs for Google Maps, Bing Maps, and Apple Maps
- 📍 Location Handling: Coordinate-based locations and place searches
- 🚗 Direction Support: Complex routing with waypoints and travel modes
- 🎨 View Customization: Multiple map types and layer options
- 🌍 Street View: Support for Google Street View and Bing Bird's Eye view
- 📱 Embed Generation: Create embeddable map iframes
- 🌐 Internationalization: Language and region preferences
- 🚦 Traffic & Transit: Real-time traffic and public transportation overlays
- 📊 Collections: Support for multiple location markers and points of interest
Requirements
- PHP 7.4 or later
- WordPress 6.7.1 or later
Installation
Install via Composer:
composer require arraypress/mapkit
Basic Usage
use ArrayPress\MapKit\Client; // Initialize client $mapkit = new Client(); // Generate URLs for all services at once $urls = $mapkit->get_all_urls( 40.7484, -73.9857, 15 ); // Empire State Building // Or use specific services $google_url = $mapkit->google() ->coordinates( 40.7484, -73.9857 ) ->zoom( 15 ) ->get_url(); $bing_url = $mapkit->bing() ->coordinates( 40.7484, -73.9857 ) ->zoom( 15 ) ->get_url(); $apple_url = $mapkit->apple() ->coordinates( 40.7484, -73.9857 ) ->zoom( 15 ) ->get_url();
Google Maps Features
Basic Maps
$google = $mapkit->google(); // Simple map view $url = $google->coordinates( 40.7484, -73.9857 ) ->zoom( 15 ) ->get_url(); // Satellite view $url = $google->coordinates( 40.7484, -73.9857) ->zoom( 18 ) ->basemap( 'satellite' ) ->get_url(); // Show traffic $url = $google->coordinates( 40.7484, -73.9857 ) ->layer( 'traffic' ) ->get_url();
Search
// Basic search $url = $google->search( 'Empire State Building' ) ->get_url(); // Search with Place ID $url = $google->search( 'Empire State Building', 'ChIJaXQRs6lZwokRY6EFpJnhNNE' ) ->get_url(); // Localized search $url = $google->search( 'Empire State Building' ) ->language( 'es' ) ->region( 'US' ) ->get_url();
Directions
// Basic directions $url = $google->from( 'Times Square' ) ->to( 'Empire State Building' ) ->get_url(); // Complex routing $url = $google->from( 'Times Square' ) ->to( 'Empire State Building' ) ->waypoints( [ 'Madison Square Garden'] ) ->travel_mode( 'walking' ) ->avoid( [ 'highways', 'tolls' ] ) ->get_url(); // Transit directions $url = $google->from( 'Grand Central' ) ->to( 'Central Park' ) ->travel_mode( 'transit' ) ->get_url();
Street View
// Basic Street View $url = $google->coordinates( 40.7484, -73.9857 ) ->street_view() ->get_url(); // Customized view $url = $google->coordinates( 40.7484, -73.9857 ) ->street_view( null, 180, 20, 90 ) // heading, pitch, FOV ->get_url();
Embedded Maps
// Basic embed $embed = $google->coordinates( 40.7484, -73.9857 ) ->zoom( 15 ) ->as_embed() ->get_embed(); // Custom size embed $embed = $google->coordinates( 40.7484, -73.9857 ) ->zoom( 15 ) ->as_embed( 800, 600 ) ->get_embed();
Bing Maps Features
Basic Maps
$bing = $mapkit->bing(); // Road view $url = $bing->coordinates( 40.7484, -73.9857 ) ->style( 'road' ) ->get_url(); // Aerial view $url = $bing->coordinates( 40.7484, -73.9857 ) ->style( 'satellite' ) ->get_url(); // Bird's eye view $url = $bing->coordinates( 40.7484, -73.9857 ) ->style( 'birds-eye' ) ->birds_eye( null, 180 ) ->get_url();
Search
// Location search $url = $bing->search( 'Empire State Building' ) ->get_url(); // Business search $url = $bing->business_search( 'restaurants near Times Square' ) ->get_url(); // Sorted business search $url = $bing->business_search( 'restaurants', 2 ) // Sort by rating ->get_url();
Directions
// Basic directions $url = $bing->from( 'Times Square' ) ->to( 'Empire State Building' ) ->get_url(); // Transit directions with timing $url = $bing->from( 'Grand Central' ) ->to( 'Central Park' ) ->travel_mode( 'transit' ) ->transit_time( 'depart', '202403151430' ) ->get_url(); // Route with traffic $url = $bing->from( 'Times Square' ) ->to( 'Empire State Building' ) ->route_options( false, true ) // Show traffic ->get_url();
Collections
// Single point $url = $bing->add_point( 40.7484, -73.9857, 'Empire State Building', 'Iconic NYC landmark' )->get_url(); // Multiple points $url = $bing->add_point( 40.7484, -73.9857, 'Empire State Building' ) ->add_point( 40.7580, -73.9855, 'Times Square' ) ->get_url();
Apple Maps Features
Basic Maps
$apple = $mapkit->apple(); // Standard view $url = $apple->coordinates( 40.7484, -73.9857 ) ->map_type( 'standard' ) ->get_url(); // Satellite view $url = $apple->coordinates( 40.7484, -73.9857 ) ->map_type( 'satellite' ) ->get_url(); // Hybrid view $url = $apple->coordinates( 40.7484, -73.9857 ) ->map_type( 'hybrid' ) ->get_url();
Search and Directions
// Search $url = $apple->search( 'Empire State Building' ) ->get_url(); // Directions $url = $apple->from( 'Times Square' ) ->to( 'Empire State Building' ) ->transport_type( 'walking' ) ->get_url();
Additional Features
// Add pin $url = $apple->coordinates( 40.7484, -73.9857 ) ->add_pin( 40.7484, -73.9857) ->get_url(); // Set locale $url = $apple->coordinates( 40.7484, -73.9857 ) ->language( 'es' ) ->region( 'US' ) ->get_url();
Advanced Usage
Method Chaining
All service builders support method chaining for a fluent interface:
$url = $mapkit->google() ->coordinates( 40.7484, -73.9857 ) ->zoom( 15 ) ->basemap( 'satellite' ) ->layer( 'traffic' ) ->language( 'en' ) ->region( 'US' ) ->get_url();
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
License
Licensed under the GPLv2 or later license.
Support
For more information and support:
arraypress/mapkit 适用场景与选型建议
arraypress/mapkit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 12 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「routing」 「geocoding」 「google-maps」 「wordpress」 「navigation」 「maps」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 arraypress/mapkit 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 arraypress/mapkit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 arraypress/mapkit 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Maps in minutes. Powered by the Google Maps API.
Yii2 map input widget. Allows you to select geographcal coordinates via a human-friendly inteface.
GISCO Geocoding Provider for Geocoder PHP.
Write down your routing mapping at one place
Harness the power of the Google Autocomplete API inside Craft. Adds an autocomplete search box to Craft entries.
Laravel package that helps to use GoogleMaps
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2024-12-13