简体   繁体   English

如何在默认情况下使用CI谷歌地图库启用信息窗口打开

[英]How to enable Info Windows Open on Default With CI google map library

I am using biostall's codeigniter google map library for my google map display. 我正在使用biostall的codeigniter谷歌地图库进行谷歌地图显示。 I followed the instruction to display info windows and had the map displayed properly on the page. 我按照说明显示信息窗口,并在页面上正确显示地图。 And currently the info window only opens when clicked on the pointer. 目前,信息窗口仅在点击指针时打开。 Progress so far is like the purple icon displayed in demo. 到目前为止的进展就像演示中显示的紫色图标。 Click for Quick demo . 单击快速演示

I wasn't able to make the info window open on default. 我无法在默认情况下打开信息窗口。 Please advise. 请指教。

Configuration code as per below: 配置代码如下:

// map
$this->load->library('googlemaps');
// Initialize our map. Here you can also pass in additional parameters for customising the map (see below) 
$config['center'] = '37.4419, -122.1419';
$config['zoom'] = '14';
$config['map_width'] = '500px';
$this->googlemaps->initialize($config);

// set markers
$marker = array();
$marker['position'] = '37.4419, -122.1419';
$marker['infowindow_content'] = '<b>We are here!!</b>;
$marker['animation'] = 'DROP';
$this->googlemaps->add_marker($marker);

// Create the map. This will return the Javascript to be included in our pages <head></head> section and the HTML code to be placed where we want the map to appear. 
$data['map'] = $this->googlemaps->create_map();

I had the same problem and your solution with the simulated clicked worked fine. 我有同样的问题,你的解决方案与模拟点击工作正常。 But I my info window was too big / my zoom too high / my map-div too small, so the map-div clipped the info window. 但我的信息窗口太大/我的缩放太高/我的map-div太小,所以map-div剪切了信息窗口。 So I modified your codeline a little bit, and this problem was also solved. 所以我稍微修改了你的代码行,这个问题也解决了。

$config["onload"] = 'window.setTimeout("google.maps.event.trigger(marker_0, \'click\');",300);';

Thanks for using my library. 感谢您使用我的图书馆。 Try adding this to the list of $config parameters: 尝试将其添加到$ config参数列表中:

$config['onload'] = "google.maps.event.trigger(marker_0, 'click');";

This will essentially mimic a click on the first marker when the page loads. 这将基本上模仿页面加载时第一个标记的点击。

I haven't tested this but it should work. 我没有测试过这个,但它应该可行。 If it doesn't let me know and I'll take a closer look. 如果它不让我知道,我会仔细看看。

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM