• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: [solved] How to combine CG Google Maps with Company Directory & Postcode
PostPosted: Fri Apr 30, 2010 9:04 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Apr 15, 2010 12:27 am
Posts: 218
Location: Georgia
Hello CMSMSers,

I am wanting a way for users to search by zip code and find the closest business to their zip. I was informed to use Company Directory & Postcode in conjunction with CG Google Maps. However, there is a problem. . . Me.

I am a novice when it comes to CMSMS and don't fully comprehend it's capabilities. Can someone help instruct me on how to do so? I don't need anything elaborate, I just want want it to basically function EXACTLY like www.easylocator.net . Simple sidebar with search and shows closest results, and map on the side.

Please help!


Last edited by michaywood on Thu May 06, 2010 2:40 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: How to combine CG Google Maps with Company Directory & Postcode
PostPosted: Mon May 03, 2010 4:40 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Apr 15, 2010 12:27 am
Posts: 218
Location: Georgia
So, either no one knows how to do this or no one is willing to share how to do this? If so, how much would it cost to get this done?


Top
 Profile  
 
 Post subject: Re: How to combine CG Google Maps with Company Directory & Postcode
PostPosted: Tue May 04, 2010 7:49 pm 
Offline
Power Poster
Power Poster

Joined: Mon Apr 14, 2008 8:55 am
Posts: 308
Location: Notodden, Norway
Hi

I have waiting a while for some extra functionality in CGGoogleMaps to accomplish this for my own maps.
(But I must admit I haven't requested it either. Hoped I didn't have to write it myself.)
All is perfect except from one small problem. There is no parameter in this module to center the map dynamically.

Therefore it is problematic to center the map dynamically based on either zip codes or Geo Location based on users host address (which i prefer) which is essential to achieve this.

JanB

_________________
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.


Top
 Profile  
 
 Post subject: Re: How to combine CG Google Maps with Company Directory & Postcode
PostPosted: Tue May 04, 2010 9:09 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Apr 15, 2010 12:27 am
Posts: 218
Location: Georgia
Well can you at least help instruct me on how to hook company directory with cg google maps?

I just learned how to add Postcode Lookup by just putting by module tag as {Company Directory action='search'} so I can search within a certain radius, but I don't know how to link company directory results to cg google maps.

Any suggestions?

CMS Version 1.6.7
PHP 5.2.1
MySQL 5.0.32


Top
 Profile  
 
 Post subject: Re: How to combine CG Google Maps with Company Directory & Postcode
PostPosted: Tue May 04, 2010 9:30 pm 
Offline
Power Poster
Power Poster

Joined: Mon Apr 14, 2008 8:55 am
Posts: 308
Location: Notodden, Norway
Ok

First of all, it is important to use at least zip and city for each company entry in Directory.
The result of the search is using Summary, so open the default summary template in Company Director.
(or make a new one, and mark it default for now)

At the end of the template, just before {/foreach} add the CG Dynpoint tag, and after the foreach tag add CGGoogleMaps tag.
Like this: (Do not add an extra  {/foreach} )

{cggm_add_dynpoint map="1" name=$entry->company_name address=$entry->address}
{/foreach}
{CGGoogleMaps map="1"}

_________________
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.


Top
 Profile  
 
 Post subject: Re: How to combine CG Google Maps with Company Directory & Postcode
PostPosted: Wed May 05, 2010 1:31 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Apr 15, 2010 12:27 am
Posts: 218
Location: Georgia
Great! This shows the map when something is clicked on! Wonderful! Besides the Lat/Long problem I'm having (put into another post) I would love to see how to get this better fit to my page. I attached a picture of my webpage content area. I have a FIXED page size (fixed to the red box size), so it's a problem with the map showing up below the result after the postcode because it goes outside of the box size. My layout is 2 columns, a left one that is {content block="left"} and the right which is {content} . Is it possible for just the postcode lookup and company directory info to show up in the left column and the map change in the other column respectively? I read somewhere that the map can't change dynamically when you click on a location. Is this also true?

Thanks for the help!


NOTE: In the attached image, the map point and address on the left don't match. this is cause I just quickly did this in photoshop to display what I am after design-wise.


Attachments:
mockupmap.jpg
mockupmap.jpg [ 49.59 KiB | Viewed 1508 times ]
Top
 Profile  
 
 Post subject: Re: How to combine CG Google Maps with Company Directory & Postcode
PostPosted: Wed May 05, 2010 3:21 pm 
Offline
Power Poster
Power Poster

Joined: Mon Apr 14, 2008 8:55 am
Posts: 308
Location: Notodden, Norway
Hi

I have couple of ideas regarding this, but want to test it first.
I don't have time just now, but probably during the day.

JanB

_________________
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.


Top
 Profile  
 
 Post subject: Re: How to combine CG Google Maps with Company Directory & Postcode
PostPosted: Wed May 05, 2010 10:46 pm 
Offline
Power Poster
Power Poster

Joined: Mon Apr 14, 2008 8:55 am
Posts: 308
Location: Notodden, Norway
Ok, so here we go..

I have tested, tested and tested again, and it was not so simple as I expected :)
..but who gives up?

First of all, we have to fix a couple of bugs.

In CGGoogleMaps there is a bug preventing us to specify a map template.
http://dev.cmsmadesimple.org/bug/view/3545

The other one is for centering the map.
http://forum.cmsmadesimple.org/index.ph ... 803.0.html

What I intend to do is:

Show the CGGoogleMaps Sidebar in the left column showing the result of the Company Directory Search
(..and NOT showing the normal output from Company Directory)
Show the CGGoogleMaps Map in the right column (content).

Don't forget to turn on "Show Sidebar" and "Show Info Window" in the map.
I have put some Directory info into the Info Window, only as a proposal for how this can be done.

Happy coding :)


Company Directory:

Make a new summary template and name it ex. cgmap

Code:

{if isset($catformstart)}
{$catformstart}
{$catdropdown}{$catbutton}
{$catformend}
{/if}

{if isset($messages)}
<div class="CompanyDirectoryMessage">
 <ul>
   {foreach from=$messages item='one'}
     <li>{$one}</li>
   {/foreach}
 </ul>
</div>
{/if}

{if isset($errors)}
<div class="CompanyDirectoryError">
 <ul>
   {foreach from=$errors item='one'}
     <li>{$one}</li>
   {/foreach}
 </ul>
</div>
{/if}


{if isset($items)}


  {foreach from=$items item=entry}

{assign var='company_name' value = $entry->company_name}
{assign var='address' value = $entry->address}
{assign var='telephone' value = $entry->telephone}
{assign var='website' value = $entry->website}
{assign var='details' value = $entry->details}

{assign var='description' value = "
<b>`$company_name`</b><br />
`$address`<br />
Phone: `$telephone`<br />
<a href='`$website`'>`$website`</a><br /><br />
`$details`"}

{cggm_add_dynpoint map="1" name=$entry->company_name address=$entry->address  description=$description}
  {/foreach}

{/if}




CGGoogleMaps:

Add a new map template and name it: directory_map
The only thing I have changed in this template is the google_map_sidebar tag (commented it out)

Code:

{* map template *}
{$google_map_header}

{*
<!-- necessary for google maps polyline drawing in IE -->
{literal}
<style type="text/css">
v\:* {
 behavior:url(#default#VML);
}
{/literal}
</style>
*}

<!-- begin display map -->
<table>
  <tr>
     <td>{$google_map}</td>
{*     <td>{$google_map_sidebar}</td>*}
  </tr>
</table>
{$map_description}
{$google_map_js}
<!-- end display map -->



Create another map template an name it directory_sidebar

Code:

{$google_map_header}
<div style="display:none">{$google_map}</div>
<div style="line-height:15px;">{$google_map_sidebar}</div>
{$google_map_js}



Page content:

Sidebar:

Code:

{CompanyDirectory action="search" inline="1" summarytemplate="cgmap"}
{CGGoogleMaps map="1" maptemplate="directory_sidebar"}



Content:

Code:

{CGGoogleMaps map="1" maptemplate="directory_map"}



Hope this can be useful..

JanB

_________________
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.


Last edited by janb on Wed May 05, 2010 11:35 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: [solved] Re: How to combine CG Google Maps with Company Directory & Postcode
PostPosted: Thu May 06, 2010 2:40 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Apr 15, 2010 12:27 am
Posts: 218
Location: Georgia
[solved!!!!!!!]

Perfect, janb! Thank you so much for that OUTSTANDING help! Hopefully this can help other users as well and hope you benefited from it as well. Again, thank you so very much for your outstanding knowledge!

Thank you,
Michaywood


Top
 Profile  
 
 Post subject: Re: [solved] How to combine CG Google Maps with Company Directory & Postcode
PostPosted: Thu May 06, 2010 3:02 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Apr 15, 2010 12:27 am
Posts: 218
Location: Georgia
Ok. so now after going through some initial testing, the layout is working PERFECTLY. Sidebar staying on the side and when you click on a link, it goes to its marker on the map. very cool! Only thing is no matter what zip code I put in, it pulls up ALL the addresses in the Company Directory module. I went in and gave all my locations lat/long coordinates to make sure they had the most information possible, and all the results still show up on the map, no matter what. Is there something in the search that could be missing?


Top
 Profile  
 
 Post subject: Re: [solved] How to combine CG Google Maps with Company Directory & Postcode
PostPosted: Thu May 06, 2010 6:05 am 
Offline
Power Poster
Power Poster

Joined: Mon Apr 14, 2008 8:55 am
Posts: 308
Location: Notodden, Norway
Hi

Found a couple of bugs in Company Director. (Fixed in SVN Rev.146)

In action.do_search.php

Line 37 (this should fix the Zip filtering)

Code:
$postcode = cge_utils::get_module('PostCode');


Change to:

Code:
$postcode = cge_utils::get_module('Postcode');


Line 236

Code:
     if( empty($errors) && $cd_units == 'km' )


Change to:

Code:
     if( empty($errors) && $units == 'km' )


JanB

_________________
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.


Last edited by janb on Fri May 07, 2010 6:50 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: [solved] How to combine CG Google Maps with Company Directory & Postcode
PostPosted: Thu May 06, 2010 10:02 am 
Offline
Power Poster
Power Poster

Joined: Mon Apr 14, 2008 8:55 am
Posts: 308
Location: Notodden, Norway
Hi

Did some investigation using GeoLocation Services and got it to work quite well :)
..as an alternative to Zip search.

First of all I created an UDT (User Defined Tag) with the link to the provider i want to use (in this example www.geoplugin.net)
Then I do a lookup based on my official IP-address and store the result (City and Country) in a smartytag (MyGeoLocationCity) and the Lat/Lon pairs for centering the map (MyGeoLocationLatLon) for later use.

Here is the UDT:

Code:
$GeoLocation = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$_SERVER['REMOTE_ADDR']));
$smarty->assign('MyGeoLocationCity',$GeoLocation['geoplugin_city'].','.$GeoLocation['geoplugin_countryCode']);
$smarty->assign('MyGeoLocationLatLon',$GeoLocation['geoplugin_latitude'].','.$GeoLocation['geoplugin_longitude']);


Then I made a new Company Directory SearchTemplate and named it GeoSearch.
On the top of the template i am calling my UDT {GeoLocation}

And further down in the document i do a address lookup based on my geographical location.

Here is my Search Template:

Code:

{GeoLocation}

<div id="cd_searchform">
{$formstart}

<div class="row">
<p>Search for Companies in my Area: ({$MyGeoLocationCity})</p>
<input type="hidden" name="{$actionid}cd_address" value={$MyGeoLocationCity}/>
</div>

<div class="row">
  <p class="col30">{$mod->Lang('radius')}</p>
  <p class="col70">
    <select name="{$actionid}cd_radius">
      <option value="10">10</option>
      <option value="25">25</option>
      <option value="50">50</option>
      <option value="100">100</option>
    </select>
    <input type="hidden" name="{$actionid}cd_units" value="miles"/>
  </p>
</div>

{if isset($categories)}
<div class="row">
  <p class="col30">{$mod->Lang('categories')}</p>
  <p class="col70">
    {capture assign='tmp'}{$actionid}cd_use_categories{/capture}
    {html_checkboxes name=$tmp options=$categories separator='<br/>'}
  </p>
</div>
{/if}

<div class="row">
  <p class="col30"></p>
  <p class="col70">
    <input type="submit" name="{$actionid}cd_submit" value="{$mod->Lang('submit')}"/>
  </p>
</div>
{$formend}
</div>




Then, instead of using the default search template, specify the new template like this;
(As a replacement to the tag in the sidebar made earlier)

Code:
<p>{CompanyDirectory action="search" inline="1" summarytemplate="cgmap" searchformtemplate="GeoSearch"}</p>


(Update)
One more thing I forgot. I added some modification to the directory_map template to center the map.
This is better than modifying the original code.
Code:

{GeoLocation}

{* map template *}
{$google_map_header}

{*
<!-- necessary for google maps polyline drawing in IE -->
{literal}
<style type="text/css">
v\:* {
 behavior:url(#default#VML);
}
{/literal}
</style>
*}

<!-- begin display map -->
<table>
  <tr>
     <td>{$google_map}</td>
{*     <td>{$google_map_sidebar}</td>*}
  </tr>
</table>
{$map_description}
{$google_map_js}

<script type="text/javascript">
{literal}
    map.setCenter(new GLatLng({/literal}{$MyGeoLocationLatLon}{literal}));
{/literal}
</script>

<!-- end display map -->



Setting CGGoogleMaps map option Zoom Encompass to "Yes" will auto zoom the map to contain all Companies within the selected radius

JanB

_________________
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.


Last edited by janb on Thu May 06, 2010 11:01 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: [solved] How to combine CG Google Maps with Company Directory & Postcode
PostPosted: Thu May 06, 2010 1:10 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Apr 15, 2010 12:27 am
Posts: 218
Location: Georgia
janb wrote:
Hi

Found a couple of bugs in Company Director.

In action.do_search.php

Line 37 (this should fix the Zip filtering)

Code:
$postcode = cge_utils::get_module('PostCode');


Change to:

Code:
$postcode = cge_utils::get_module('Postcode');


Line 236

Code:
     if( empty($errors) && $cd_units == 'km' )


Change to:

Code:
     if( empty($errors) && $units == 'km' )


JanB


I did these changes, and now, no matter what zipcode I put it it spits back the message "Could not find any information for postal/zip code 'xxxxx' " (X's just represent the zipcode)

I'll give your UDT a try and see if that one might work. Thanks for all the help!


Top
 Profile  
 
 Post subject: Re: [solved] How to combine CG Google Maps with Company Directory & Postcode
PostPosted: Thu May 06, 2010 1:35 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Apr 15, 2010 12:27 am
Posts: 218
Location: Georgia
JanB,

I gave your UDT setup a try, and it didn't work :( . I attached a screen shot below of what my page ended up looking like. I couldn't really even test it, cause it wouldn't give me a search bar to put in a zip code. For the right content area I also just put a map image as the background for the DIV so it isn't just white space on the right before the map appears after searching. We're getting so close!!


Top
 Profile  
 
 Post subject: Re: [solved] How to combine CG Google Maps with Company Directory & Postcode
PostPosted: Thu May 06, 2010 3:16 pm 
Offline
Power Poster
Power Poster

Joined: Mon Apr 14, 2008 8:55 am
Posts: 308
Location: Notodden, Norway
Something isn't as it should be at your host.
Can you try on thing.

At the end of the UDT, can you enter the following text:

print_r($GeoLocation);

..and tell me what the output says.
It should appear at the top of your page.

JanB

_________________
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting