Welcome Guest, Not a member yet? Register   Sign In
How to using infowindow_content for direct link to another web?
#1

[eluser]irga[/eluser]

How to using infowindow_content for direct link to another web?
i'm using API V3 with codeigniter frame work..

like this [/code]https://google-developers.appspot.com/ma...e?hl=id-ID

[code] foreach ($infoMarkers as $infoMarker) {
$marker = array();
$marker['position'] = $infoMarker->latitude.",".$infoMarker->longitude;
$marker['infowindow_content'] = 'Hello world';
$marker['animation'] = 'DROP';
$this->googlemaps->add_marker($marker);
#2

[eluser]weboap[/eluser]
look at the link for example.
https://developers.google.com/maps/artic...#createmap

need more info about the lib "googlemaps" that you are using to help here.
#3

[eluser]irga[/eluser]
I am using the google map library from Steve
http://biostall.com/codeigniter-google-m...pi-library

1. I tried to add the hyperlink into info_window, but it can’t be worked, no google map shown.
Code:
$marker['infowindow_content']='<a href="http://www.google.com">Google</a>'

How can I add the hyperlink into info_window by a correct way?
#4

[eluser]weboap[/eluser]
your missing forward slash (\)after href= and at the end just before last (")
Code:
$marker['infowindow_content']='<a href="http://www.google.com">Google</a>'; // coudln't replicate that the forum is filtering the (\)
#5

[eluser]weboap[/eluser]
the long answer is (if somebody need help implementing this lib).


sample db table:

Code:
CREATE TABLE IF NOT EXISTS `mymap` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `place` varchar(50) NOT NULL,
  `desc` varchar(150) NOT NULL,
  `lat` float NOT NULL,
  `lng` float NOT NULL,
  `url` varchar(150) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Dumping data for table `mymap`
--

INSERT INTO `mymap` (`id`, `place`, `desc`, `lat`, `lng`, `url`) VALUES
(1, 'Some place 1', 'Some desc 1', 37.429, -122.152, 'www.google.com'),
(2, 'Some place 2', 'Some desc 2', 37.409, -122.132, 'www.google.com');

model : mymap_model.php

Code:
class mymap_model extends CI_Model {

    
    
public function getAllMarkers() {
    
    $query = $this->db->get( 'mymap' );

    if( $query->num_rows() > 0 ) {
        return $query->result();
    } else {
        return false;
    }
    }
    
    
    
    
    
    
    
    
}


controller : mymap.php


Code:
class Mymap extends CI_Controller {
  
  
  function __construct()
  {
  
    parent::__construct();
    

  }
  
  function index(){
    //using data from demo
    // http://biostall.com/demos/google-maps-v3-api-codeigniter-library/multiplemarkers
    
    $this->load->library('googlemaps');

    //can be setup in a config file or after you pull data, use the 1st record  in the set as a center
    //then initialize ....whatever you need to do...

    $config['center'] = '37.4419, -122.1419';
    $config['zoom'] = 'auto';

    $this->googlemaps->initialize($config);
    
    
    $this->load->model('mymap_model', 'mymap');
  
    
  
    $db_markers = $this->mymap->getAllMarkers();
    
    if( $db_markers ){
        
        
        foreach( $db_markers as $db_marker ){
            
        $marker = array();
        $marker['position'] = $db_marker->lat.', '.$db_marker->lng;
        $marker['infowindow_content'] = '<a >url.'\"<b>'.$db_marker->place.'</b></a><br>'.$db_marker->desc;
        $marker['icon'] = 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=A|9999FF|000000';
        $this->googlemaps->add_marker($marker);
        
        }
      
       $data['map'] = $this->googlemaps->create_map();
        
    }else{
        
        $data['map'] = false;
        
    }
  
    $this->load->view('mymap_view.php', $data);
  
  }
  

  
  
}


view: mymap_view.php


Code:
&lt;?php
    if(!$map){
        echo "no data available!";
    }else{
        
        ?&gt;

&lt;html&gt;
&lt;head&gt;&lt;?php echo $map['js']; ?&gt;&lt;/head&gt;
&lt;body&gt;&lt;?php echo $map['html']; ?&gt;&lt;/body&gt;
&lt;/html&gt;

&lt;?
}
?&gt;


hope it help somebody.

#6

[eluser]irga[/eluser]
thanks for your solution sir..
it's totaly work.

i've another question and i hope you can help me sir..
can i customize the infowindows?




Theme © iAndrew 2016 - Forum software by © MyBB