现在工作正常。 infowindow太大而丑陋。我想实现信息框,因为它更具可定制性。有人可以指导我如何使用信息框对象来创建弹出式标记窗口吗?如何使用infobox而不是infwindow?
var map,geocoder;
var bound = new google.maps.LatLngBounds();
function initializeMap() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(39.88445,-86.11084);
var myOptions = {
maxZoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
}
function codeAddress() {
var infowindow = new google.maps.InfoWindow({});
$('.eachLocation').each(function(index) {
var counter=index+1;
var addy = $(this).parent().find('span.LocAddHidden').text();
geocoder.geocode({ 'address': addy}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK)
{
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
position: results[0].geometry.location,
map: map,
title:addy,
});
//Adding a click event to the marker
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent('<div id=\"infowindow\" style="width:235px; height:105px;>'
+'Hello World'+'</div>');
infowindow.open(map, this);
});
bound.extend(marker.getPosition());
map.fitBounds(bound);
}
});//geocode END
counter=counter+1;
});
}
太谢谢你了!上帝祝福你! :) – 2012-02-16 14:27:42
不客气,我的荣幸! – Valky 2012-02-16 15:11:08