Want to use Google’s Visualization GEO API with CodeIgniter, her To simply put it they wanted to:
- The controller
- The model
- The view
- Pass it to Google’s Visualization into a data table
- Create a map based on that data.
Now the example given is great, however it doesn’t jive well when you want to add in a friendly library like jQuery. So here is how we fixed it:
The Controller – maps.com
1
2
3
4
5
6
7
8
9
10
|
public function index() {
$data = $this->Maps_m->get_map_country(); // Pass the data t the template, using the variable map $this->template->map = $data;
|
The Data Model
1
2
3
4
5
6
7
8
9
10
11
12
13
|
public function get_map_country() {
return $this->db |
Then we just needed load the data from the database and create the map.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
https://www.google.com/jsapi
google.load(‘visualization’, ‘1’, {‘packages’: [‘geochart’]}); function drawRegionsMap() { [”, ], ]); var options = {}; var chart = new google.visualization.GeoChart(document.getElementById(‘chart_div’)); |