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 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法