User:Nitobus/div.GoogleMap

div.GoogleMap is a block control that allows to display the Google Maps in Wikipedia, as well as to draw markers and tracks on maps. Script that provides  functionality, is located at User:Nitobus/div.GoogleMap.js. To use the  control you must install the script by adding the following line of code:

to your custom JavaScript file (common.js) at Preferences/Appearance. After saving the common.js file you have to bypass browser’s cache (Key Ctrl + F5 or Key Ctrl + R). All of the examples on this page will also be operable only after editing and saving common.js file.

Google Maps Usage Limits and Licensing
Google Maps is a set of applications provided by Google that are based on the free web mapping service to display maps and satellite images of the Earth. In addition to the web mapping service Google provides the technology of maps embedding on third-party web sites via Google Maps JavaScript API v3. Commercial websites is permitted using Google Maps JavaScript API to generate up to 25 000 map loads per day, in case of exceeding this value one must purchase a Google Maps API license. Non-profit organizations, which include the site owner Wikipedia Wikimedia Foundation, are exempt from Google Maps JavaScript API usage limits.

Examples
To display Google Maps in Wikipedia article,  tag with the   class should be used. It should be noted, despite the Google Maps JavaScript API technology provides wide opportunities to access and work with maps, a script that provides the functionality of the  control uses only a small part of these possibilities namely display maps or satellite images, drawing markers on the map, drawing tracks on the map. Below are a few examples of the use of these opportunities.

Example 1. A simple example
Adding  class to the   element displays a map of the world. Attribute  defines the width and height of rectangle to be allocated by map. All the standard features of Google Maps (scrolling, zooming, map/satellite type switching) are available in map displayed. Result: Map of the world.

Example 2. Zoom, centering and map type
To choose the display parameters of the map, one should place the  element inside the   element. element determines the properties of the map displayed. Consider the following example. Attribute value  of the   element defines the zoom of the map. A value of 0 corresponds to the lowest zoom level (world map), the value of 20 – to the largest. If this attribute is omitted, the default value is 0. Attributes values  of the   element define the coordinates (latitude and longitude) of the center of the map. If these attributes are omitted, the default values are 0. Attribute value  of the   element specifies the map type that can be one of four types:
 * ROADMAP - road map.
 * SATELLITE - satellite image.
 * HYBRID – mixture of road map and satellite image.
 * TERRAIN - map with terrain information.

If this attribute is omitted, the default value is ROADMAP. Result: Moscow, center.

Example 3. Adding marker on the map
To add a marker on the map, one should place the  element inside the   element. element creates the marker. The number of markers ( elements) on the map is not limited. Consider the same example with the addition of one marker in the center of the map. Attribute values  of the   element defines the coordinates (latitude and longitude) of the marker. Note, in this example coordinates of marker are in the "degrees"."minutes"."seconds"."decimals of second" format, while map center coordinates are in the "degrees"."decimals of degrees" format. Generally, both of these formats are allowed for any object’s coordinates, format with one decimal point will be interpreted as "degrees"."decimals of degrees" and format with two or three decimal points will be interpreted as "degrees"."minutes"."seconds"."decimals of second". Attribute value  of the   element specifies the name of the marker and will be displayed when placing mouse over the marker. Result: The Moscow Kremlin.

Example 4. Adding track on the map
Track is a sequence of points on the map, connected by a line. To add a track on the map, one should place the  element inside the   element and a set of   elements, defining track points, inside the   element. element does not require the attributes, while  element s requireis   and   attributes, that already described above. The number of tracks on the map ( elements) and the number of points in each track (  elements) are not limited. Consider an example illustrating a display of multiple markers and one track on the map. In this example, markers are placed at the coordinates of Koltsevaya Line stations of the Moscow subway. Track consists of the points with the same coordinates, and thus connects the subway stations by the line. You should also pay attention to the value of the  attribute of the   element in this example. The value of -1 means that zoom and centering of the map will be calculated automatically to best fit all required markers and tracks. It is clear that in this case  and   attributes of the   element are ignored. Result: The Moscow subway, Koltsevaya line.

Example 5. Displaying a large amount of information
Here is an example of multiple tracks that define the administrative boundaries of Moscow and its administrative districts, with the total number of track points displayed is about 20 thousand. This example does not show any new functionality, but designed only to demonstrate the possibility of displaying a very large amount of information on the map. Since the mapping of such number of points may cause some delay, this example is given on a separate page. Map boundaries of administrative districts of Moscow