Extension:GoogleGeocode
From Linux Web Expert
GoogleGeocode Release status: beta |
|
---|---|
Implementation | Parser function |
Description | MediaWiki wrapper around the Google Geocode API |
Author(s) | Ike Hecht (Tosfostalk) |
Latest version | 0.1.0 (November 2015) |
MediaWiki | 1.23+ |
PHP | 5.3+ |
Database changes | No |
Composer | mediawiki/google-geocode |
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 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
- <translate> [[<tvar name=2>Special:ExtensionDistributor/GoogleGeocode</tvar>|Download]] and move the extracted <tvar name=name>
GoogleGeocode
</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/GoogleGeocode - <translate> Only when installing from Git, run <tvar name=composer>Composer</tvar> to install PHP dependencies, by issuing <tvar name=code>
composer install --no-dev
</tvar> in the extension directory.</translate> <translate> (See <tvar name=phab><translate> task <tvar name=1>T173141</tvar></translate></tvar> for potential complications.)</translate> - <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
wfLoadExtension( 'GoogleGeocode' );
- 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>
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
Categories:
- Pages with script errors
- Pages with broken file links
- Beta status extensions
- Extensions without an image
- Parser function extensions
- Extensions without a compatibility policy
- Extensions with manual MediaWiki version
- Extensions supporting Composer
- GPL licensed extensions
- Extensions in Wikimedia version control
- ParserFirstCallInit extensions
- All extensions
- Geocode extensions