I noticed that the call to the Google Maps API happens on every single 'account.php' page, even those that do not display any maps whatsoever. This can cause pages to hang if Google happens to be a bit slow responding.
My solution is to restrict the loading of the API a little more. The if-condition starting on line 38 of default.php checks the value of the PostBackAction, and only loads the API into the header if there is no PostBackAction (the initial account page) or if the user is managing the map (PostBackAction is 'ManageLocation'.
$PostBackAction = ForceIncomingString('PostBackAction','');
if ((($Context->SelfUrl == 'account.php' && (empty($PostBackAction) || $PostBackAction == 'ManageLocation')) OR ($Context->SelfUrl == 'extension.php' && ForceIncomingString('PostBackAction','') == 'GoogleMap')) AND isset($Head))
{
$Head->AddStylesheet('extensions/MemberGoogleMap/style.css');
$Head->AddScript('http://maps.google.com/maps?file=api&v=2&key='.$Context->Configuration['GOOGLEMAP_KEY']);
}
I've shown the $Head assignments for completeness, but they remain as is.
I am convinced there is some kind of race condition happening with the Google code and the default Vanilla JavaScript (or other modules). I am finding that at least one out of every three visits to a user profile page results in the browser hanging, apparently waiting for some download to complete. The Google Map does not get drawn.
Pressing Control-F5 to refresh the screen and download everything from scratch always recovers the page, until the next time I visit the page.
All the JavaScript is cached locally in the browser *except* the call to the Google Maps code, which is fetched every time, which is making me wonder whether other code executing before Google code is downloaded is causing problems.
I cannot see any JavaScript errors. It is something I just cannot put my finger on. Anyone else had this experience?
After making the recommended fixes, I got this extension to work. On the big map that shows the location of all the members, when you click on a marker, it shows the members Username.
Is there a way for the marker balloon to show the members Real Name? Thanks! Ken
Comments
My solution is to restrict the loading of the API a little more. The if-condition starting on line 38 of default.php checks the value of the PostBackAction, and only loads the API into the header if there is no PostBackAction (the initial account page) or if the user is managing the map (PostBackAction is 'ManageLocation'.
$PostBackAction = ForceIncomingString('PostBackAction',''); if ((($Context->SelfUrl == 'account.php' && (empty($PostBackAction) || $PostBackAction == 'ManageLocation')) OR ($Context->SelfUrl == 'extension.php' && ForceIncomingString('PostBackAction','') == 'GoogleMap')) AND isset($Head)) { $Head->AddStylesheet('extensions/MemberGoogleMap/style.css'); $Head->AddScript('http://maps.google.com/maps?file=api&v=2&key='.$Context->Configuration['GOOGLEMAP_KEY']); }
I've shown the $Head assignments for completeness, but they remain as is.
-- Jason
Pressing Control-F5 to refresh the screen and download everything from scratch always recovers the page, until the next time I visit the page.
All the JavaScript is cached locally in the browser *except* the call to the Google Maps code, which is fetched every time, which is making me wonder whether other code executing before Google code is downloaded is causing problems.
I cannot see any JavaScript errors. It is something I just cannot put my finger on. Anyone else had this experience?
-- Jason
On the big map that shows the location of all the members, when you click on a marker, it shows the members Username.
Is there a way for the marker balloon to show the members Real Name?
Thanks!
Ken