Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 2.11 KB

readme.md

File metadata and controls

38 lines (28 loc) · 2.11 KB

Media Location - A WordPress Plugin

This plugin adds a Google Maps places field to the media attachment edit interface. This enables the saving of places as post meta along with the attachment (Facebook-style photo tagging of places).

Requirements

  • Google Maps API Key - The key must have the Javascript Maps and Places APIs enabled, and have an associated billing method.

Setup

  1. After installing and activating the plugin, visit Settings > Media Location to enter your Google API key.

Saving Image Locations

  1. Open a media library image
  2. New fields will appear below the standard media library fields, including date and location.
  3. If the Google Places library is enabled, search by location in the "Location" field. Selecting a location will populate some hidden field data including the place name, coordinates, etc.
  4. Click "Save Location" to save the date and location data.

All location data is saved as meta_data for the attachment object.

API Usage

The location data is available through a REST API endpoint:

media-location/v1/attachment/{attachment_id}

The endpoint accepts one parameter, the attachment ID. The parameter name is id. If location data is saved, this endpoint will return the normal post object along with the following extra properties:

  • place_id - The Google Places ID
  • place_name - The Google formatted place name
  • formatted_address - The Google formatted address
  • latitude
  • longitude
  • data (stored in the format specified by the WordPress install)

Repository

A repository method for retrieving place data is included in MediaLocation\Repositories\AttachmentRepository. Example usage: $location_data = (new \MediaLocation\Repositories\AttachmentRepository)->getAttachment($id);

Theme Usage

The output of location data is currently expected to be handled entirely by the theme. Note: Google's license agreement specifies that the geolocation data must be used within Google Maps. The output of maps and any tagged location must be handled by the theme.

A lightbox-style gallery with location output is currently under development to be included with this plugin.