Ushahidi v2.X has maps on the front page and on the report create/edit page.  Sometimes you'll want to add a map to a different page (e.g. part of a plugin view).  This is where the map code lives...

In the view file:

If you look at file \themes\default\views\main\layout.php, you'll see

<div class="map-container">
echo $div_map;
echo $div_timeline;
</div>

This code adds the map and timeline blocks to the main page.  If you're using a different theme, e.g. theme xxx, look for \themes\xxx\views\main\layout.php to see if there's anything different in there.

In the controller file: 

If you look in application/controllers/main.php, you'll see:

$div_map = new View('main/map');
$div_timeline = new View('main/timeline');
Event::run('ushahidi_filter.map_main', $div_map);
Event::run('ushahidi_filter.map_timeline', $div_timeline);
$this->template->content->div_map = $div_map;
$this->template->content->div_timeline = $div_timeline;

This creates the map and timeline, filters them, and adds them to the current view (see above).  The map file is in themes\default\views\main\map.php

 

To activate the map, you'll need to add the following lines to the controller file:

$this->themes->map_enabled = TRUE; //Loads Ushahidi's map JS files
$this->themes->js = new View('main/my_map_js'); //path to your js file containing map instructions
 
// From here on, you may or may not need the lines below, depending on the map you're using
		$this->themes->js->marker_radius = ($marker_radius >=1 AND $marker_radius <= 10 )
		    ? $marker_radius
		    : 5;
		$this->themes->js->marker_opacity = ($marker_opacity >=1 AND $marker_opacity <= 10 )
		    ? $marker_opacity * 0.1
		    : 0.9;
		$this->themes->js->marker_stroke_width = ($marker_stroke_width >=1 AND $marker_stroke_width <= 5)
		    ? $marker_stroke_width
		    : 2;
		$this->themes->js->marker_stroke_opacity = ($marker_stroke_opacity >=1 AND $marker_stroke_opacity <= 10)
		    ? $marker_stroke_opacity * 0.1
		    : 0.9;

The script above looks for a map on the main/my_map_js.php file. We suggest you copy the JS from default/views/main/main_js.php and start customizing it as you wish.

 

 

 

To be continued...