Javascript 多个标记,单个信息窗口,定位在地图底部

Javascript 多个标记,单个信息窗口,定位在地图底部,javascript,google-maps-api-3,google-maps-markers,Javascript,Google Maps Api 3,Google Maps Markers,我在渲染带有多个标记的google地图信息窗口时遇到问题 我使用MVC 3和javascript来渲染地图,地图渲染很好,还有相关的信息窗口。但是我希望信息窗口显示在地图的底部,而不是相对于标记。根据用于搜索的国家,每张地图的起点可能不同。下面是我的javascript(正在运行)>我只是不知道如何更改信息窗口: function initializeMap() { var countryID = $("#CountryID :selected").val(); var cityID =

我在渲染带有多个标记的google地图信息窗口时遇到问题

我使用MVC 3和javascript来渲染地图,地图渲染很好,还有相关的信息窗口。但是我希望信息窗口显示在地图的底部,而不是相对于标记。根据用于搜索的国家,每张地图的起点可能不同。下面是我的javascript(正在运行)>我只是不知道如何更改信息窗口:

   function initializeMap() {

var countryID = $("#CountryID :selected").val();
var cityID = $("#cities :selected").val();
var regionID = $("#regions :selected").val();
var locationtypeID = $("#LocationTypeID :selected").val();
var filtertype = $("#filtertype").val();
var latlng;

$.ajax({
    type: "GET",
    url: "/ajaxcalls/getCentre",
    data: "cid=" + countryID,
    datatype: "json",
    success: function (result) {
        var gpscoords = (result).split(",");
        latlng = new google.maps.LatLng(gpscoords[0], gpscoords[1]);
    },
    error: function (req, status, error) {            
    }
});

var myOptions = {
    zoom: 7,
    center: latlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
};    

var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

$.ajax({
    type: "GET",
    url: "/ajaxcalls/getmarkers",
    data: "cid=" + countryID + "&rid=" + regionID + "&xid=" + cityID + "&tid=" + locationtypeID + "&filterType=" + filtertype,
    datatype: "json",
    success: function (result) {

        var infowindow = null;

        infowindow = new google.maps.InfoWindow({
            content: "holding..."
        });

        $.each(result, function (i, item) {

            var gpscoords = (item.GPSCoOrds.toString()).split(",");

            var mpos = new google.maps.LatLng(gpscoords[1], gpscoords[0]);

            var markerobject = "";

            if (item.LocationTypeID == 2) {
                markerobject = "atm.png";
            }
            else {
                markerobject = "bank.png";
            }

            marker = new google.maps.Marker({
                map: map,
                position: mpos,
                draggable: false,
                icon: "/content/mapicons/" + markerobject,
                title: item.Designation.toString() + " " + item.Address.toString()
            });

            google.maps.event.addListener(marker, 'mouseover', function () {
                var windowcontent = "<div>Site Name: ";
                windowcontent = windowcontent + item.Designation + "</div>";
                windowcontent = windowcontent + "<div>Address: " + item.Address + "</div>";
                windowcontent = windowcontent + "<div>Contact Number: " + item.contactNumber + "</div>";
                windowcontent = windowcontent + "<div>Branch Type: " + item.BranchType + "</div>";
                windowcontent = windowcontent + "<div>Network Provider: " + item.NetworkProvider + "</div>";
                windowcontent = windowcontent + "<div>Network Capacity: " + item.NetworkCapacity + "</div>";

                infowindow.setContent(windowcontent);

                infowindow.open(map, this);
            });
        });
    },
    error: function (req, stats, error) {
        alert(error);
    }
});
    }

   $(document).ready(function () {
        $("#mapupdater").click(function () {
    initializeMap();
});
    });
函数初始化映射(){
var countryID=$(“#countryID:selected”).val();
var cityID=$(“#城市:选定”).val();
var regionID=$(“#区域:选定”).val();
var locationtypeID=$(“#locationtypeID:selected”).val();
var filtertype=$(“#filtertype”).val();
var latlng;
$.ajax({
键入:“获取”,
url:“/ajaxcalls/getcenter”,
数据:“cid=“+countryID,
数据类型:“json”,
成功:功能(结果){
var gpscoords=(结果).split(“,”);
latlng=new google.maps.latlng(gpscoords[0],gpscoords[1]);
},
错误:函数(请求、状态、错误){
}
});
变量myOptions={
缩放:7,
中心:拉特林,
mapTypeId:google.maps.mapTypeId.ROADMAP
};    
var map=new google.maps.map(document.getElementById(“map_canvas”),myOptions);
$.ajax({
键入:“获取”,
url:“/ajaxcalls/getmarkers”,
数据:“cid=“+countryID+”&rid=“+regionID+”&xid=“+cityID+”&tid=“+locationtypeID+”&filterType=“+filterType,
数据类型:“json”,
成功:功能(结果){
var infowindow=null;
infowindow=新建google.maps.infowindow({
内容:“持有……”
});
$。每个(结果、功能(i、项目){
var gpscoords=(item.gpscoords.toString()).split(“,”);
var mpos=new google.maps.LatLng(gpscoords[1],gpscoords[0]);
var markerobject=“”;
如果(item.LocationTypeID==2){
markerobject=“atm.png”;
}
否则{
markerobject=“bank.png”;
}
marker=新的google.maps.marker({
地图:地图,
职位:mpos,
可拖动:错误,
图标:“/content/mapicons/”+markerobject,
标题:item.Designation.toString()+“”+item.Address.toString()
});
google.maps.event.addListener(标记'mouseover',函数(){
var windowcontent=“站点名称:”;
windowcontent=windowcontent+项目名称+“”;
windowcontent=windowcontent+“地址:”+项。地址+”;
windowcontent=windowcontent+“联系人号码:“+item.contactNumber+”;
windowcontent=windowcontent+“分支类型:“+item.BranchType+”;
windowcontent=windowcontent+“网络提供程序:”+item.NetworkProvider+”;
windowcontent=windowcontent+“网络容量:“+item.NetworkCapacity+”;
setContent(windowcontent);
打开(地图,这个);
});
});
},
错误:函数(请求、统计、错误){
警报(错误);
}
});
}
$(文档).ready(函数(){
$(“#mapupdater”)。单击(函数(){
初始化映射();
});
});

任何帮助都将不胜感激。

不要使用
infowindow.open将infowindow锚定到标记上(地图,此)

只需做
infowindow.打开(地图)


但是,您仍然需要告诉信息窗口显示在哪里。创建时使用
position
属性,或者在创建后使用
setPosition()

position属性的问题在于它仍然是一个LatLng对象。如果您滚动或移动地图,则信息窗口将移开,因为此时地图上可能看不到latlng。我的理解正确吗?是的,所以当映射边界更改时,您需要打开一个事件侦听器,以重新绘制任何打开的信息窗口。感谢所有的回复,我刚刚创建了一个静态浮动div,并使用ajax调用直接用数据库中的信息更新div。