plugin:google_maps
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
plugin:google_maps [2012-08-11 23:52] – corrected the link 81.182.154.254 | plugin:google_maps [2019-04-22 09:45] (current) – [Bugs and ToDo] hua | ||
---|---|---|---|
Line 7: | Line 7: | ||
type : syntax | type : syntax | ||
lastupdate : 2010-10-18 | lastupdate : 2010-10-18 | ||
- | compatible : 2009-12-25c, | + | compatible : 2009-12-25c, |
depends | depends | ||
conflicts | conflicts | ||
Line 13: | Line 13: | ||
tags : media, maps, google, embed | tags : media, maps, google, embed | ||
- | downloadurl: | + | downloadurl: |
---- | ---- | ||
+ | |||
===== Download and Installation ===== | ===== Download and Installation ===== | ||
- | Download | + | Search |
- | The up-to-date version of the plugin and this description is [[http:// | + | [[https://www.centurion.link/ |
Line 57: | Line 58: | ||
^ Parameter name ^ | ^ Parameter name ^ | ||
- | | **google_api_key** | Valid Google API key for the current site. See [[# | + | | **google_api_key** | Valid Google API key for the current site. See [[# |
| **small_width** | //(default is **425**)// size in px -- the width of small frame, if **size=small** was specified | | | **small_width** | //(default is **425**)// size in px -- the width of small frame, if **size=small** was specified | | ||
| **small_height** | //(default is **350**)// size in px -- the height of small frame, if **size=small** was specified | | | **small_height** | //(default is **350**)// size in px -- the height of small frame, if **size=small** was specified | | ||
| **large_width** | //(default is **550**)// size in px -- the width of large frame, if **size=large** was specified | | | **large_width** | //(default is **550**)// size in px -- the width of large frame, if **size=large** was specified | | ||
| **large_height** | //(default is **450**)// size in px -- the height of large frame, if **size=large** was specified | | | **large_height** | //(default is **450**)// size in px -- the height of large frame, if **size=large** was specified | | ||
+ | |||
===== Demonstration ===== | ===== Demonstration ===== | ||
- | See [[http:// | + | [[https://www.centurion.link/w/wiki/ |
Line 71: | Line 73: | ||
Important is to register your site at Google to receive an access to Google services. Registration is free: | Important is to register your site at Google to receive an access to Google services. Registration is free: | ||
- | * Register your website | + | * [[http:// |
* Modify the configuration file and put a newly generated key to **google_api_key**. | * Modify the configuration file and put a newly generated key to **google_api_key**. | ||
Line 88: | Line 90: | ||
===== Source ===== | ===== Source ===== | ||
- | |||
==== syntax/ | ==== syntax/ | ||
Line 124: | Line 125: | ||
' | ' | ||
' | ' | ||
- | ' | + | ' |
' | ' | ||
' | ' | ||
| | ||
- | ' | + | ' |
); | ); | ||
} | } | ||
Line 168: | Line 169: | ||
} | } | ||
- | function handle($match, | + | function handle($match, |
{ | { | ||
switch ($state) | switch ($state) | ||
Line 201: | Line 202: | ||
} | } | ||
- | function render($mode, | + | function render($mode, |
{ | { | ||
if ($mode == ' | if ($mode == ' | ||
Line 230: | Line 231: | ||
{ | { | ||
// Dynamic injection of this script via JS causes FF to hang, so we have to include it for each map: | // Dynamic injection of this script via JS causes FF to hang, so we have to include it for each map: | ||
- | $renderer-> | + | $renderer-> |
// Default values: | // Default values: | ||
Line 276: | Line 277: | ||
// Query is already escaped, params are taken from options: | // Query is already escaped, params are taken from options: | ||
- | $url = "http:// | + | $url = "// |
// External link: | // External link: | ||
Line 318: | Line 319: | ||
*/ | */ | ||
- | var max_geo_results | + | (function() { |
- | var geocoder; | + | // Globals: |
+ | var GMAPS_MAX_RETRY_COUNT = 5; | ||
+ | var GMAPS_RETRY_DELAY = 100; | ||
+ | var GMAPS_MAX_GEO_RESULTS | ||
+ | var GMAPS_GEOCODER = null; | ||
/* | /* | ||
Line 340: | Line 345: | ||
* This recursive function sends an ansynchronous query to Google GeoCoder and marks results on the map. | * This recursive function sends an ansynchronous query to Google GeoCoder and marks results on the map. | ||
*/ | */ | ||
- | function queryGoogleGeo(map, | + | function queryGoogleGeo(map, |
{ | { | ||
- | if (geocoder | + | if (GMAPS_GEOCODER |
{ | { | ||
// Can be initialized only at this point, as Google libraries should have been included: | // Can be initialized only at this point, as Google libraries should have been included: | ||
- | | + | |
} | } | ||
- | | + | |
function generateMarkersFromGoogleGeoResult(response) | function generateMarkersFromGoogleGeoResult(response) | ||
{ | { | ||
// Was not able to locate any data: | // Was not able to locate any data: | ||
- | if (response == null || response.Status.code != 200) | + | if (response == null) |
{ | { | ||
- | | + | alert(" |
+ | return; | ||
} | } | ||
- | else | + | else if (response.Status.code == 602) |
{ | { | ||
- | | + | |
- | + | ||
- | for (var i = 0; i < places.length && i < max_geo_results; | + | |
{ | { | ||
- | | + | |
- | var point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); | + | return; |
+ | } | ||
- | | + | setTimeout(queryGoogleGeo, |
+ | return; | ||
+ | } | ||
+ | else if (response.Status.code != 200) | ||
+ | { | ||
+ | alert(" | ||
+ | return; | ||
+ | } | ||
- | | + | var places = response.Placemark; |
- | + place.AddressDetails.Country.CountryNameCode | + | |
- | )); | + | for (var i = 0; i < places.length && i < GMAPS_MAX_GEO_RESULTS; |
- | } | + | { |
+ | var place = places[i]; | ||
+ | var point = new GLatLng(place.Point.coordinates[1], | ||
+ | |||
+ | bounds.extend(point); | ||
+ | |||
+ | | ||
+ | + place.AddressDetails.Country.CountryNameCode | ||
+ | )); | ||
} | } | ||
Line 394: | Line 414: | ||
{ | { | ||
// Query recuresively other locations: | // Query recuresively other locations: | ||
- | queryGoogleGeo(map, | + | queryGoogleGeo(map, |
} | } | ||
}); | }); | ||
Line 404: | Line 424: | ||
function loadMaps() | function loadMaps() | ||
{ | { | ||
- | | + | |
- | var divNodes | + | var attrs = this.attributes; |
- | for (var i = 0; i < divNodes.length; | + | // Create a map: |
- | { | + | |
- | | + | |
- | { | + | |
- | var attrs = divNodes[i].attributes; | + | |
- | | + | |
- | | + | if (attrs.size.value == ' |
- | map.setCenter(new GLatLng(34, 0), 1); // default point | + | map.addControl(new GSmallMapControl()); |
+ | else if (attrs.size.value == ' | ||
+ | map.addControl(new GLargeMapControl()); | ||
- | | + | |
- | if (attrs.size.value == 'small') | + | if (attrs.control.value == 'hierarchical') |
- | map.addControl(new | + | map.addControl(new |
- | else | + | else if (attrs.control.value == 'all') |
- | | + | map.addControl(new |
- | map.addControl(new | + | |
- | | + | |
- | if (attrs.control.value == 'hierarchical') | + | if (attrs.overviewmap.value == 'true') |
- | | + | { |
- | | + | var overviewMap = new GOverviewMapControl(); |
- | map.addControl(new GMapTypeControl()); | + | |
+ | | ||
+ | } | ||
- | // mini-map in the bottom-right corner | + | |
- | if (attrs.overviewmap.value == ' | + | |
- | { | + | |
- | var overviewMap = new GOverviewMapControl(); | + | |
- | map.addControl(overviewMap); | + | |
- | overviewMap.hide(); | + | |
- | } | + | |
- | map.enableScrollWheelZoom(); | + | var locations = new Array(); |
- | | + | |
- | + | while (true) | |
- | | + | { |
- | while (true) | + | |
{ | { | ||
- | | + | break; |
- | { | + | |
- | | + | |
- | } | + | |
- | + | ||
- | locations[n] = attrs[' | + | |
- | n++; | + | |
} | } | ||
- | | + | locations[n] = attrs[' |
+ | n++; | ||
} | } | ||
- | | + | |
+ | queryGoogleGeo(map, | ||
+ | | ||
} | } | ||
// A special Wiki-wide function, defined in lib/ | // A special Wiki-wide function, defined in lib/ | ||
- | addInitEvent(loadMaps); | + | jQuery(loadMaps); |
- | </ | + | })();</ |
Line 481: | Line 493: | ||
</ | </ | ||
- | The latest source code snapshot | + | The latest source code can be taken from [[https:// |
+ | |||
+ | |||
+ | ===== Release History ===== | ||
+ | |||
+ | * 2008-03-17 (r05) --- Initial version. | ||
+ | * [[https://www.centurion.link/ | ||
+ | * [[https://www.centurion.link/w/_media/plugin/google_maps-2008-10-03.tar.bz2|2008-10-03 (r47)]] --- Plugin was refactored to allow formatting in comment. Also aligned in compliance with common practices how to process the flow. | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | |||
+ | ===== Bugs and ToDo ===== | ||
+ | Tested with IE 6.0 SP1, FF 3.5.x. No bugs at the moment. | ||
- | ===== ToDo ===== | + | There is nothing right now in my ToDo list. Please, add comment to this page. |
- | There is nothing right now in my ToDo list. Please, send your suggestions to [[dma_k@mail.ru|Dmitry Katsubo]]. | + | Question: |
+ | 1. Google API key should be placed | ||
+ | It doesn' | ||
plugin/google_maps.1344721949.txt.gz · Last modified: 2012-08-11 23:52 by 81.182.154.254