Extension:GooglePlaces
<translate> This extension is currently not actively maintained!</translate> <translate> Although it may still work, any bug reports or feature requests will more than likely be ignored.</translate> <translate> If you are interested in taking on the task of developing and maintaining this extension, [[<tvar name=request>Special:MyLanguage/Gerrit/Privilege policy#Requesting Gerrit privileges</tvar>|you can request repository ownership]].</translate> <translate> As a courtesy, you may want to contact the author.</translate> <translate> You should also remove this template and list yourself as maintaining the extension in the page's <tvar name=extension>{{Extension }}</tvar> infobox.</translate> |
GooglePlaces Release status: unmaintained |
|
---|---|
Implementation | Parser function |
Description | Pulls data from the Google Places API into wiki pages |
Author(s) | Ike Hecht (Tosfostalk) |
Latest version | 1.1 (February 2017) |
MediaWiki | 1.25+ |
PHP | 5.3+ |
Database changes | No |
License | GNU General Public License 2.0 or later |
Download | |
|
|
Quarterly downloads | Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin'). |
Public wikis using | Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin'). |
Translate the GooglePlaces extension if it is available at translatewiki.net |
The GooglePlaces extension uses parser functions to pull data from the Google Places API into wiki pages. This extension is not for the faint of heart. Its focus is on functionality and not on ease of use. It works well, but a fair amount of knowledge about the Google Places API is required to get full use of this extension. Basic users can still copy the examples below.
Installation
- <translate> [[<tvar name=2>Special:ExtensionDistributor/GooglePlaces</tvar>|Download]] and move the extracted <tvar name=name>
GooglePlaces
</tvar> folder to your <tvar name=ext>extensions/
</tvar> directory.</translate>
<translate> Developers and code contributors should install the extension [[<tvar name=git>Special:MyLanguage/Download from Git</tvar>|from Git]] instead, using:</translate>cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/GooglePlaces - <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
wfLoadExtension( 'GooglePlaces' ); $wgGooglePlacesAPIKey = /* GOOGLE API KEY GOES HERE */;
- <translate> Run the [[<tvar name=update>Special:MyLanguage/Manual:Update.php</tvar>|update script]] which will automatically create the necessary database tables that this extension needs.</translate>If downloading with git, you must run
git submodule update --init
from the extension directory. - File:OOjs UI icon check-constructive.svg <translate> Done</translate> – <translate> Navigate to <tvar name=special>Special:Version</tvar> on your wiki to verify that the extension is successfully installed.</translate>
Configuration parameters
- $wgGooglePlacesAPIKey
- (Required) Your API key from Google
- $wgGooglePlacesExpiry
- How long to cache the API lookups. Defaults to 10 minutes.
Usage
Note: With either parser function, either or both parameters may be omitted and the extension will use the value that was contained in the previous parser function call that is on that same page.
The googleplaces
parser function
The googleplaces
parser function allows you to look up a place's details based on that place's Google Place ID. It takes two unnamed parameters.
- The first parameter is the Place ID. You can look that up using this page.
- The second parameter is the path through the API's response that contains the information you need, with each level separated by a
;
. This page contains information about the fields that the API sends.
Examples
{{#googleplaces:ChIJKye2O32AhYAReYE_INe4rf4|name}}
→ Wikimedia Foundation Inc.{{#googleplaces:ChIJKye2O32AhYAReYE_INe4rf4|address_fixed;address_city}}
→ SF{{#googleplaces:ChIJKye2O32AhYAReYE_INe4rf4|address_fixed;address_state}}
→ CA{{#googleplaces:ChIJKye2O32AhYAReYE_INe4rf4|formatted_address}}
→ 149 New Montgomery Street, San Francisco, CA 94105, United States{{#googleplaces:ChIJKye2O32AhYAReYE_INe4rf4|formatted_phone_number}}
→ (415) 839-6885{{#googleplaces:ChIJKye2O32AhYAReYE_INe4rf4|geometry;location;lat}}, {{#googleplaces:ChIJKye2O32AhYAReYE_INe4rf4|geometry;location;lng}}
→ 37.786997, -122.399695{{#googleplaces:ChIJKye2O32AhYAReYE_INe4rf4|rating}}
→ 4.4{{#googleplaces:ChIJKye2O32AhYAReYE_INe4rf4|website}}
→ http://wikimediafoundation.org/{{#googleplaces:ChIJKye2O32AhYAReYE_INe4rf4|adr_address}}
→ <span class="street-address">149 New Montgomery Street</span>, <span class="locality">San Francisco</span>, <span class="region">CA</span> <span class="postal-code">94105</span>, <span class="country-name">United States</span>{{#googleplaces:ChIJKye2O32AhYAReYE_INe4rf4|opening_hours;weekday_text;0}}
→ Monday: 9:00 am – 5:00 pm
The googleplacestype
parser function
The googleplacestype
parser function allows you to retrieve particular components of the address_components
API response. It takes two or three unnamed parameters:
- The first parameter is the Place ID. You can look that up using this page.
- The second parameter is the type that the extension should search for. The extension will search through the
address_components
array until it finds an array containing this type. Google uses types contained in this list. - (optional) The third parameter is the field (array key) that the extension should search for, within the array that matches the type that was requested. That is usually either
long_name
orshort_name
. If omitted, the extension will just pick the first value - usuallylong_name
.
Examples
{{#googleplacestype:ChIJKye2O32AhYAReYE_INe4rf4|country|long_name}}
→ United States{{#googleplacestype:ChIJKye2O32AhYAReYE_INe4rf4|country|short_name}}
→ US{{#googleplacestype:ChIJKye2O32AhYAReYE_INe4rf4|country}}
→ United States{{#googleplacestype:ChIJKye2O32AhYAReYE_INe4rf4|locality|long_name}}
→ San Francisco{{#googleplacestype:ChIJKye2O32AhYAReYE_INe4rf4|locality|short_name}}
→ SF
Limitations
- It should be made more secure, with certificates.
- Caching should be made optional.
- Not all responses from Google (such as responses which are arrays) are easily accessible yet.
- Pages with script errors
- Pages with broken file links
- Unmaintained extensions
- Extensions without an image
- Parser function extensions
- Extensions without a compatibility policy
- Extensions with manual MediaWiki version
- GPL licensed extensions
- Extensions in Wikimedia version control
- ParserFirstCallInit extensions
- All extensions