Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined variable: map #43

Open
GiseleFerreiraLima opened this issue May 5, 2015 · 4 comments
Open

Undefined variable: map #43

GiseleFerreiraLima opened this issue May 5, 2015 · 4 comments

Comments

@GiseleFerreiraLima
Copy link

Message: Undefined variable: map

How to solve this?

Controller Map.php

defined('BASEPATH') OR exit('No direct script access allowed');

class Map extends CI_Controller {

public function __construct()
{
    parent::__construct();

    $this->m_login->verifica_sessao();
}

public function index()
{
    $this->load->library('googlemaps');
    $config['center'] = '37.4419, -122.1419';
    $config['zoom'] = 'auto';
    $this->googlemaps->initialize($config);
    $marker = array();
    $marker['position'] = '37.429, -122.1419';
    $marker['draggable'] = true;
    $marker['ondragend'] = 'alert(\'You just dropped me at: \' + event.latLng.lat() + \', \' + event.latLng.lng());';
    $this->googlemaps->add_marker($marker);
    $data['map'] = $this->googlemaps->create_map();
    $this->load->view('home', $data);
}

}

I put before the closing tag in the file view header.php:

In the view home.php

I need to config up something of REST?

@Wayne-King-79
Copy link

Wayne-King-79 commented Jun 5, 2016

I had the same problem since I load a header, content, then footer so what I did was remove the <?php echo $map['js']; ?>from my header and added in to the content view where I have the <?php echo $map['html']; ?>. Problem resolved for me on CodeIgniter 3.

@umairsultan
Copy link

Solution not working

@Wayne-King-79
Copy link

How are you going to come in 2 years after I comment and thumbs down my solution? Lol

@umairsultan
Copy link

Have you found any other solution for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants