dsmvqp3124 2013-11-21 13:17
浏览 39
已采纳

谷歌地图jquery插件与json,php,mysql覆盖标记

I am using jquery plugin to for google maps, trough json I am getting GPS coordinates and infos for the events. The problem is when I have 2 same markers (GPS coordinates are the same) but info of event is different, for example:

{"markers":[ { "latitude":57.7973333, "longitude":12.0502107, "content":"Representing event 1 10:00-12:00" }, { "latitude":57.7973333, "longitude":12.0502107, "content":"Representing event 2 - 15:00-16:00" } ]}

The problem is that markers are overwritten, I get info only for one event on one position, and not 2 events, how could I get one 1 marker with all the infos on the map, something like 1 marker with one info box where I would have this info:

Representing event 1 10:00-12:00

Representing event 2 - 15:00-16:00

My code is like that now - i think this could be done with mysql but not really sure how, is there a way to check the gps coordinates and if there same take all content and store in one field???:

$return_arr = array();

$fetch = mysql_query("SELECT title,event,SUBSTRING_INDEX(gps,',',1) as latitude,SUBSTRING_INDEX(gps,',',-1) as longitude,gps FROM termin,event WHERE gps IS NOT NULL AND gps!='' AND event_id_fk=event_id") or die(mysql_error());

while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) { $row_array['latitude'] = $row['latitude']; $row_array['longitude'] = $row['longitude']; $row_array['content'] = "<b>".$row['title']."</b><br/>".$row['event'];

array_push($return_arr,$row_array);

}

echo '{"markers":'.json_encode($return_arr).'}';

What I would like is something like this, one record:

"latitude":57.7973333, "longitude":12.0502107, "content":"Representing event 1 10:00-12:00 Representing event 2 - 15:00-16:00"

or is there some other way to check it with loop? that would be better I think, because than I would be able to use html for every event

  • 写回答

2条回答 默认 最新

  • dongluo8439 2013-11-21 13:50
    关注

    I found an answer with group_concat

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 图像信息库的建立与识别
  • ¥15 韩国网站购物,KG支付的支付回调如何解决
  • ¥15 workstation导入ovf文件,报错,怎么解决呢?
  • ¥15 关于#c语言#的问题:构成555单稳态触发器,采用LED指示灯延时时间,对延时时间进行测量并显示(如楼道声控延时灯)需要Proteus仿真图和C语言代码
  • ¥15 workstation加载centos进入emergency模式,查看日志报警如图,怎样解决呢?
  • ¥50 如何用单纯形法寻优不能精准找不到给定的参数,并联机构误差识别,给定误差有7个?matlab
  • ¥15 workstation加载centos进入emergency模式,查看日志报警如图,没有XFS,怎样解决呢?
  • ¥15 应用商店如何检测在架应用内容是否违规?
  • ¥15 Ubuntu系统配置PX4
  • ¥50 nw.js调用activex