所有,我有以下代码来添加标记:
function addPoints( points )
{
for ( var p = 0; p < points.length; ++p )
{
var pointData = points[p];
if ( pointData == null ) return;
var point = new GLatLng( pointData.latitude, pointData.longitude );
var marker = createMarker( point, icon0, pointData.html );
map.addOverlay( marker );
}
}
function createMarker(point, icon, popuphtml) {
//alert("the create marker is: "+point);
var popuphtml = "<div id=\"popup\">" + popuphtml + "<\/div>";
var marker = new GMarker(point, icon);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(popuphtml);
});
return marker;
}
我有一些 PHP/Javascript 将信息传递给这个函数:
$lat = $resultset_vendors['vendor_latitude'];
$long = $resultset_vendors['vendor_longitude'];
$name = $resultset_vendors['vendor_name']. "<br/>" . $resultset_vendors['vendor_address1']
. "<br/>" . $resultset_vendors['vendor_city'] . ", " . $resultset_vendors['vendor_state'] . " " . $rs['vendor_zip'];
$jsData = $jsData . " new Store( $lat, $long, '$name' ),\n";
function Store( lat, long, text )
{
this.latitude = lat;
this.longitude = long;
this.html = text;
}
var myStores = [<?php echo $jsData;?>, null];
我的数据成功传递,一切看起来都很好,除了在 Maps div 内打开了弹出框。如何在地图 div 之外打开它?可以在 yelp 上找到一个很好的例子。如果您将鼠标悬停在他们地图中的标记上,它会在地图 div 之外打开。