本帖最后由 北京美眉 于 2009-3-29 21:37 编辑
感谢楼主分享!还有几处不明白的地方希望指点一下~ 第一处红色我知道怎么改,其它的应该怎么改成自己站的呢?
<div style="display:none;">
<!--{if $newfeed}-->
<!--{loop $newfeed $key $value}-->
<script type="text/javascript">
tmap_u.push({ "name":"$value[username]","lat": $value[lat], "lng": $value[lng], "id": $value[uid],"zoom": $value[zoom]});</script>
<div id="map_u_{$key}">
<span style="float:right;"><a href="space.php?uid=$value[uid]" title="{$_SN[$value[uid]]}" target="_blank"><img src="<!--{avatar($value[uid],small)}-->" class="avatar" /></a></span>
<p>$value[title_template]</p>
<p><a href="javascript:map_zoom_in({$key});">放大地图</a> <a href="javascript:map_zoom_out();">还原地图</a> </p>
<p><a href="space.php?uid=$value[uid]" title="{$_SN[$value[uid]]}" target="_blank">访问 $_SN[$value[uid]] 个人空间</a>
</p></div>
<!--{/loop}-->
<!--{/if}-->
</div>
<script src="http://ditu.google.com/maps?file=api&v=2&key=ABQIAAAACoypN5nK6k_TLuhZ3oZH_RSJq63ahCLp9LRODt47kTV4yYcmfRQsX1n-KWWIoMpHFCpMhScWA57t4A" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
// show shops on map
var mymap = 'viewmap_index';
var map = null;
var mapbounds = new GLatLngBounds(new GLatLng(-33.873801,151.206765), new GLatLng(0.335218,0.719604));
var markers = [];
var current_marker = null;
function map_show_info(i)
{
if(current_marker !== i)
{
markers[0].openInfoWindow(markers[1], {"maxWidth": 250});
current_marker = i;
}
}
function map_zoom_in(i)
{
map.setCenter(markers[0].getPoint(), 16);
}
function map_zoom_out()
{
if(current_marker !== null) { markers[current_marker][0].closeInfoWindow(); }
map.setCenter(mapbounds.getCenter(), Math.min(15, map.getBoundsZoomLevel(mapbounds)));
}
function map_set_marker(marker, i)
{
GEvent.addListener(marker, "click", function() { map_show_info(i); });
GEvent.addListener(marker, "infowindowclose", function() { current_marker = null; });
}
function map_auto_show()
{
var next_marker;
if(current_marker === null) next_marker = 0;
else next_marker = current_marker + 1;
if(next_marker === null || next_marker >= markers.length) { next_marker = 0; }
map_show_info(next_marker);
window.setTimeout(map_auto_show, 6000);
}
if (GBrowserIsCompatible())
{
map = new GMap2(document.getElementById('viewmap_index'));
map.addControl(new GSmallMapControl());
map.addControl(new GScaleControl());
var center = new GLatLng(112.1817398071289,37.20989218842202);
map.setCenter(center, 12);
for(var i = 0; i < tmap_u.length; i++)
{
var icon = new GIcon(G_DEFAULT_ICON, "http://msenlin.com/home/api/td.png");
G_DEFAULT_ICON.iconSize = new GSize(22, 22);
icon.iconSize = new GSize(22, 22);
var marker = new GMarker(new GLatLng( tmap_u.lat, tmap_u.lng ), {"icon": icon, "title": tmap_u.name+"@梦森林"});
map.addOverlay(marker);
markers.push([marker,document.getElementById("map_u_"+i).innerHTML, tmap_u.id]);
if(markers.length > 1)
{
mapbounds =
new GLatLngBounds(new GLatLng(Math.min(mapbounds.getSouthWest().lat(), tmap_u.lat),
Math.min(mapbounds.getSouthWest().lng(), tmap_u.lng)),
new GLatLng(Math.max(mapbounds.getNorthEast().lat(), tmap_u.lat),
Math.max(mapbounds.getNorthEast().lng(), tmap_u.lng)));
}
else
{
mapbounds = new GLatLngBounds(new GLatLng(tmap_u.lat, tmap_u.lng),
new GLatLng(tmap_u.lat, tmap_u.lng));
}
}
map_zoom_out();
window.setTimeout(map_auto_show, 3000);
}
</script> |