Display Geolocation Map - Homepage

What is the hook to display the gelocation map on your homepage? Just the map itself, not a list of items.

The hook is public_home, but it might or might not be implemented in theme you are using (I just noticed that it's missing from the default theme).

The basic code would be like this:

<div id="map_block">
    <?php echo $this->googleMap('map_browse', array('loadKml'=>true, 'list'=>'map-links'));?>
</div><!-- end map_block -->

The javascript assumes that it will be adding the links to a div with id 'map-links', so to get the effect it sounds like you are looking for doing something like this might be an okay workaround.

<div id="map_block">
    <?php echo $this->googleMap('map_browse', array('loadKml'=>true, 'list'=>'map-links'));?>
</div><!-- end map_block -->
<div id='map-links' style='display:none;'></div>

Where the last div just lets the javascript do its thing, and then you keep the div hidden.

yeah, it does some weird things when I use that code. I get these errors:

#0 /home/yearsbla/public_html/application/libraries/Zend/View/Abstract.php(1182): Zend_Loader_PluginLoader->load('GoogleMap')
#1 /home/yearsbla/public_html/application/libraries/Zend/View/Abstract.php(618): Zend_View_Abstract->_getPlugin('helper', 'googleMap')
#2 /home/yearsbla/public_html/application/libraries/Zend/View/Abstract.php(344): Zend_View_Abstract->getHelper('googleMap')
#3 /home/yearsbla/public_html/themes/tinnerhill/common/header.php(50): Zend_View_Abstract->__call('googleMap', Array)
#4 /home/yearsbla/public_html/themes/tinnerhill/common/header.php(50): Omeka_View->googleMap('map_browse', Array)
#5 /home/yearsbla/public_html/application/libraries/Omeka/View.php(117): include('/home/yearsbla/...')
#6 /home/yearsbla/public_html/application/libraries/Zend/View/Abstract.php(888): Omeka_View->_run('/home/yearsbla/...')
#7 /home/yearsbla/public_html/application/libraries/Zend/View/Helper/Partial.php(105): Zend_View_Abstract->render('common/header.p...')
#8 [internal function]: Zend_View_Helper_Partial->partial('common/header.p...', Array)
#9 /home/yearsbla/public_html/application/libraries/Zend/View/Abstract.php(350): call_user_func_array(Array, Array)
#10 /home/yearsbla/public_html/application/libraries/globals.php(1614): Zend_View_Abstract->__call('partial', Array)
#11 /home/yearsbla/public_html/application/libraries/globals.php(1614): Omeka_View->partial('common/header.p...', Array)
#12 /home/yearsbla/public_html/application/libraries/globals.php(1628): common('header', Array)
#13 /home/yearsbla/public_html/plugins/SimplePages/views/public/page/show.php(5): head(Array)
#14 /home/yearsbla/public_html/application/libraries/Omeka/View.php(117): include('/home/yearsbla/...')
#15 /home/yearsbla/public_html/application/libraries/Zend/View/Abstract.php(888): Omeka_View->_run('/home/yearsbla/...')
#16 /home/yearsbla/public_html/application/libraries/Zend/Controller/Action/Helper/ViewRenderer.php(900): Zend_View_Abstract->render('page/show.php')
#17 /home/yearsbla/public_html/application/libraries/Zend/Controller/Action/Helper/ViewRenderer.php(921): Zend_Controller_Action_Helper_ViewRenderer->renderScript('page/show.php', NULL)
#18 /home/yearsbla/public_html/application/libraries/Zend/Controller/Action/Helper/ViewRenderer.php(960): Zend_Controller_Action_Helper_ViewRenderer->render()
#19 /home/yearsbla/public_html/application/libraries/Zend/Controller/Action/HelperBroker.php(277): Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
#20 /home/yearsbla/public_html/application/libraries/Zend/Controller/Action.php(527): Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#21 /home/yearsbla/public_html/application/libraries/Zend/Controller/Dispatcher/Standard.php(308): Zend_Controller_Action->dispatch('showAction')
#22 /home/yearsbla/public_html/application/libraries/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#23 /home/yearsbla/public_html/application/libraries/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#24 /home/yearsbla/public_html/application/libraries/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#25 /home/yearsbla/public_html/application/libraries/Omeka/Application.php(79): Zend_Application->run()
#26 /home/yearsbla/public_html/index.php(23): Omeka_Application->run()
#27 {main}

Maybe that hook is not included in my theme? How would I go about adding that? Can you shoot me in the right direction? Or have a sample theme I should look at?

Could you include to top part of the error message, above the trace you gave?

A sample to look at is the default items/show.php page in application/views/scripts/items/show.php.

Or, we've just fixed that bug in the Thanks, Roy and Berlin themes by putting this at the bottom of the secondary div:

<?php fire_plugin_hook('public_home', array('view' => $this)); ?>

The top looks like this:

Zend_Loader_PluginLoader_Exception
Plugin by name 'GoogleMap' was not found in the registry; used paths:
Coins_View_Helper_: /home/yearsbla/public_html/plugins/Coins/views/helpers/
Omeka_View_Helper_: /home/yearsbla/public_html/application/views/helpers/
Zend_View_Helper_: Zend/View/Helper/

Any news on this?

Hmm. That seems like more theme oddness. Could you tell me what theme you are using?

A fix around it might be to add this right at the top of the index.php file in your theme:

<?php

$view->addHelperPath(GEOLOCATION_PLUGIN_DIR . '/helpers', 'Geolocation_View_Helper_');

queue_css_file('geolocation-items-map');
queue_css_file('geolocation-marker');
queue_js_url("http://maps.google.com/maps/api/js?sensor=false");
queue_js_file('map');

?>

The first line should resolve the error. The other four lines add the style and javascript the Geolocation needs.

However, as I've tested this out, variations between themes might or might not make the map show up. All the the code seems to be there, but trying to style around Google's code can sometimes be a challenge.

Weird. Still getting this error:

Zend_Loader_PluginLoader_Exception
Plugin by name 'GoogleMap' was not found in the registry; used paths:
Coins_View_Helper_: /home/yearsbla/public_html/plugins/Coins/views/helpers/
Omeka_View_Helper_: /home/yearsbla/public_html/application/views/helpers/
Zend_View_Helper_: Zend/View/Helper/

It's a custom theme BTW

The map works on this page: /geolocation/map/browse it's just a problem getting it to show up on the homepage.

Just double-checking....are you working on using the public_home hook to add the map, or are you directly inserting the PHP in index.php?

I was directly inserting the PHP in my header.php

In that case instead of

$view->addHelperPath(GEOLOCATION_PLUGIN_DIR . '/helpers', 'Geolocation_View_Helper_');

try

$this->addHelperPath(GEOLOCATION_PLUGIN_DIR . '/helpers', 'Geolocation_View_Helper_');

I am having a related problem. I added items, then added geolocations to them. Now, when doing any batch editing ( such as adding to collections) on them, I get the error:

Zend_Loader_PluginLoader_Exception
Plugin by name 'ItemGoogleMap' was not found in the registry;

I tried changing themes, and adding the $view-> line to the index.php files, but there was no change. What am I missing?

By putting this in my header.php file it started working:

<?
$this->addHelperPath(GEOLOCATION_PLUGIN_DIR . '/helpers', 'Geolocation_View_Helper_');
queue_css_file('geolocation-items-map');
queue_css_file('geolocation-marker');
queue_js_url("http://maps.google.com/maps/api/js?sensor=false");
queue_js_file('map');

?>

<?php fire_plugin_hook('public_home', array('view' => $this)); ?>

Thanks drewrowland. unfortunately, I tried it in the header.php and it did not work.

I am thinking that the problem might be something slightly different in that my error says that I don't have 'ItemGoogleMap' not "GoogleMap' as shown in your error. Do I have a syntax problem? I think that this was mentioned as a problem somewhere, but can't find it. I don't want to re-install because I had to manually geolocate so many items already. ?

@Karen, sorry just seeing this. Are you still having an issue?