++ed by:
1 non-PAUSE user
Author image Lee Johnson


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

Build Status Coverage Status




  use HTML::GoogleMaps::V3

  $map = HTML::GoogleMaps::V3->new;
  $map->center("1810 Melrose St, Madison, WI");
  $map->add_marker(point => "1210 W Dayton St, Madison, WI");
  $map->add_marker(point => [ 51, 0 ] );   # Greenwich

  my ($head, $map_div) = $map->onload_render;


This module is forked from HTML::GoogleMaps and updated to use V3 of the API. Note that the module isn't quite a drop in replacement, although it should be trivial to update your code to use it.

Note that V3 of the API does not require an API key, however you can pass one and it will be used (useful for analytics).

Also note that this library only implements a subset of the functionality available in the maps API, if you want more then raise an issue or create a pull request.


HTML::GoogleMaps::V3 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::V3->new;

Creates a new HTML::GoogleMaps::V3 object. Takes a hash of options. Valid options are:

api_key => key (your Google Maps API key)
height => height (in pixels or using your own unit)
width => width (in pixels or using your own unit)
z_index => place on z-axis (e.g. -1 to ensure scrolling works)
geocoder => an object such as Geo::Coder::Google



Center the map at a given point. Returns 1 on success, 0 if the point could not be found.


Set the new zoom level (0 is corsest)


Enable or disable dragging.


Enable or disable info windows.


Set the id of the map div


Set the map type. Either normal, satellite, road, or hybrid.

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

Add a marker to the map at the given point. A point can be a unique place name, like an address, or a pair of coordinates passed in as an arrayref: [ longitude, latitude ]. Will return 0 if the point is not found and 1 on success.

If html is specified, add a popup info window 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). Will return 0 if the points are not found and 1 on success.


Renders the map and returns a two 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. You will also need to add a call to html_googlemaps_initialize() in your page's onload handler. The easiest way to do this is adding it to the body tag:

    <body onload="html_googlemaps_initialize()">




This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. If you would like to contribute documentation, features, bug fixes, or anything else then please raise an issue / pull request:



Nate Mueller <nate@cs.wisc.edu> - Original Author

Lee Johnson <leejo@cpan.org> - Maintainer of this fork

Nigel Horne - Contributor of several patches