http://code.google.com/apis/maps/documentation/javascript/examples/infowindow-simple.htmlvar myLatlng = new google.maps.LatLng(-25.363882,131.044922); var myOptions = { zoom: 4, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP }var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);var contentString = '<div id="content">'+ '<div id="siteNotice">'+ '</div>'+ '<h1 id="firstHeading" class="firstHeading">Uluru</h1>'+ '<div id="bodyContent">'+ '<p><b>Uluru</b>, also referred to as <b>Ayers Rock</b>, is a large ' + 'sandstone rock formation in the southern part of the '+ 'Northern Territory, central Australia. It lies 335 km (208 mi) '+ 'south west of the nearest large town, Alice Springs; 450 km '+ '(280 mi) by road. Kata Tjuta and Uluru are the two major '+ 'features of the Uluru - Kata Tjuta National Park. Uluru is '+ 'sacred to the Pitjantjatjara and Yankunytjatjara, the '+ 'Aboriginal people of the area. It has many springs, waterholes, '+ 'rock caves and ancient paintings. Uluru is listed as a World '+ 'Heritage Site.</p>'+ '<p>Attribution: Uluru, <a href="http://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194">'+ 'http://en.wikipedia.org/w/index.php?title=Uluru</a> (last visited June 22, 2009).</p>'+ '</div>'+ '</div>';var infowindow = new google.maps.InfoWindow({ content: contentString });var er = new google.maps.Marker({ position: myLatlng, map: map, title:"Uluru (Ayers Rock)" });google.maps.event.addListener(er, 'click', function() { infowindow.open(map,er); });
var myOptions = {
zoom: 4,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);var contentString = '<div id="content">'+
'<div id="siteNotice">'+
'</div>'+
'<h1 id="firstHeading" class="firstHeading">Uluru</h1>'+
'<div id="bodyContent">'+
'<p><b>Uluru</b>, also referred to as <b>Ayers Rock</b>, is a large ' +
'sandstone rock formation in the southern part of the '+
'Northern Territory, central Australia. It lies 335 km (208 mi) '+
'south west of the nearest large town, Alice Springs; 450 km '+
'(280 mi) by road. Kata Tjuta and Uluru are the two major '+
'features of the Uluru - Kata Tjuta National Park. Uluru is '+
'sacred to the Pitjantjatjara and Yankunytjatjara, the '+
'Aboriginal people of the area. It has many springs, waterholes, '+
'rock caves and ancient paintings. Uluru is listed as a World '+
'Heritage Site.</p>'+
'<p>Attribution: Uluru, <a href="http://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194">'+
'http://en.wikipedia.org/w/index.php?title=Uluru</a> (last visited June 22, 2009).</p>'+
'</div>'+
'</div>';var infowindow = new google.maps.InfoWindow({
content: contentString
});var er = new google.maps.Marker({
position: myLatlng,
map: map,
title:"Uluru (Ayers Rock)"
});google.maps.event.addListener(er, 'click', function() {
infowindow.open(map,er);
});
但是假如我有个很多个er的话 还调的过来吗
对于单个er 我基本上了解了
我现在就是想有多个er
而且可以根据搜索等到相应的er
而且可以根据搜索等到相应的er
“多个er和相应的弹出框内容放到数组里,循环往地图上加er就好了”这样的话,假如我有1000个er需要加在map上,分布是全世界各地的,那是从后台一次性取出这些er的信息,放入数组吗?这样性能上没有压力吗?
“而且可以根据搜索等到相应的er”
不好意思,我写错了,是搜索得到相应的er
http://gmaps-samples-v3.googlecode.com/svn/trunk/toomanyers/toomanyers.html
http://code.google.com/apis/maps/documentation/javascript/maptypes.html#TileCoordinates我没有具体做过但是感觉就是每次你改变地图的位置,根据你div的大小(像素)来找显示的范围,最后去你自己的数据库查询。可能麻烦了点,还不如一次加载算了。
GMAP还提供一个自定义地图的功能。用你的GOOGLE用户帐号登录GMAP,有个个人地图管理。在里面可以建立N个自定义的地图。每个地图里可以建立若干个标记点,并对标记点添加说明。每个自定义地图有个编号,GMAP会为你生成引用的代码,只需要复制下来,使用时粘贴过去,载入地图就是你所编辑的区域和该区域里那些自定义标记。如果有多个区域,可以分别建立不同的自定义地图,引用时切换不同代码即可。