10 九月 2008 @ 12:17 下午 
A:請自己綁定mouseover事件,利用UMarker.getPoint()來取得經緯度座標,並設定marker info的位置。
var map;
function init() {
	map = new UMap(document.getElementById(’map’));
	map.centerAndZoom(new ULatLng(25.035405, 121.520255), 9);
	var mapDiv = document.getElementById(’map’);

	var marker = new UMarker(map.getCenter());
	bindMaukerMouseover(marker, ‘this is a string!’);
	map.addOverlay(marker);

	var marker2 = new UMarker(new ULatLng(25.033405, 121.523255));
	bindMaukerMouseover(marker2, ‘this is another string!’);
	map.addOverlay(marker2);

	//My marker info Div
	var myMarkerInfoDiv = document.createElement(’div’);
	myMarkerInfoDiv.id = ‘myMarkerInfoDiv’;
	myMarkerInfoDiv.style.cssText = ‘width:200px;border:1px solid blue;display:none;position:absolute;background-color:#CCC;’;
	document.getElementById(’map’).appendChild(myMarkerInfoDiv);
}
榜定marker的mouseover事件
function bindMaukerMouseover(mkr, msg){
	mkr.addListener(’mouseover’, function(){
		var latlng = mkr.getPoint();//取得該座標的經緯度
		var point = map.transformLatLngToContainerCoordinates(latlng);//將經緯度轉成螢幕座標(相對於mapDiv左上角)
		var exX = 15;//x偏差量
		var exY = 10;//y偏差量
		document.getElementById(’myMarkerInfoDiv’).style.left = (point.x + exX) + ‘px’;
		document.getElementById(’myMarkerInfoDiv’).style.top = (point.y + exY) + ‘px’;
		document.getElementById(’myMarkerInfoDiv’).style.display = ‘block’;
		document.getElementById(’myMarkerInfoDiv’).innerHTML = msg;
	});
	mkr.addListener(’mouseout’, function(){
		document.getElementById(’myMarkerInfoDiv’).style.display = ‘none’;
	});
}
下載範例檔
Posted By: BLACKBING
Last Edit: 10 九月 2008 @ 12:17 下午

EmailPermalink
Tags
Tags: ,
Categories: Programing


 

Responses to this post » (None)

 
Post a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


 Last 50 Posts
 Back
Change Theme...
  • Users » 30
  • Posts/Pages » 64
  • Comments » 35
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

About Me



    No Child Pages.

留言板



    No Child Pages.

Album



    No Child Pages.