solved Will a ujGooglemaps map appear in a SiteBuilder panel?

iamtimbo
@iamtimbo
9 years ago
301 posts
Hi Steve,

Apologies if this turns out to be my slow learning. I'm trying to create a ujGooglemaps multi-item map in a SiteBuilder panel showing all profiles with a certain value in a custom profile_county (e.g. Dorset) field.

I keep failing but it's crossed my mind that a ujGooglemaps map can't exist there at all - is that the case?
updated by @iamtimbo: 03/25/15 07:43:58AM
SteveX
SteveX
@ultrajam
9 years ago
2,583 posts
I have absolutely no idea about site builder I'm afraid, I have never even installed it and don't kow how it works.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
iamtimbo
@iamtimbo
9 years ago
301 posts
You can't say fairer than that!
iamtimbo
@iamtimbo
9 years ago
301 posts
Just to help me narrow down, this should work (it does elsewhere!), correct? This is from the beginning of item_list.tpl in the profile module:

____________________________________________________________________

{if isset($_items)}

{ujGoogleMaps_map module="jrCore" name="countywide" map=$_items height="300" width="100%" lat={$profile_latitude} lng={$profile_longitude} zoom="15" map_type=hybrid}

{foreach from=$_items item="item"}


____________________________________________________________________

Profile_latitude and profile_longitude already exist in each profile's entry, and according to the debug console are available for use in this call....
SteveX
SteveX
@ultrajam
9 years ago
2,583 posts
If you have mappable data in the $_items array you probably don't want lat and lng parameters as they will be provided by each item in the array.

You probably want jrProfile as the module (not sure that that would break it though). Have you seen the jrProfile docs here?:
https://www.jamroom.net/ultrajam/documentation/modules/1770/googlemaps#profile-maps


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
iamtimbo
@iamtimbo
9 years ago
301 posts
Hi Steve - yes I'm working through - every day is a learning experience! I know it's because my lat and long data isn't where the module is expecting it to be, I'm just learning to teach it where to look (as it were)......
SteveX
SteveX
@ultrajam
9 years ago
2,583 posts
The lat and lng will draw a map with that lat/lng at the center.

If you want to draw a map with multiple items on it, you'd want to add the $profile_latitude and $profile_longitude your $_items array in the expected place (profile_googlemaps_lat and profile_googlemaps_lng).

This is untested, but you could try something like this:
{foreach $_items as $key => $val}
  {$_items[$key].profile_googlemaps_lat=$profile_latitude}
  {$_items[$key].profile_googlemaps_lng=$profile_longitude}
{/foreach}
or this:
{foreach $_items as $key => $val}
  {$_items.$key.profile_googlemaps_lat=$profile_latitude}
  {$_items.$key.profile_googlemaps_lng=$profile_longitude}
{/foreach}

Then pass the $_items array into the map parameter:
{ujGoogleMaps_map module="jrProfile" name="countywide" map=$_items height="300" width="100%" map_type="hybrid"}



--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)

updated by @ultrajam: 03/10/15 04:13:57PM
iamtimbo
@iamtimbo
9 years ago
301 posts
Thanks, Steve - I'll process this and see what occurs.....!
iamtimbo
@iamtimbo
9 years ago
301 posts
Hi - I'm busy trying to get my head round this, but wasn't making any headway, so I decided to just create the simplest multi-item map for profiles that I could. I've set a couple of profiles with profile_googlemaps data (before I try and do the clever stuff above!), but I can't even get a simple map to show.

I've achieved this without a problem for the Gallery module in the item_list.tpl. As I understand it, using virtually the same smarty in the Profile item_list.tpl (essentially just changing the module to jrProfile) should work to plot all profiles on a map, but it doesn't - no map appears at all.

Using debug, I can see that profile_googlemaps fields are populated in the array for the profiles that I've set them for - so is there some key difference in the way ujGooglemaps works with profiles? I noticed that someone else had issues with a profile multimap, but I'm not sure if they solved it or gave up.

My only thought is that every item in the array might need populated profile_googlemaps fields for it to work, but I'm not sure why that would make a difference - it doesn't in the Gallery implementation.
SteveX
SteveX
@ultrajam
9 years ago
2,583 posts
Maps work very well on profiles. Try making a simple map on a profile before making a multi map.

If you dont see the map and you are sure that the mappable data is correct, verify that the smarty function is in the right template (add some text before the smarty function and check that it appears in the page where you expect it to). Also look at the page source and see what map javascript is added to the page. Paste it here if you can.

It doesn't matter if some profiles have map data and others don't.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)

updated by @ultrajam: 02/27/15 04:28:27AM
iamtimbo
@iamtimbo
9 years ago
301 posts
Hi Steve,

Double-checked - I'm definitely in the right place. I already have simple and multi-item maps on other pages - they all seem to be fine. Code is in the item_list.tpl in User Profiles, and is currently:

{if isset($_items)}

{ujGoogleMaps_map name="multimap" map=$_items module="jrProfile" height="500" width="100%" map_type="hybrid"} 

    {foreach from=$_items item="item"}
    <div class="item">

        <div class="container">
            <div class="row">
                {*** <div class="col2">
                    <div class="block_image">
                        <a href="{$jamroom_url}/{$item.profile_url}">{jrCore_module_function function="jrImage_display" module="jrProfile" type="profile_image" item_id=$item._profile_id size="24" crop="auto" class="iloutline img_scale" alt=$item.profile_name title=$item.profile_name width=false height=false}</a>
                    </div>
                </div>***}
                <div class="col10 last">
                    <div class="p10">
                        {***<h4><a href="{$jamroom_url}/{$item.profile_url}">{$item.profile_name|truncate:45:"...":true}</a></h4>***}
                        <h4><a href="{$jamroom_url}/{$item.profile_url}">{$item.profile_place}, {$item.profile_county}, {$item.profile_postcode}</a></h4>
                        {***{if !empty($item.profile_bio)}
                        <br><span class="normal">{$item.profile_bio|jrCore_format_string:$item.profile_quota_id|truncate:250:"..."}</span>
                        {/if}***}
                    </div>
                </div>
            </div>
        </div>

    </div>
    {/foreach}
  
{/if}

Apologies for the commented-out stuff. No javascript is firing at all (related to googlemaps), according to the source in Firefox - and I can see what I'm looking for from a page with a different, working map. Bit baffled....
SteveX
SteveX
@ultrajam
9 years ago
2,583 posts
You should be using profile_googlemaps_lng and profile_googlemaps_lat, or change the values in your array. Without mappable data no map will show.

If you put the ujGoogleMaps_map function into the div class="col10 last" and pass in the $item do you see a map for each item?
Do you see Lat:{$item.profile_googlemaps_lat} Lng:{$item.profile_googlemaps_lng} ?
Temporarily try something like this and let me know what you see:
{if isset($_items)}

{ujGoogleMaps_map name="multimap" map=$_items module="jrProfile" height="500" width="100%" map_type="hybrid"} 

    {foreach from=$_items item="item"}
    <div class="item">

        <div class="container">
            <div class="row">
                <div class="col12 last">
                    <div class="p10">
                        <h3><a href="{$jamroom_url}/{$item.profile_url}">{$item.profile_name}</h3><br>
                        {ujGoogleMaps_map name="singlemap" map=$item module="jrProfile" height="300" width="100%" map_type="hybrid"}
                        <h5>Lat:{$item.profile_googlemaps_lat} Lng:{$item.profile_googlemaps_lng}</h5>
                    </div>
                </div>
            </div>
        </div>

    </div>
    {/foreach}
  
{/if}
Do you have a link to this page?


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)

updated by @ultrajam: 02/28/15 10:56:44AM
iamtimbo
@iamtimbo
9 years ago
301 posts
Hi Steve,

Sorry for the delay - real life keeps getting in the way....

I've swapped in the code you supplied. You can see the lat/long profile data showing, but not the maps themselves. Obviously this is the sample profiles that I have added the data to manually.

Does that help? The link to this page is iamtimbo.com/dorset. I've dropped the wall so that you can access it - let me know when you've seen enough, and I'll reactivate it.

Obviously, ultimately I want to map the profile_latitude and profile_longitude fields, as we discussed earlier - that exists for every profile.
updated by @iamtimbo: 03/04/15 05:39:58AM
SteveX
SteveX
@ultrajam
9 years ago
2,583 posts
Ok, If the profile_googlemaps_lat and profile_googlemaps_lng are coming from the database, try adding a profile_googlemaps field to the items which have profile_googlemaps_lat and profile_googlemaps_lng. Add any text as the value (profile_googlemaps would be an address if you had used the module to add the mappable data to the profile).

OR

If you are adding to the array in your template using the {foreach $_items as $key => $val} idea (from 7 posts above this post) add a profile_googlemaps field inside that foreach loop.

{foreach $_items as $key => $val}
  {$_items[$key].profile_googlemaps_lat=$profile_latitude}
  {$_items[$key].profile_googlemaps_lng=$profile_longitude}
  {$_items[$key].profile_googlemaps="address placeholder"}
{/foreach}



--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
iamtimbo
@iamtimbo
9 years ago
301 posts
The profiles showing lat/lng info did have values in the profile_googlemaps field,as I'd used the module to add the data. I've added the output from the field to the screengrab to show it coming in...
ultrajamcapture2.jpg
ultrajamcapture2.jpg  •  102KB


updated by @iamtimbo: 03/06/15 03:11:41AM
SteveX
SteveX
@ultrajam
9 years ago
2,583 posts
Thanks @iamtimbo. I have set up something similar to your profile use here and I see that bug too, so I'll try to find a fix in the next few days.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
SteveX
SteveX
@ultrajam
9 years ago
2,583 posts
I have fixed a bug, but looking at your screenshots it probably won't have been triggered by your profiles - it was only triggered if the first item had no mappable data.

Can you check again that you are using module="jrProfile" NOT module="jrCore" and that the places you are listing are profiles not items.

There is no update yet as there is something else I want to check out before making a new version.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)

updated by @ultrajam: 03/11/15 03:12:11AM
iamtimbo
@iamtimbo
9 years ago
301 posts
Ok - Steve - I'll have a look and get back to you....
iamtimbo
@iamtimbo
9 years ago
301 posts
Hi there - definitely using jrProfile. Can you clarify what you mean by 'profiles not items'? All the 'places' I'm trying to list are profiles in their own right...
SteveX
SteveX
@ultrajam
9 years ago
2,583 posts
I meant profiles rather than other module items. I asked because I saw results like yours when I had module="jrCore" in the ujGoogleMaps function (I had copied and pasted it from above). When I corrected that the map appeared.

The main bug I fixed was to do with having no results in the first or second profiles listed, but from your screenshot you do have results for the first two profiles. So it might not fix whatever the problem is there.

I'll get the new version uploaded to the marketplace, update it and give it a try.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
SteveX
SteveX
@ultrajam
9 years ago
2,583 posts
1.0.6 is in the Marketplace now.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
iamtimbo
@iamtimbo
9 years ago
301 posts
Nice one - well done - that's absolutely perfect! I'll revsisit the foreach loop stuff now to get the data from where it's at to where it needs to be.

Thanks again - really much appreciated.
ultrajam3.jpg
ultrajam3.jpg  •  314KB


updated by @iamtimbo: 03/16/15 07:51:13AM
iamtimbo
@iamtimbo
9 years ago
301 posts
It's all so tantalisingly close, I can smell it! The foreach loop is passing in the "address placeholder" text (from the code 9 posts above), so it's definitely running, but it's not updating the profile_googlemaps_latitude & profile_googlemaps_longitude - debug just shows their values as 'null'. There are definitely valus in $profile_latitude and $profile_longitude.

I'm guessing it's a syntax thing, and am playing around......!
ultrajam4.jpg
ultrajam4.jpg  •  42KB


updated by @iamtimbo: 03/16/15 08:33:21AM
SteveX
SteveX
@ultrajam
9 years ago
2,583 posts
I've jsut tried this in my profiles item_list.tpl just after the {if isset($_items)}, and it does work. (it creates a diagonal line of markers as it just adds 1 to the lng and lat for each profile). Only some of the profiles have map data, some do not, this adds a marker for each profile.

{$i = 1}
{foreach $_items as $key => $val}
{$profile_latitude = $i + 1}
{$profile_longitude = $i + 1}
  {$_items[$key].profile_googlemaps_lat=$profile_latitude}
  {$_items[$key].profile_googlemaps_lng=$profile_longitude}
  {$_items[$key].profile_googlemaps="address placeholder"}
  {$i++}
{/foreach}

{ujGoogleMaps_map module="jrProfile" name="testy" marker="infowindow" map=$_items height="300" width="100%" map_type="hybrid" }

Give that exact code a try in your template and let me know what you see.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)

updated by @ultrajam: 03/16/15 11:42:49AM
iamtimbo
@iamtimbo
9 years ago
301 posts
Hi there - this is what I see......
ultrajam5.jpg
ultrajam5.jpg  •  196KB


updated by @iamtimbo: 03/18/15 06:54:57AM
SteveX
SteveX
@ultrajam
9 years ago
2,583 posts
Ok, so the code related to maps is working, the smarty override to populate your $_items array with mappable data is working as well.

If there is no difference between the code above and your code, the problem lies in your $profile_latitude and/or $profile_longitude data - the values that you are passing in are not mappable, so no map appears.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
iamtimbo
@iamtimbo
9 years ago
301 posts
Thank you for that - I see what you're saying. I've been back and reinserted the code from earlier, so the template starts like this:

{if isset($_items)}

{foreach $_items as $key => $val}
  {$_items[$key].profile_googlemaps_lat=$profile_latitude}
  {$_items[$key].profile_googlemaps_lng=$profile_longitude}
  {$_items[$key].profile_googlemaps="address placeholder"}
{/foreach}


{ujGoogleMaps_map module="jrProfile" name="testy" marker="infowindow" map=$_items height="300" width="100%" map_type="hybrid" }

Interestingly, the map is rendering, but only the first place in the list. However, looking in the debug console, you can see that the profile_googlemaps_latitude and profile_googlemaps_longitude is still reading 'null' - yet it has got the first entry in the array mapped....

I've attached a screenshot with the output on, and the debug window on top.....

EDIT: it also hasn't added the marker, even though an infowindow was requested
ultrajam6.jpg
ultrajam6.jpg  •  324KB


updated by @iamtimbo: 03/18/15 07:44:14AM
iamtimbo
@iamtimbo
9 years ago
301 posts
Update - Ive just removed the foreach loop entirely, and get the same result as in the previous post (without the address placeholder text, obviously) - just the first place in the list appearing....

I'm not confident enough with the operations in that loop (although I can see what it's supposed to be doing) to identify the error, though.
SteveX
SteveX
@ultrajam
9 years ago
2,583 posts
You are passing in values $profile_latitude and $profile_longitude which are not numbers or mappable. If they contain a valid latitude and longitude the map and markers will appear.

Try this:
{if isset($_items)}

{foreach $_items as $key => $val}
  {$_items[$key].profile_googlemaps_lat=$_items[$key].profile_latitude}
  {$_items[$key].profile_googlemaps_lng=$_items[$key].profile_longitude}
  {$_items[$key].profile_googlemaps="address placeholder"}
{/foreach}


{ujGoogleMaps_map module="jrProfile" name="testy" marker="infowindow" map=$_items height="300" width="100%" map_type="hybrid" }



--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
iamtimbo
@iamtimbo
9 years ago
301 posts
Hi Steve,

For some reason I didn't see the post straightaway, and in the meantime playing around this morning, I came to the same conclusion as you, and voila!

Absolutely perfect - works like a charm. Thank you sincerely for all your help on this!

One thought - does each marker constitute an API call?
updated by @iamtimbo: 03/25/15 07:02:01AM
SteveX
SteveX
@ultrajam
9 years ago
2,583 posts
Glad that worked out.

I'm not sure, but I think that all markers = 1 api call unless they are geocoded each time. At least, that's the way it used to work - Google do change their maps terms and conditions often.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
iamtimbo
@iamtimbo
9 years ago
301 posts
Thought so! Could be interesting - the Dorset map alone generates > 700 markers. Might have to keep an eye on that!
SteveX
SteveX
@ultrajam
9 years ago
2,583 posts
Currently Google allows 25000 map loads per day, it doesnt matter how many markers there are on a map. If you go over that limit for more than 90 days in a row they will get in touch with you to discuss your options. Seems pretty reasonable:
https://developers.google.com/maps/faq#usagelimits


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)