Integrating Google Maps into contact form

For Joomla! 2.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Note: All 1.6, 1.7 and 3.5 releases have reached end of life and should be updated to 3.x.

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Locked
AnteKnez
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Wed Jul 01, 2009 7:27 pm
Location: Drniš, Croatia
Contact:

Integrating Google Maps into contact form

Post by AnteKnez » Sun Jul 24, 2011 10:14 am

Hi everybody i found tutorial on how to integrate google maps on joomla contct form http://forum.joomla.org/viewtopic.php?f=304&t=474910 , hack uses google maps plugin and changes contact form frontend and backend page/files, but hack is for joomla 1.5 can some of you width bigger knowledge in joomla framework make joomla 1.6/1.7 version, big thanks in advance.

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

Post by AnteKnez » Mon Jul 25, 2011 10:21 am

Latest google maps in contact solution from previous mentioned topic:
juanparati wrote: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
Please help me, what is correspondent file in joomla 1.6 for "administrator/components/com_contact/contact_items.xml", and will dis 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>';             
  }
?>
work in joomla 1.6?

cernekj
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Jan 26, 2012 3:35 pm

Re: Integrating Google Maps into contact form

Post by cernekj » Thu Jan 26, 2012 3:52 pm

Hi,
steps 1), 2), 3) are the same.
4) File "administrator/components/com_contact/models/forms/contact.xml" line 328
Behind:

Code: Select all

<fields name="params">
	<fieldset name="jbasic"
		label="JGLOBAL_FIELDSET_DISPLAY_OPTIONS"
		>
Add FIELDS (not params):

Code: Select all

<field name="lat" type="text" label="Latitude" description="Map Latitude" />
<field name="lon" type="text" label="Longitude" description="Map Longitude" />
5) the same.
6) Add to "templates/[your current template]/html/com_contact/contact/default_address.php" this code:

Code: Select all

<?php
	if ( $this->contact->params->get('lat')!='' && $this->contact->params->get('lon')!='' ) {
		$html = '<div class="mosmap">'
					.'{mosmap lat='".$this->contact->params->get('lat')."'|lon='".$this->contact->params->get('lon')."'|height='200px'|width='100%'}"'
					.'</div>';
		echo JHTML::_('content.prepare', $html);
	}
?>

User avatar
ismadman
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Thu Nov 04, 2010 3:42 am

Re: Integrating Google Maps into contact form

Post by ismadman » Wed Feb 22, 2012 10:38 am

Why hack the code?
Why not just create a custom html module through module manager
Assign it to your contact page ( menu item ) in a position like sidebar a
That way you can use your default settings in Mikes google maps plugin
or just throw something like his example in the html box

Code: Select all

{mosmap width='400'|height='400'|lat='52.052312'|lon='4.447141'|zoom='3'|mapType='Satellite'|text='sv DWO'|tooltip='DWO'|marker='1'|align='center'}


This soultion is easy simple with no hacks
Works for me great

User avatar
cpetitclerc73
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Fri May 27, 2011 10:08 pm
Location: Calgary, Alberta, Canada
Contact:

Re: Integrating Google Maps into contact form

Post by cpetitclerc73 » Sun Jul 29, 2012 1:55 am

Yes. That is the best solution. Create a new Custom HTML module and apply it to the contact us page. Paste in the Google map iframe code from Google maps.


Locked

Return to “Joomla! 2.5 Coding”