BIOSTALL / CodeIgniter-Google-Maps-V3-API-Library

The library enables you to create a map and overlay multiple markers, polylines, polygons, rectangles, ground overlays and/or circles, all of which are fully customisable. The library also supports showing directions between two points, including the ability to show the textual directions alongside the map too, and marker clustering. The first stages of integration with the Google Places API are available for use too.
http://biostall.com/codeigniter-google-maps-v3-api-library
288 stars 199 forks source link

Undefined variable: map #43

Open GiseleFerreiraLima opened 9 years ago

GiseleFerreiraLima commented 9 years ago

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:

<?php echo $map['js']; ?>

In the view home.php

<?php echo $map['html']; ?>

I need to config up something of REST?

Wayne-King-79 commented 8 years ago

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 commented 6 years ago

Solution not working

Wayne-King-79 commented 6 years ago

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

umairsultan commented 6 years ago

Have you found any other solution for that?