pankaj7590 / geoplot
A lightweight PHP library for plotting geographic coordinates with optional Yii2 integration.
Requires
- php: >=7.4
Requires (Dev)
- phpunit/phpunit: ^9.6
Suggests
- yiisoft/yii2: Required for using the Yii2 widget.
This package is auto-updated.
Last update: 2026-07-04 08:28:35 UTC
README
A lightweight PHP library for plotting geographic coordinates on an interactive canvas without relying on external map tile providers.
GeoPlot is designed for applications that need to visualize latitude and longitude datasets such as hotels, tourist attractions, offices, warehouses, or custom geographic points. It provides a fast, dependency-free plotting engine with optional Yii2 integration.
Features
- π Plot latitude and longitude coordinates on an interactive canvas
- πΊοΈ No dependency on Google Maps, OpenStreetMap, or other tile providers
- π Built-in zoom and pan controls
- π― Highlight individual points with custom styling
- π¨ Custom marker colors, labels, and tooltips
- β‘ Lightweight and fast rendering
- π Optional Yii2 widget integration
- π§© PSR-4 compliant and Composer installable
Requirements
- PHP 7.4 or later
Optional:
- Yii2 (only if using the provided widget)
Installation
Install via Composer:
composer require geoplot/geoplot
If Yii2 integration is required:
composer require yiisoft/yii2
Quick Start
require 'vendor/autoload.php'; use GeoPlot\Dataset; use GeoPlot\Plot; use GeoPlot\Point; $dataset = Dataset::make('Hotels') ->style([ 'color' => '#2196f3', 'size' => 7, ]); foreach ($points as $point) { $hotel = Point::make($point->latitude, $point->longitude, $point->name); if ($point->isSelected) { $hotel->mark('#e53935', 10); } $dataset->add($hotel); } $plot = new Plot([ 'datasets' => [$dataset], 'height' => '600px', 'maxZoom' => 5000, ]); echo $plot->render();
Yii2 Integration
GeoPlot includes optional Yii2 support through an adapter widget.
use GeoPlot\Dataset; use GeoPlot\Point; use GeoPlot\Yii2\Plot as YiiPlot; $dataset = Dataset::make('Hotels') ->style([ 'color' => '#2196f3', 'size' => 7, ]); foreach ($points as $point) { $hotel = Point::make($point->latitude, $point->longitude, $point->name); if ($point->isSelected) { $hotel->mark('#e53935', 10); } $dataset->add($hotel); } echo YiiPlot::widget([ 'datasets' => [$dataset], 'height' => '600px', 'maxZoom' => 5000, ]);
Example Output
GeoPlot renders an interactive plotting canvas where users can:
- Zoom in and out
- Pan the view
- Highlight selected locations
Features in Detail
Coordinate Plotting
Plot thousands of latitude and longitude points efficiently.
Interactive Navigation
- Mouse wheel zoom
- Drag to pan
- Adjustable zoom limits
Marker Styling
Customize markers individually.
Examples include:
- Different colors
- Different sizes
- Labels
City Center Detection
GeoPlot can determine a representative city center based on the distribution of plotted coordinates.
This is particularly useful for:
- Hotel clusters
- Property listings
- Delivery hubs
- Tourist destinations
Configuration
GeoPlot allows customization of various rendering options, including:
- Canvas dimensions
- Zoom limits
- Marker colors
- Marker radius
- Labels
Typical Use Cases
GeoPlot is suitable for applications such as:
- Hotel booking platforms
- Travel portals
- Property listing websites
- Logistics and fleet management
- Delivery routing
- Warehouse visualization
- Educational GIS projects
- Business location mapping
Roadmap
Future enhancements may include:
- Polygon support
- Polyline rendering
- Heatmap visualization
- Cluster rendering
- Distance measurement tools
- SVG export
- GeoJSON import/export
- Additional framework integrations
Contributing
Contributions, feature requests, and bug reports are welcome.
Please open an issue before submitting significant changes to discuss the proposed implementation.
License
GeoPlot is licensed under the MIT License.
See the LICENSE file for details.