Welcome Guest, Not a member yet? Register   Sign In
Passing Results from SQL to Google Maps API in CodeIgniter
#11

[eluser]yannyannyann[/eluser]
You mean the map doesn't get updated ?
#12

[eluser]jshultz[/eluser]
[quote author="yannyannyann" date="1274823859"]You mean the map doesn't get updated ?[/quote]

correct.
#13

[eluser]pickupman[/eluser]
I'll have to checkout that library. I am using the jQuery gMaps plugin. Worked on first try, so I haven't gone any further with a CI solution. I essentially have similar code, but gMaps takes a json string so I just json_encode() the $marker array.
#14

[eluser]yannyannyann[/eluser]
I get longituted and latitude, but what i see from the map doesn't move / refresh to the location i want ?
#15

[eluser]jshultz[/eluser]
I got it working finally:

Here's the Controller:

Code:
function business($id)
    {
        $this->load->model('Business_model');
        $this->load->model('Gallery_model');
        
        $address = $this->Business_model->addressForMap($id); //Get result row
        $config['apikey'] = 'google-api-key';
        $config['center_address'] =  $address->busaddress .', '. $address->buscity;
        $this->googlemaps->initialize($config);
        $marker = array();
        
        // $marker['address'] = $address->busaddress .' '.$address->buscity .', '. $address->buszip;
        $marker['address'] = $address->busaddress .', '. $address->buscity;
        $this->googlemaps->add_marker($marker);
        
        $data['map'] = $this->googlemaps->create_map();
        
        $data['address'] = $address->busaddress .', '.$address->buscity;
        $data['photos'] = $this->Gallery_model->get_images_from_db($id);
        $data['business']     = $this->Business_model->businessQuery($id);
        $data['user_id']    = $this->tank_auth->get_user_id();
        $data['username']    = $this->tank_auth->get_username();
        $data['page_title'] = 'Welcome To Jerome - Largest Ghost Town in America';
        $data['page'] = 'business_view'; // pass the actual view to use as a parameter
        $this->load->view('container',$data);
    }


Here's the Model:

Code:
function addressForMap($id) {
    $this->db->select('b.id, b.busaddress, b.buscity, b.buszip');
    $this->db->from('business as b');
    $this->db->where('b.id', $id);
    $this->db->limit(1);
// add a limit
    $this->db->limit(1);

    // get the results.. cha-ching
    $q = $this->db->get();

    // any results?
    if($q->num_rows() !== 1)
    {
        return FALSE;
    }

    return $q->row();
}




Theme © iAndrew 2016 - Forum software by © MyBB