dtyyrt4545 2013-05-17 19:28
浏览 71

在谷歌地图上的弹出窗口中显示图片

i use google map for showing user's location by using markers and a popup window that include name of each user and profile picture

but the problem is that the profile picture of the logged in user is displayed on all markers not the profile picture of the owner marker but the name is the right name

can anyone help me ???

i want each marker to display the profile picture of the owner marker

map.php

<script type="text/javascript">
 var icon = new google.maps.MarkerImage("http://maps.google.com/mapfiles/ms/micons/blue.png",
                       new google.maps.Size(32, 32), new google.maps.Point(0, 0),
                       new google.maps.Point(16, 32));
            var center = null;
            var map = null;
            var currentPopup;
            var bounds = new google.maps.LatLngBounds();
            function addMarker(lat, lng, info) {
                var pt = new google.maps.LatLng(lat, lng);
                bounds.extend(pt);
                var marker = new google.maps.Marker({
                    position: pt,
                    icon: icon,
                    map: map
                });
                var popup = new google.maps.InfoWindow({
                    content: info,
                    maxWidth: 300
                });
                google.maps.event.addListener(marker, "click", function() {
                    if (currentPopup != null) {
                        currentPopup.close();
                        currentPopup = null;
                    }
                    popup.open(map, marker);
                    currentPopup = popup;
                });
                google.maps.event.addListener(popup, "closeclick", function() {
                    map.panTo(center);
                    currentPopup = null;
                });
            }           
            function initMap() {
                map = new google.maps.Map(document.getElementById("map"), {
                    center: new google.maps.LatLng(0, 0),
                    zoom: 14,
                    mapTypeId: google.maps.MapTypeId.ROADMAP,
                    mapTypeControl: true,
                    mapTypeControlOptions: {
                        style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR
                    },
                    navigationControl: true,
                    navigationControlOptions: {
                        style: google.maps.NavigationControlStyle.ZOOM_PAN
                    }
                });


<?php

$query = mysql_query("SELECT lattitude, user_name,village_name, longitude FROM members u 
                      INNER JOIN village v
                       ON u.village = v.id")or die(mysql_error());

while($row = mysql_fetch_array($query))
{
  $name = $row['user_name'];
  $lat = $row['lattitude'];
  $lon = $row['longitude'];
//****for image *****//
 $sql = mysql_query("SELECT * FROM members") or die(mysql_error());
  while($row = mysql_fetch_array($sql))
  {

     $username = $row['user_name'];

     //***************for upload img*****************
     $check_pic="members/$id/image01.jpg";
     $default_pic="members/0/image01.jpg";
     if(file_exists($check_pic))
     {
         $user_pic="<img src=\"$check_pic\"width=\"100px\"/>";
     }
     else
     {
          $user_pic="<img src=\"$default_pic\"width=\"100px\"/>";
     }

  //var_dump($query);


  }
    echo("addMarker($lat, $lon, '<b>$name</b><br /> $user_pic');
");
}
?>
 center = bounds.getCenter();
     map.fitBounds(bounds);

     }
</script>
<script type="text/javascript">
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
    • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
    • ¥50 需求一个up主付费课程
    • ¥20 模型在y分布之外的数据上预测能力不好如何解决