Extension:GoogleGeocode
![]() Release status: betaCategory:Beta status extensions |
|
---|---|
Implementation | Parser functionCategory:Parser function extensions |
Description | MediaWiki wrapper around the Google Geocode API |
Author(s) | Ike Hecht (Tosfostalk) |
Latest version | 0.1.0 (November 2015) |
MediaWiki | 1.23+Category:Extensions with manual MediaWiki version |
PHP | 5.3+ |
Database changes | No |
Composer | true Category:Extensions supporting Composer |
License | GNU General Public License 2.0 or later |
Download | Category:Extensions in Wikimedia version control |
|
|
Quarterly downloads | 1 (Ranked 112nd) |
Translate the GoogleGeocode extension if it is available at translatewiki.net |
The GoogleGeocode extension is a MediaWiki wrapper around the GoogleMapsGeocoder PHP wrapper around the Google Maps Geocoding API. It is capable of looking up a given address, and obtaining information about it, such as its geocoordinates.
Installation
- Download and move the extracted
GoogleGeocode
folder to yourextensions/
directory.
Developers and code contributors should install the extension from Git instead, using:cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/GoogleGeocode - Only when installing from Git, run Composer to install PHP dependencies, by issuing
composer install --no-dev
in the extension directory. (See T173141 for potential complications.)Category:Extensions requiring Composer with git - Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'GoogleGeocode' );
Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
When installing from Git, please note that this extension requires Composer.
So, after installation from git, change to the directory containing the extension e.g. ".../extensions/GoogleGeocode/" and run
Alternatively as well as preferably add the line
Now run
So, after installation from git, change to the directory containing the extension e.g. ".../extensions/GoogleGeocode/" and run
composer install --no-dev
, or when updating: composer update --no-dev
.Alternatively as well as preferably add the line
"extensions/GoogleGeocode/composer.json"
to the "composer.local.json" file in the root directory of your wiki like e.g.
{
"extra": {
"merge-plugin": {
"include": [
"extensions/GoogleGeocode/composer.json"
]
}
}
}
composer update --no-dev
.Configuration parameters
- $wgGoogleGeocodeAPIKey
- API key. You should probably obtain one from Google.
- $wgGoogleGeocodeExpiry
- Time (in seconds) to cache the data received from Google. Adjust to keep within the API's usage limits. Defaults to:
600
(10 minutes). - $wgGoogleGeocodeDelimiter
- Delimiter to use between elements of returned arrays. Defaults to:
;
.
Usage
The googlegeocode
parser function takes three parameters, in the form of {{#googlegeocode:Search term|Component|Path}}
:
- Search term
- The search term to send to the API. This would usually be an address or establishment name.
- Component
- Component to request from Google. Good candidates for this would be
lat
,lng
,route
,locality
,country
... See the documentation for more examples. - Path
- (optional, advanced) Can be set to the desired type of component result to obtain. Can be set to
short_name
,long_name
ortypes
. Defaults to:long_name
.
If either of the first two parameters are omitted, the extension will use the value previously entered on that page.
Examples
{{#googlegeocode:1600 Amphitheatre Parkway, Mountain View, CA|lat}}
--> 37.4224504{{#googlegeocode:1600 Amphitheatre Parkway, Mountain View, CA|lng}}
--> -122.0840859{{#googlegeocode:1600 Amphitheatre Parkway, Mountain View, CA|locality}}
--> Mountain View{{#googlegeocode:Google, CA|locality}}
--> Mountain View{{#googlegeocode:|country|short_name}}
--> US{{#googlegeocode:}}
--> United States
See also
Category:Geocode extensions
Category:All extensions
Category:Beta status extensions
Category:Extensions in Wikimedia version control
Category:Extensions requiring Composer with git
Category:Extensions supporting Composer
Category:Extensions with manual MediaWiki version
Category:Extensions without a compatibility policy
Category:Extensions without an image
Category:GPL licensed extensions
Category:Geocode extensions
Category:ParserFirstCallInit extensions
Category:Parser function extensions