Download the PHP package swixpop/locate without Composer

On this page you can find all versions of the php package swixpop/locate. 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 locate

Locate plugin for Craft CMS 3.x

Harness the power of the Google Autocomplete API inside Craft. Adds an autocomplete search box to Craft entries which allows place and address queries to be made to the API. Populates a hidden Location field with lat, lng, location, and placeid which you can grab in your templates to do with as you wish.

Requirements

Note:

Google has updated their API access policy. See https://cloud.google.com/maps-platform/user-guide/

Installation

To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

    cd /path/to/project
  2. Then tell Composer to load the plugin:

    composer require swixpop/locate
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Locate, or from the command line:

    ./craft install/plugin locate
  4. Configure the plugin via the plugin settings page in the control panel.

  5. You can now create Location fields and add them to your entries.

Configuration

Navigate to Settings > Plugins > Locate. Enter your Google API key if you already have one, or get one here. The settings page also allows you to customize the behaviour of the autocomplete box.

Customize the autocomplete box

The autocomplete search box need not be customized. It defaults to all place types (cities, addresses, businesses, etc.) in the world. By default, the API will attempt to detect the user's location from their IP address, and will bias the results to that location.

However, by passing in some basic options, advanced filtering can be achieved. You can modify the default behaviour by passing in a JSON object of options. For a full list of allowed options see the official documentation from Google.

These options can be set globally or on a per field basis. Options set on individual fields will override the global options.

The options object must be formatted correctly or the plugin will throw a javascript error! If after reading this documentation you are unclear about what to enter in the options box, please leave it blank.

Restrict search by place type

You can specify an array of types to restrict the results returned to your autocomplete box. In general only a single type is allowed. Possible values are:

See the official documentation for details on how using these types will restrict your results.

Example usage

Restrict the results to cities:

Restrict the results to business establishments:

Bias the search towards a geographical already

You can use the bounds property to specify a google.maps.LatLngBoundsLiteral and bias your search results to a geographic area. This is an object specifying north, east, south, and west values. The autocomplete box return results biased towards, but not restricted to, the area you specify.

See the LatLngBoundsLiteral object specification for full details.

Note that the values are entered as a number and not a string

Example usage

Bias the search results to the Pacific Northwest:

Restrict search by country

You can restrict results to an individual country using the componentRestrictions property. The country must be passed as as a two-character, ISO 3166-1 Alpha-2 compatible country code.

Example usage

Restrict the results to Canada:

Putting it all together

Using the above examples we can create an options object that restricts searches to businesses in Canada, preferably in the Pacific Northwest region (ie. Starbucks in Vancouver).

Using the Location field

The Location field returns locationData, lat, lng, location, and placeid. You can use these in your templates and pass them on to your javascript.

The placeid can be used to make additional requests to the Google Maps API. With placeid you can make place details requests to get information such as address, phone number, reviews, etc. You can also use the placeid to generate map markers. Read more about referencing a place with a place ID.

Templating examples

Using the options restrictions from the previous section, we could search for "Lucky's Donuts" in the autocomplete box.

would generate the following:

You could then generate a simple map by loading up the Google Maps javascript API:

and grabbing the placeid, lat, and lng in your javascript:

Brought to you by Isaac Gray


All versions of locate with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0
craftcms/cms Version ^3.0.0-RC1
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 swixpop/locate contains the following files

Loading the files please wait ....