Integrating Google Maps into contact form (Nice Hack)

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Locked
User avatar
juanparati
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 123
Joined: Thu Nov 08, 2007 6:00 pm
Location: Aarhus (Denmark)

Integrating Google Maps into contact form (Nice Hack)

Post by juanparati » Mon Jan 04, 2010 2:25 pm

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
You do not have the required permissions to view the files attached to this post.
From the code to the reality!

babbardel
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Tue Nov 24, 2009 10:44 pm

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

Post by babbardel » Mon Jan 04, 2010 5:46 pm

Nice tip. Many thanks
Jocuri Online Sport Gratuite - http://www.curteascolii.ro

Signature rules: Literal URLs only - http://forum.joomla.org/viewtopic.php?f=8&t=65

chosenannointed
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Mon Jan 18, 2010 1:04 pm

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

Post by chosenannointed » Mon Jan 18, 2010 1:36 pm

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!

User avatar
juanparati
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 123
Joined: Thu Nov 08, 2007 6:00 pm
Location: Aarhus (Denmark)

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

Post by juanparati » Mon Jan 18, 2010 4:45 pm

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
From the code to the reality!

zonhal
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Sat May 30, 2009 12:42 pm

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

Post by zonhal » Fri Jan 22, 2010 1:28 pm

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....

User avatar
juanparati
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 123
Joined: Thu Nov 08, 2007 6:00 pm
Location: Aarhus (Denmark)

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

Post by juanparati » Fri Jan 22, 2010 8:48 pm

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).
From the code to the reality!

zonhal
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Sat May 30, 2009 12:42 pm

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

Post by zonhal » Fri Jan 22, 2010 9:19 pm

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.

zonhal
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Sat May 30, 2009 12:42 pm

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

Post by zonhal » Fri Jan 22, 2010 10:42 pm

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?

almeriateacher
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sat Jan 23, 2010 10:01 am

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

Post by almeriateacher » Fri Feb 19, 2010 6:54 pm

Me too...
I get
Table class JTableContact not found in file

Come on whizz kids.. help an old man out

User avatar
juanparati
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 123
Joined: Thu Nov 08, 2007 6:00 pm
Location: Aarhus (Denmark)

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

Post by juanparati » Tue Feb 23, 2010 9:32 am

Ok,

I have the solution.

Replace:

Code: Select all

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

Code: Select all

$mosmap = new JObject();
From the code to the reality!

almeriateacher
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sat Jan 23, 2010 10:01 am

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

Post by almeriateacher » Tue Feb 23, 2010 9:58 pm

Cheers. That works great

todono
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Thu Apr 22, 2010 6:23 pm

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

Post by todono » Thu Apr 22, 2010 6:33 pm

Thanks for your work

this is other method of plugin author:

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

User avatar
juanparati
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 123
Joined: Thu Nov 08, 2007 6:00 pm
Location: Aarhus (Denmark)

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

Post by juanparati » Fri Jul 23, 2010 11:59 am

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
From the code to the reality!

Ntelos
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 221
Joined: Thu Aug 28, 2008 8:15 am

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

Post by Ntelos » Thu Dec 23, 2010 10:51 am

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

sygeorgio
Joomla! Intern
Joomla! Intern
Posts: 65
Joined: Thu Dec 30, 2010 7:01 am

Re: Integrating Google Maps into contact form

Post by sygeorgio » Mon Jan 10, 2011 10:08 am

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 ??

rashmilakhotia
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Fri Jan 28, 2011 9:10 am

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

Post by rashmilakhotia » Fri Jan 28, 2011 9:20 am

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

Alejandro_09
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Sat Jan 03, 2009 1:09 pm

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

Post by Alejandro_09 » Mon Apr 25, 2011 1:23 am

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?

User avatar
juanparati
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 123
Joined: Thu Nov 08, 2007 6:00 pm
Location: Aarhus (Denmark)

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

Post by juanparati » Mon Apr 25, 2011 3:44 pm

Override the contact template or edit the CSS
From the code to the reality!

Ntelos
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 221
Joined: Thu Aug 28, 2008 8:15 am

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

Post by Ntelos » Sat May 28, 2011 11:02 pm

How can we change the get directions language text on google maps using joomfish?

User avatar
juanparati
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 123
Joined: Thu Nov 08, 2007 6:00 pm
Location: Aarhus (Denmark)

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

Post by juanparati » Sun May 29, 2011 11:18 am

You can't!

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

AnteKnez
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Wed Jul 01, 2009 7:27 pm
Location: Drniš, Croatia
Contact:

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

Post by AnteKnez » Sun Jul 24, 2011 11:24 am

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.

alexia21
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Fri Aug 26, 2011 10:40 am
Contact:

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

Post by alexia21 » Fri Aug 26, 2011 10:46 am

Nice tip. Many thanks

dadset
I've been banned!
Posts: 25
Joined: Wed Aug 03, 2011 1:02 pm

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

Post by dadset » Fri Aug 26, 2011 1:20 pm

Works fine for me thank you very much

Spirmy25
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Fri Sep 30, 2011 6:36 am
Contact:

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

Post by Spirmy25 » Fri Sep 30, 2011 6:39 am

Oh. Many thanks for sharing such a good and useful information. That helped me to make my problem fixed!!!

kinnarrk
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Thu Sep 30, 2010 8:14 pm

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

Post by kinnarrk » Wed Dec 05, 2012 11:05 am

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

segamarius
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sat Jul 24, 2010 1:59 pm

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

Post by segamarius » Sat Jun 22, 2013 5:44 pm

Thank you. Nice tip.
Sursa ta de jocuri bune! - http://www.gameway.ro


Locked

Return to “Joomla! 1.5 Coding”