View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Nate Mueller > HTML-GoogleMaps-6 > HTML::GoogleMaps



Annotate this POD (1)


New  3
Open  0
View/Report Bugs
Module Version: 6   Source   Latest Release: HTML-GoogleMaps-10


HTML::GoogleMaps - a simple wrapper around the Google Maps API


  use HTML::GoogleMaps

  $map = HTML::GoogleMaps->new(key => $map_key);
  $map->center(point => "1810 Melrose St, Madison, WI");
  $map->add_marker(point => "1210 W Dayton St, Madison, WI");
  my ($head, $map_div, $map_script) = $map->render;


This version is not API compatable with HTML::GoogleMaps versions 1 and 2. The render method now returns three values instead of two.


HTML::GoogleMaps provides a simple wrapper around the Google Maps API. It allows you to easily create maps with markers, polylines and information windows. Thanks to Geo::Coder::Google you can now look up locations around the world without having to install a local database.


$map = HTML::GoogleMaps->new(key => $map_key);

Creates a new HTML::GoogleMaps object. Takes a hash of options. The only required option is key, which is your Google Maps API key. You can get a key at . Other valid options are:

height => height in pixels
width => width in pixels



Center the map at a given point.


Set the new zoom level (0 is corsest)

$map->controls($control1, $control2)

Enable the given controls. Valid controls are: large_map_control, small_map_control, small_zoom_control and map_type_control.


Enable or disable dragging.


Enable or disable info windows.


Set the map type. Either normal, satellite or hybrid. The v1 API map_type or satellite_type still work, but may be dropped in a future version.


Set the id of the map div

$map->add_icon(name => $icon_name, image => $image_url, shadow => $shadow_url, image_size => [ $width, $height ], shadow_size => [ $width, $height ], icon_anchor => [ $x, $y ], info_window_anchor => [ $x, $y ]);

Adds a new icon, which can later be used by add_marker. All args are required except for info_window_anchor.

$map->add_marker(point => $point, html => $info_window_html)

Add a marker to the map at the given point. If html is specified, add a popup info window as well. icon can be used to switch to either a user defined icon (via the name) or a standard google letter icon (A-J).

Any data given for html is placed inside a 350px by 200px div to make it fit nicely into the Google popup. To turn this behavior off just pass noformat => 1 as well.

$map->add_polyline(points => [ $point1, $point2 ])

Add a polyline that connects the list of points. Other options include color (any valid HTML color), weight (line width in pixels) and opacity (between 0 and 1).


Renders the map and returns a three element list. The first element needs to be placed in the head section of your HTML document. The second in the body where you want the map to appear. The third (the Javascript that controls the map) needs to be placed in the body, but outside any div or table that the map lies inside of.




Nate Mueller <>

syntax highlighting: