Page 1 of 1

Map not displaying right when another extension displays map

Posted: 15 Dec 2014, 13:06
by bhuether
I have edited the Phoca Maps plugin to generate marker data on the fly based on coords that are in my event mgt database (using iCagenda). So the change is

Code: Select all

$query2 = 'SELECT id, title, alias, startdate, city, country, lat as latitude, lng as longitude, `desc` as description FROM #__icagenda_events WHERE startdate >= NOW() AND TO_DAYS( startdate ) - TO_DAYS( NOW() ) < 180 AND access=1';
                                                
						$db->setQuery($query);
						$markerp = $db->loadObjectList();
                                                
                                                $db->setQuery($query2);
						$markerp2 = $db->loadObjectList();
                                                
                                                foreach( $markerp2 as &$row) {
                                                    $row->displaygps = 0;
                                                    $row->icon = 0;
                                                    $row->iconext = 0;
                                                    $row->contentwidth="";
                                                    $row->contentheight="";
                                                    $row->markerwindow=0;
                                                    $row->url="/index.php/events/" . $row->id . "-" . $row->alias;
                                                    // add url to desc
                                                    $row->description = "<p><a href = \"" . $row->url . "\">Learn more about this event</a></p>";
                                                    
                                                }
                                                $markerp=$markerp2;
I have a footer module which then displays the map and everything is working great. However, I just noticed that on event pages where the event extension displays a map, the footer map then either does not display markers, or the map is simply blank. I don't think this behavior is related to my above code edit. I think it has to do with two extensions displaying maps.

You can see here
http://dev.pfp-consortium.org
http://dev.pfp-consortium.org/index.php ... g-workshop

First link is fine, second shows map with no markers.

Any ideas?

Re: Map not displaying right when another extension displays

Posted: 17 Dec 2014, 02:58
by Jan
Hi, on the second link, there is javascript error which needs to be solved, see:
https://www.phoca.cz/documents/16-joomla ... -conflicts
Jan

Re: Map not displaying right when another extension displays

Posted: 17 Dec 2014, 23:57
by bhuether
This is what the icagenda developer said. Thoughts?

The issue is that a google map api could be loaded only one time.If you look at iCagenda code, you will see that iCagenda controls if google api not loaded before (not possible to check an extension loaded after, as it is the case with your module phoca) and doesn't load if already loaded.My code to prevent this :$document = JFactory::getDocument();$scripts = array_keys($document->_scripts);$mapsgooglescriptFound = false;for ($i = 0; $i < count($scripts); $i++){    if (stripos($scripts[$i], 'maps.googleapis.com') !== false)    {        $mapsgooglescriptFound = true;    }}if (!$mapsgooglescriptFound){    $document->addScript('https://maps.googleapis.com/maps/api/js ... se');}Hope this helps to modify the phoca module code ;-)