Google Maps in Products Module

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
zoltan
New Member
New Member
Posts: 4
Joined: Mon Feb 25, 2013 6:13 pm

Google Maps in Products Module

Post by zoltan »

Hi!

I want to integrate Google Maps in Products Module, but I don't know how can I do that.

I tried this method in Detail Template of Product Module, but it isn't work:
(I inserted the google API of course, and I tested it. It worked correctly in simple template.)

Code: Select all

<!-- Google Maps Declaration-->
        {literal}
        <__script__>
            $(document).ready(function(){
                 $('#map').googleMaps({
                    geocode: 'example str., city, zip code' // the attributes is only example for this post
                })
            });
        </__script>
        {/literal}
I know, if I'll place that code in HTML template, than Google Maps is working without any problem, but I want to use this script for "dynamic" content. When I'll create some Products Items, theese items will shows the location in Google Maps. How it?
I set some custom field in Field Definition, like as Street, City, Zip code and I want to integrate it into Google Maps script.

I tried this method in Detail template of Products Module. I thought it was working, but I have not succes.

Code: Select all

<!-- Google Maps Declaration-->
        {literal}
        <__script__>
            $(document).ready(function(){
                 $('#map').googleMaps({
                    geocode: '{if isset($entry->fields)}{foreach from=$entry->fields item='field'}{if $field->name == 'street'}{$field->value}{/if}{/foreach}{/if}, Fixed City, {if isset($entry->fields)}{foreach from=$entry->fields item='field'}{if $field->name == 'zipcode'}{$field->value}{/if}{/foreach}{/if}'
                })
            });
        </__script>
        {/literal}

<!-- The field names an examples for this post -Z.- -->
I think the jQuery isn't working in Templates of Products Module, but I could be wrong.

My question is, how can I integrate the Google Maps to Products Module with custom field calls (street, city, zip code is an custom fields)?
Sorry about my enlgish, and thank you so much for your helps!

Z.
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am

Re: Google Maps in Products Module

Post by applejack »

Try

Code: Select all

<!-- Google Maps Declaration-->
        {literal}
        <__script__>
            $(document).ready(function(){
                 $('#map').googleMaps({
                    geocode: '{/literal}{if isset($entry->fields)}{foreach from=$entry->fields item='field'}{if $field->name == 'street'}{$field->value}{/if}{/foreach}{/if}, Fixed City, {if isset($entry->fields)}{foreach from=$entry->fields item='field'}{if $field->name == 'zipcode'}{$field->value}{/if}{/foreach}{/if}{literal}'
                })
            });
        </__script>
        {/literal}

<!-- The field names an examples for this post -Z.- -->
Post Reply

Return to “Modules/Add-Ons”