昨天看了一下google map的调用方式,把一些重要的记录一下吧。
首先创建地图 var map=ne wGMap2(mapdiv);
然后, 可以加一个缩略图, map.addControl(new GOverviewMapControl ());
一般的会设置以某个地方为中心比如: map.setCenter(point, 13);而这个point对象是根据
new GLatLng(65.2, -27.1)来得到的(此处是故宫的位置)。
假如你需要通过名字来搜索,可以这样设置中心:
geocoder = new GClientGeocoder();
geocoder.getLatLng(center,function(point) {
if (!point) {
alert(center + "无法定位");
} else {
map.setCenter(point, 13);
}
}
);
这个GClientGeocoder对象就是用于解析地址的,getLatlng方法通过你传入的地址名,回调函数,给你返回poing对象。
一般在body onunload会调用 GUnload(),这个方法可以防止内存泄漏。
我们经常会看到假如你在地图上有一个地方,点击此图标,会有浮动层来显示详细信息,怎么办到的呢,很简单,需要Gmarker对象。
var markerOptions = {title:"测试"+count};
var marker=new GMarker(point,markerOptions);
map.addOverlay(marker);
//标记单击事件监听
GEvent.addListener(marker, "click", function() {
markMarker(marker);//处理marker被点击后的操作,下面有详细实现过程
});
function markMarker(marker){
var shtml= '<table width="383" border="0" cellpadding="0" cellspacing="0" bgcolor="#F4EFF5">' +
'<tr><td class="win3" colspan="2"><strong>景点</strong></td></tr>'+
'<tr><td class="win3" colspan="2">景点景点景点景点景点景点景点景点</td></tr>'+
'</table>';
marker.openInfoWindowHtml(shtml);
}
此时呢,点击你自定义的小图标(marker),则会弹出一个框(自动指向marker),然后显示详细信息。
大致的调用过程就是这样,细节的以后再补吧。
分享到:
相关推荐
Google Map API 接口调用。
Google mapGoogle mapGoogle mapGoogle mapGoogle mapGoogle mapGoogle map
google map 的应用实例,可以使用离线地图,很实用
googleMap__谷歌___地图_.ppt
该实例实现google map和ExtJs结合开发,实现图层管理、图层可见性控制、图层要素详细信息查看等功能。
googleMap根据经纬度获取地理位置,里面有使用代码,只需填入经纬度即可获取地理位置信息
谷歌MAP_V3中文详解以及一个简单例子
安卓 android google map 谷歌地图
谷歌地图Google Map API中文开发文档 V3
google map api 参考文档google map api 参考文档google map api 参考文档google map api 参考文档google map api 参考文档google map api 参考文档
Google Map API 使用示例
GOOGLE MAP api 7个案例。 CurrentAddress 得到当前位置 gMap 地形 路线 GoogleMapDemo 当前位置 MAP 绘制路线 MapView 放大缩小 WeatherMap 在MAP上添加图片 WorldCities 城市经纬度的切换 以及 动画切换效果
google mapgoogle mapgoogle mapgoogle mapgoogle mapgoogle map
同google map的geoserver用sld geoserver用的,可以拿来学习,也可以直接使用,覆盖掉原先的geoserver自带的sld就可以了 画出来的效果不错的说o(∩_∩)o...
Google Map MarkerCluster使用簡介 可使用此方式使marker自動表現群聚 相當的方便!
GoogleMap控件是一款开源控件。 下载
GoogleMap 开发源码
Google Map Reduce 中文版 论文 Google Map Reduce 中文版 论文 Google Map Reduce 中文版 论文
全面的对GoogleMap和BingMap 的地图API进行分析,如果是做地图开发或做自己的GIS平台,应该是有帮助的
下载googlemap,主要用于方便各位下载google地图