Page 1 of 1

Integrating Google Maps into contact form (Nice Hack)

Posted: Mon Jan 04, 2010 2:25 pm
by juanparati
For everybody that want integrate google maps into contact form.

1) Download and install Google maps plugin from http://extensions.joomla.org/extensions/1147/details
2) Generate the API key for use the Google maps plugins in http://code.google.com/intl/gl/apis/maps/signup.html
3) Add the API key in the plugin configuration and activate the plugin
4) Open the file administrator/components/com_contact/contact_items.xml and after this line:

Code: Select all

<param name="allow_vcard" type="radio" default="0" label="vCard" description="Show/Hide VCard">
			<option value="0">Hide</option>
			<option value="1">Show</option>
		</param>
Add this 3 lines:

Code: Select all

<param name="@spacer" type="spacer" default="" label="" description="" />
<param name="lat" type="text" defautl="" label="Latitud" description="Latitud en el mapa" />
<param name="lon" type="text" defautl="" label="Longitud" description="Longitud en el mapa" />
5) Copy the file components/com_contact/views/contact/tmpl/default_address.php to /templates/[your current template]/html/com_contact/contact/ (If the directories tree don't exist you must creat it)
6) Open the copied file /templates/[your current template]/html/com_contact/contact/default_address.php and add to end of file the next piece of code:

Code: Select all

<?php 
  if ( $this->contact->params->get('lat')!='' && $this->contact->params->get('lon')!='' ) {
    
    echo '<div class="mosmap">';
    
    $mosmap = &JTable::getInstance('contact');
    $mosmap->text="{mosmap lat='".$this->contact->params->get('lat')."'|lon='".$this->contact->params->get('lon')."'|height='200px'|width='100%'}";
    $dispatcher =& JDispatcher::getInstance();
    $params = & new JParameter('');
  
    JPluginHelper::importPlugin('content');
    $results = $dispatcher->trigger('onPrepareContent', array (& $mosmap, & $params, 0));
    
    echo $mosmap->text;
    
    echo '</div>';             
  }
?>
Now you can add a contact position directly from the contact form!! :pop
screen.png

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Mon Jan 04, 2010 5:46 pm
by babbardel
Nice tip. Many thanks

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Mon Jan 18, 2010 1:36 pm
by chosenannointed
I've made the changes to the files, and the options to add Longitude and Latitude appears like in the screenshot, but when I save it, it doesn't appear on the website itself.

page: http://www.ruthministries.co.za/index.p ... &Itemid=58

Any help would be really appreciated!

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Mon Jan 18, 2010 4:45 pm
by juanparati
Have you been activate the gmaps plugin?

You can see an example of the contact form with map in:
http://www.vallegranrey.es/turismo/es/i ... rismo.html

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Fri Jan 22, 2010 1:28 pm
by zonhal
Hi:
I follow all the instructions, but I don't see any map in the contact form.
I have a question, the plugin will take country and street from the contact form?
which field do I need to complete in the plugin, API key, what else?

I have multiple contact forms....

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Fri Jan 22, 2010 8:48 pm
by juanparati
You must activate the plugin and insert an api key from http://code.google.com/intl/es-ES/apis/maps/signup.html.

You must indicate the latitude and longitude in the new form fields (you have an example in previous post with a image).

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Fri Jan 22, 2010 9:19 pm
by zonhal
The pligin is activated, the API is withing the plugin configuration.
The issue is that I don't receive a new format, with the latitude and longitude.

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Fri Jan 22, 2010 10:42 pm
by zonhal
I already fixed my issue, I received in the contact form both fields.
But now when I try to open the contact form I received:
Table class JTableContact not found in file
What I need to do?

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Fri Feb 19, 2010 6:54 pm
by almeriateacher
Me too...
I get
Table class JTableContact not found in file

Come on whizz kids.. help an old man out

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Tue Feb 23, 2010 9:32 am
by juanparati
Ok,

I have the solution.

Replace:

Code: Select all

$mosmap = &JTable::getInstance('contact');
for

Code: Select all

$mosmap = new JObject();

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Tue Feb 23, 2010 9:58 pm
by almeriateacher
Cheers. That works great

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Thu Apr 22, 2010 6:33 pm
by todono
Thanks for your work

this is other method of plugin author:

http://tech.reumer.net/Google-Maps/Docu ... 1.5.x.html

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Fri Jul 23, 2010 11:59 am
by juanparati
Some persons report me a problems with PHP 5.3 and other issues

Here is the last version:

For everybody that want integrate google maps into contact form (Last version).

1) Download and install Google maps plugin from http://extensions.joomla.org/extensions/1147/details
2) Generate the API key for use the Google maps plugins in http://code.google.com/intl/gl/apis/maps/signup.html
3) Add the API key in the plugin configuration and activate the plugin
4) Open the file administrator/components/com_contact/contact_items.xml and after this line:
Code:
<param name="allow_vcard" type="radio" default="0" label="vCard" description="Show/Hide VCard">
<option value="0">Hide</option>
<option value="1">Show</option>
</param>

Add this 3 lines:
Code:
<param name="@spacer" type="spacer" default="" label="" description="" />
<param name="lat" type="text" defautl="" label="Latitud" description="Latitud en el mapa" />
<param name="lon" type="text" defautl="" label="Longitud" description="Longitud en el mapa" />


5) Copy the file components/com_contact/views/contact/tmpl/default_address.php to /templates/[your current template]/html/com_contact/contact/ (If the directories tree don't exist you must creat it)
6) Open the copied file /templates/[your current template]/html/com_contact/contact/default_address.php and add to end of file the next piece of code:

Code:

Code: Select all

<?php
  if ( $this->contact->params->get('lat')!='' && $this->contact->params->get('lon')!='' ) {
   
    echo '<div class="mosmap">';
   
    $mosmap = new JObject();
    $mosmap->text="{mosmap lat='".$this->contact->params->get('lat')."'|lon='".$this->contact->params->get('lon')."'|height='200px'|width='100%'}";
    $dispatcher =& JDispatcher::getInstance();
    $params = new JParameter('');
 
    JPluginHelper::importPlugin('content');
    $results = $dispatcher->trigger('onPrepareContent', array (& $mosmap, & $params, 0));
   
    echo $mosmap->text;
   
    echo '</div>';             
  }
?>
Now you can add a contact position directly from the contact form!! :pop

Image

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Thu Dec 23, 2010 10:51 am
by Ntelos
Could someone post a way that we can place the map below the contact image?

I saw that the code is at the mytemplate/html/contact/default.php and i try to write some code with no success.

The reason is because if you want to have an email form and the map then the webpage gets too long.

Thanks in advance

Re: Integrating Google Maps into contact form

Posted: Mon Jan 10, 2011 10:08 am
by sygeorgio
Can somebody pse tell me...where on earth do I find the file that the above refers to ie. administrator/components/com_contact/contact_items.xml ??

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Fri Jan 28, 2011 9:20 am
by rashmilakhotia
hey i am also suffering with the same problem:

"Table class JTableContact not found in file."
please help me out.
i eaven tried
$mosmap = &JTable::getInstance('contact');
instead of
$mosmap = new JObject();
but still getting the same problem..
please help me out asap

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Mon Apr 25, 2011 1:23 am
by Alejandro_09
Works fine for me, but I do have problems with using the contact image. It creates a lot of space between the title and the different contact labels. Is there any solution for it?

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Mon Apr 25, 2011 3:44 pm
by juanparati
Override the contact template or edit the CSS

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Sat May 28, 2011 11:02 pm
by Ntelos
How can we change the get directions language text on google maps using joomfish?

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Sun May 29, 2011 11:18 am
by juanparati
You can't!

You must access to the gmaps plugin options and there you can translate some texts like "Get Directions", "Address", etc.

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Sun Jul 24, 2011 11:24 am
by AnteKnez
Does anybody knows how to make this hack work on joomla 1.6/1.7, I made new topic in "Joomla! 1.7 / 1.6 Coding" http://forum.joomla.org/viewtopic.php?f=642&t=638757.

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Fri Aug 26, 2011 10:46 am
by alexia21
Nice tip. Many thanks

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Fri Aug 26, 2011 1:20 pm
by dadset
Works fine for me thank you very much

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Fri Sep 30, 2011 6:39 am
by Spirmy25
Oh. Many thanks for sharing such a good and useful information. That helped me to make my problem fixed!!!

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Wed Dec 05, 2012 11:05 am
by kinnarrk
Thank you so much for the help!!!

I don't know what was the problem but I had to remove the if condition in order to show the map.

But worked like a charm.

Thanks again. :D

Re: Integrating Google Maps into contact form (Nice Hack)

Posted: Sat Jun 22, 2013 5:44 pm
by segamarius
Thank you. Nice tip.