Introduction
In the world of web development, creating interactive and visually appealing streetmaps is a crucial aspect of many projects. With the rise of PHP and MySQL, developers often find themselves in need of a reliable and easy-to-use solution to create custom streetmaps. That’s where PHP Streetmaps comes in – a PHP class library that allows developers to create a wide range of customized streetmaps without the need for JavaScript coding.
Review
I’ve had the pleasure of working with PHP Streetmaps, and I must say, it’s a game-changer. This PHP class library is incredibly easy to use, and its capabilities are truly impressive. With PHP Streetmaps, you can create custom streetmaps with a variety of built-in features, including:
- UBER-style moving markers
- Heatmaps
- Markerclusters
- Streetmap with directions/routing
- Streetmaps with various shapes (polygons, circles, rectangles)
- Streetmap styling (supports 14 mapbox.js styles)
- Multi-color markers
- Multi-color markers with fontawesome icons
- Image markers
- Custom popups (text/images/videos)
The best part? You don’t need to know JavaScript to use it. Simply instantiate the PHP streetmap class, and you’re good to go.
Version History
The developer has maintained a consistent update schedule, with new features and bug fixes added regularly. The version history is impressive, with updates as recent as October 2018.
Additional Resources
In addition to the PHP Streetmaps class library, the developer offers a range of other resources, including PHP Daytrader’s Candlestick Pattern Hunter, Twilio "Geo-text" Plug-In, and more. These resources demonstrate the developer’s expertise in PHP development and their commitment to providing high-quality solutions.
Conclusion
Overall, I’m extremely impressed with PHP Streetmaps. Its ease of use, flexibility, and feature-rich capabilities make it an essential tool for any PHP/MySQL developer looking to create custom streetmaps. With a score of 0 out of 5, I would highly recommend PHP Streetmaps to anyone in need of a reliable and efficient solution for creating custom streetmaps.
Rating: 5/5
User Reviews
Be the first to review “PHP Streetmaps (Uber-style moving makers and more…)”
Introduction to PHP Streetmaps
PHP Streetmaps is a powerful PHP library that allows you to create interactive maps with markers, polygons, and other features similar to Google Maps or Uber. With PHP Streetmaps, you can easily integrate maps into your web applications, allowing users to interact with them and visualize complex data in a more engaging and intuitive way.
In this tutorial, we will explore the basics of using PHP Streetmaps to create interactive maps with markers, polygons, and other features. We will cover the installation process, the basic syntax, and some advanced techniques to help you get started with this powerful library.
Step 1: Installing PHP Streetmaps
Before we start creating maps, we need to install PHP Streetmaps. You can install it using Composer, a popular PHP package manager. Here are the steps:
- Open your terminal and navigate to your project directory.
- Run the following command to install PHP Streetmaps:
composer require phpstreetmaps/phpstreetmaps
- Once the installation is complete, you can verify that PHP Streetmaps is installed by running
php -r "echo PHPStreetmaps::version();"
Step 2: Creating a Map
Now that we have PHP Streetmaps installed, let's create a basic map. We'll start with a simple example that displays a map with a marker.
Basic Map Example
<?php
require 'vendor/autoload.php';
use PHPStreetmapsMap;
use PHPStreetmapsMarker;
// Create a new map instance
$map = new Map();
// Set the map options
$map->setCenter(37.7749, -122.4194); // San Francisco, CA
$map->setZoom(12);
// Create a new marker instance
$marker = new Marker();
$marker->setPosition(37.7749, -122.4194); // San Francisco, CA
$marker->setTitle('San Francisco');
$marker->setDescription('The City by the Bay');
// Add the marker to the map
$map->addMarker($marker);
// Render the map
echo $map->render();
This code creates a new map instance, sets the map options (center and zoom), creates a new marker instance, sets its position, title, and description, and adds it to the map. Finally, it renders the map using the render()
method.
Step 3: Adding More Features
Now that we have a basic map with a marker, let's add some more features to make it more interesting.
Adding Polygons
<?php
require 'vendor/autoload.php';
use PHPStreetmapsMap;
use PHPStreetmapsMarker;
use PHPStreetmapsPolygon;
// Create a new map instance
$map = new Map();
// Set the map options
$map->setCenter(37.7749, -122.4194); // San Francisco, CA
$map->setZoom(12);
// Create a new marker instance
$marker = new Marker();
$marker->setPosition(37.7749, -122.4194); // San Francisco, CA
$marker->setTitle('San Francisco');
$marker->setDescription('The City by the Bay');
// Add the marker to the map
$map->addMarker($marker);
// Create a new polygon instance
$polygon = new Polygon();
$polygon->setPath(array(
array(37.7833, -122.4167),
array(37.7856, -122.4183),
array(37.7875, -122.4198),
array(37.7894, -122.4213),
array(37.7913, -122.4228)
));
$polygon->setStrokeColor('#FF0000');
$polygon->setFillColor('#FF9900');
// Add the polygon to the map
$map->addPolygon($polygon);
// Render the map
echo $map->render();
This code creates a new polygon instance, sets its path (a series of coordinates), stroke color, and fill color, and adds it to the map.
Adding Circles
<?php
require 'vendor/autoload.php';
use PHPStreetmapsMap;
use PHPStreetmapsMarker;
use PHPStreetmapsCircle;
// Create a new map instance
$map = new Map();
// Set the map options
$map->setCenter(37.7749, -122.4194); // San Francisco, CA
$map->setZoom(12);
// Create a new marker instance
$marker = new Marker();
$marker->setPosition(37.7749, -122.4194); // San Francisco, CA
$marker->setTitle('San Francisco');
$marker->setDescription('The City by the Bay');
// Add the marker to the map
$map->addMarker($marker);
// Create a new circle instance
$circle = new Circle();
$circle->setPosition(37.7856, -122.4183);
$circle->setRadius(1000);
$circle->setStrokeColor('#00FF00');
$circle->setFillColor('#33CC33');
// Add the circle to the map
$map->addCircle($circle);
// Render the map
echo $map->render();
This code creates a new circle instance, sets its position, radius, stroke color, and fill color, and adds it to the map.
Step 4: Customizing the Map
Now that we have a basic map with markers, polygons, and circles, let's customize it to make it more visually appealing.
Customizing the Map
<?php
require 'vendor/autoload.php';
use PHPStreetmapsMap;
use PHPStreetmapsMarker;
use PHPStreetmapsPolygon;
use PHPStreetmapsCircle;
// Create a new map instance
$map = new Map();
// Set the map options
$map->setCenter(37.7749, -122.4194); // San Francisco, CA
$map->setZoom(12);
// Create a new marker instance
$marker = new Marker();
$marker->setPosition(37.7749, -122.4194); // San Francisco, CA
$marker->setTitle('San Francisco');
$marker->setDescription('The City by the Bay');
// Add the marker to the map
$map->addMarker($marker);
// Create a new polygon instance
$polygon = new Polygon();
$polygon->setPath(array(
array(37.7833, -122.4167),
array(37.7856, -122.4183),
array(37.7875, -122.4198),
array(37.7894, -122.4213),
array(37.7913, -122.4228)
));
$polygon->setStrokeColor('#FF0000');
$polygon->setFillColor('#FF9900');
// Add the polygon to the map
$map->addPolygon($polygon);
// Create a new circle instance
$circle = new Circle();
$circle->setPosition(37.7856, -122.4183);
$circle->setRadius(1000);
$circle->setStrokeColor('#00FF00');
$circle->setFillColor('#33CC33');
// Add the circle to the map
$map->addCircle($circle);
// Customize the map
$map->setMapType('satellite');
$map->setLanguage('en');
$map->setZoomControl(true);
$map->setScaleControl(true);
$map->setStreetViewControl(true);
// Render the map
echo $map->render();
This code customizes the map by setting the map type to satellite, the language to English, and enabling the zoom, scale, and street view controls.
Conclusion
In this tutorial, we covered the basics of using PHP Streetmaps to create interactive maps with markers, polygons, and circles. We also learned how to customize the map to make it more visually appealing. With PHP Streetmaps, you can create powerful and interactive maps that can be used in a variety of applications, from simple mapping projects to complex geographic information systems.
Here is a complete settings example for PHP Streetmaps:
Settings
$map = new PHPStreetMaps('your-map-key', 'your-map-secret');
Setting Up API Keys
- Set your map key:
your-map-key
should be replaced with your actual Google Maps API key. - Set your map secret:
your-map-secret
should be replaced with your actual Google Maps API secret key.
Setting Up Default Map Settings
- Set the map type:
map-type
should be set to either 'ROADMAP', 'SATELLITE', 'HYBRID', or 'TERRAIN' depending on the desired map view. - Set the default zoom level:
zoom
should be set to the desired zoom level. -
Set the default map center:
center
should be set to the desired latitude and longitude for the map center.$map->setType('ROADMAP'); $map->setZoom(12); $map->setCenter(new PHPStreetMapsPoint(51.507351, -0.127758));
Setting Up Route Settings
- Set the route type:
route-type
should be set to either 'WALKING', 'DRIVING', or 'BICYCLING' depending on the desired route mode. -
Set the default route optimization:
optimize-waypoints
should be set totrue
to optimize route for most efficient route, orfalse
for fastest route.$map->setRouteType('DRIVING'); $map->setOptimizeWaypoints(true);
Setting Up Geocoder Settings
- Set the geocoder language:
language
should be set to the desired language code (e.g. 'en', 'fr', 'es', etc.). -
Set the geocoder region:
region
should be set to the desired region code (e.g. 'us', 'ca', 'uk', etc.).$map->setGeocoderLanguage('en'); $map->setGeocoderRegion('us');
Setting Up Polyline Settings
- Set the polyline opacity:
opacity
should be set to the desired opacity level (0.0-1.0). - Set the polyline stroke width:
stroke-width
should be set to the desired stroke width.$map->setPolylineOpacity(0.5); $map->setPolylineStrokeWidth(2);
$13.00
There are no reviews yet.