/*
    This file is part of Inova Google Maps Zimlet (Inova Maps).

    Inova Maps is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Inova Maps is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Inova Maps.  If not, see <http://www.gnu.org/licenses/>.

        Authors:
                Bruno Santos, Inova Tecnologias Ltda.
                Marcelo Bezerra, Inova Tecnologias Ltda.
*/

Inova Google Maps Zimlet

* Introduction

This Zimlet brings Google Maps to your ZCS installation. Previously, deployment of a Google Maps zimlet was complicated by the requirement of a Google API key. A Google API key is required for each hostname. This zimlet provides a mechanism through which a Google API can be provided. The mechanism further permits multiple API keys, enabling deployment of this Zimlet in multi-domain ZCS installations (ex. hosted Zimbra).


* Installing The Inova Google Maps Zimlet

Installation is pretty simple, just do it as you would for any Zimlet.
Log into the admin panel, navigate to Zimlet, click deploy and pick the file.

That's it.

* Getting a Google API Key for your domain

Getting a Google Maps API key is simple and fast.

Just go to http://code.google.com/apis/maps/signup.html,
read the aggrement and if you agree, enter your Zimbra public hostname on the url.

For exemple, if you access your Zimbra server using a url like: http://zimbra.mydomain.com/zimbra, enter http://zimbra.mydomain.com as your website URL in Zimbra.

You will need a google account for this to work.

Now, save the key as you will need it.

If you have multiple public hostnames, repeat this step for all of them.

* Setting up Inova Google Maps Zimlet

Setup is quite simple.
You will need a mysql database.

You need to create a new database and grant permission so that the Zimlet will have access to it.

Create the table we will use to save the API keys:

CREATE TABLE `keymap` (
  `host` varchar(255) NOT NULL,
  `apiKey` varchar(255) NOT NULL,
  PRIMARY KEY  (`host`)
);

Now use the keys you have saved:
For each key you created, you should insert an entry in the table, like this:

INSERT INTO `keymap` (`host`, `apiKey`) VALUES ('zimbra.mydomain.com', 'yourkey');

Now it's time to configure the Zimlet so it knows where the database is.

Create a file with the following lines and replace the values for dbhost, dbuser, dbpass, dbname and baseCountry

<zimletConfig name="Net_Inova_GMaps" version="1.0">
	<global>
		<property name="allowedDomains">*.google.com,*.inova.com.br,*.inova.net</property>
		<property name="dbhost">Enter the IP address of yout mysql server here</property>
		<property name="dbuser">Enter the user name for your mysql server here</property>
		<property name="dbpass">Enter the password for your mysql server here</property>
		<property name="dbname">Enter the database name for your mysql server here</property>
		<property name="baseCountry">br</property>
		<property name="markerIcon">http://maps.google.com/intl/en_ALL/mapfiles/marker.png</property>
		<property name="markerIconW">20</property>
		<property name="markerIconH">34</property>
		<property name="markerIconAnchorX">13</property>
		<property name="markerIconAnchorY">35</property>
	</global>
</zimletConfig>


Now tell Zimbra this is the config file for net_inova_gmaps zimlet.

Upload the file to a mailbox server and use the following command:

zmzimletctl configure config.xml net_inova_gmaps

Now, all you need to do is test it.

Send yourself an e-mail with an address and mouse over it!

