Download the PHP package sjaakp/yii2-locator without Composer

On this page you can find all versions of the php package sjaakp/yii2-locator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii2-locator

Yii2-locator

Leaflet-wrapper for Yii2 PHP framework

Latest Stable Version Total Downloads License

This is a wrapper of the Leaflet JavaScript geomapping library for the Yii 2.0 PHP Framework. It's an Yii2 Widget that can be used to display geographical data stored in an ActiveRecord, as well as to update it. Yii2-locator optionally has a search facility. It can use several providers, for the map tiles as well as for the geocoding service.

A demonstration of yii2-locator is here.

Installation

The preferred way to install yii2-locator is through Composer. Either add the following to the require section of your composer.json file:

"sjaakp/yii2-locator": "*"

Or run:

composer require sjaakp/yii2-locator "*"

You can manually install yii2-locator by downloading the source in ZIP-format.

GeoJSON

Yii2-locator handles data in GeoJSON format. Some databases store these directly. Others, like MySQL and MariaDB, use their own format for spatial data. My Yii2-spatial extension can be used to transform MySQL format to GeoJSON and vice versa. In that case, the model should be extended from sjaakp\spatial\ActiveRecord in stead of the usual yii\db\ActiveRecord.

Usage

A typical usage scenario is like this: suppose we have a database table with some geographical data, let's say the table tower. If we use MySQL or MariaDB, the model Tower is extended like this:

class Tower extends sjaakp\spatial\ActiveRecord    {
    public static function tableName()
    {
        return 'tower';
    }
    // ...
}    

The table tower has, among others, the following fields:

View

In a yii2 view, displaying a map of a tower is simple as this:

...

...

Index

Displaying a map with all the towers in, say, the index view, can be accomplished with:

...

...

Active Locator

In a create or update view, Locator can be used in a form:

...

...

...

...

Methods

Locator is an Yii2 Widget, so it inherits all of its methods.

Chainable

Most of Locator's methods return this, so they are chainable. This means that the absolute minimum code to display a map in a view would be something like:

...

Properties

Locator is an Yii2 Widget, so it inherits all of its properties.

Tile Names

Locator retrieves its map tiles from a tile provider or map provider. Tiles are identified by the name of the provider, or by an array with the name as the first item and options in the rest of the array. This value is used in the $tile property, and in the tileLayer() method. A map can have more than one tile layers, which makes sense if they are partly transparent, like the tiles from OpenSeaMap.

Some providers offer tiles in a few variants. They are indicated with a suffix to the provider name, seperated by a dot. For example: 'OpenStreetMap' and 'OpenStreetMap.BlackAndWhite'.

Commercial tile providers expect some sort of API key. This should be added to the options. Often, an API key can be obtained free of charge for small or non-commercial applications.

Out of the box, Locator supports several tile providers. They each have a PHP class file in the src/tiles directory. Currently, the following tile providers are supported (there may be more in the future):

Name Variants Required option
OpenStreetMap BlackAndWhite, HOT
OpenMapSurfer Roads, Hybrid, AdminBounds, ContourLines, Hillshade
OpenTopoMap
OpenSeaMap
Wikimedia (affiliated sites)
Carto Light, Dark, Voyager
Stamen Toner, TonerBackground, TonerLines, TonerLabels, TonerLite, Watercolor, Terrain, TerrainBackground, TerrainLabels
EsriWorld
Here lots (see TileHere.php) [ 'apiKey' => '...' ]
TomTom Basic, Hybrid, Labels [ 'key' => '...' ]
Kadaster (Netherlands only) standaard, grijs, pastel, water
Amsterdam light, zw

If $tile is not set, Locator uses tiles from OpenStreetMap.

Geocoder Names

Locator's Search functionality uses information from a geocoding service. The service is set by the first parameter of the finder() method. This can be a string which is the name of the geocoding service, or an array with the name as first item, followed by options.

Generally, there will be no options, apart from the API key some providers expect. Other options may be added.

Currently, Locator supports the following providers (there may be more in the future):

Name Required option
Nominatim, by OpenStreetMap
GeoNames [ 'username' => '...' ]
Here [ 'apiKey' => '...' ]
TomTom [ 'key' => '...' ]
Kadaster (Netherlands only)

Notice that some providers may stipulate that you should use their service only on map tiles of the same provider.

If you don't explicitly set a geocoder, Leaflet-search uses Nominatim.

Marker Types

In the property $marker, and in methods like marker(), modelMarker() etc. the marker type can be set. This is an array with [ 'type' => '<marker type>' ], supplemented with marker options (dependent on the type). For instance:

$map->marker = [ 'type' => 'Marker', 'opacity' => 0.5 ]

Apart from Leaflet's own Marker and CircleMarker, Locator sports two other markers:

DotMarker

A simple extension of CircleMarker. It has fixed radius and always has (at least) the class name 'dot-marker'. The default marker of Locator is a DotMarker.

SpriteMarker

A marker with a DivIcon. Use this to display FontAwesome markers like so:

$map->marker = [ 'type' => 'SpriteMarker', 'html' => '<i class="far fa-2x fa-dog"></i>' ]

All versions of yii2-locator with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
yiisoft/yii2 Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sjaakp/yii2-locator contains the following files

Loading the files please wait ....