Google Map API V3开发(4)
9 图层
Maps API 包含以下几种图层:
KmlLayer 对象,用于在 Maps API V3 图块叠加层中呈现 KML 和 GeoRSS 元素。
HeatmapLayer 对象,使用热图可视化技术来呈现地理数据。
FusionTablesLayer 对象,用于呈现 Google Fusion Tables 中包含的数据。
TrafficLayer 对象,用于呈现描述路况情况的图层和表示路况的叠加层。
TransitLayer 对象,用于在地图上显示您所在城市的公交网络。
WeatherLayer和CloudLayer 对象,可让您向地图添加天气预报和云图。
BicyclingLayer 对象,用于在公共图层中呈现自行车道的图层和/或自行车专用叠加层。默认情况下,在请求出行模式 BICYCLING 的路线时,系统会在DirectionsRenderer 中返回该图层。
PanoramioLayer 对象,用于添加 Panoramio 中的照片作为图层。
例:
var weatherLayer = new google.maps.weather.WeatherLayer({
temperatureUnits: google.maps.weather.TemperatureUnit.FAHRENHEIT
});
weatherLayer.setMap(map);
10 服务
? 路线服务
? 距离矩阵服务
? 海拔服务
? 地理编码服务
? 最大缩放图像服务
? 街景视图服务
路线服务
您可以使用 DirectionsService 对象计算路线(使用各种交通方式)。此对象与 Google Maps API 路线服务进行通信,该服务会接收路线请求并返回计算的结果。您可以自行处理这些路线结果,也可以使用 DirectionsRenderer 对象呈现这些结果。
您可以通过文本字符串(例如,“伊利诺斯州芝加哥市”或“澳大利亚新南威尔士州达尔文市”)或 LatLng 值的形式来指定路线的起点和终点。路线服务可以使用一系列路标返回多段路线。路线可以显示为一条在地图上绘制路线的折线,此外,也可以显示为 <div> 元素中的一些文字说明(例如,“右转上中山南路”)。
距离矩阵服务
Google 的距离矩阵服务会使用给定的出行方式来计算多个起点和终点之间的行程距离和持续时间。
var origin1 = new google.maps.LatLng(55.930385, -3.118425);
var origin2 = "Greenwich, England";
var destinationA = "Stockholm, Sweden";
var destinationB = new google.maps.LatLng(50.087692, 14.421150);
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origins: [origin1, origin2],
destinations: [destinationA, destinationB],
travelMode: google.maps.TravelMode.DRIVING,
avoidHighways: false,
avoidTolls: false
}, callback);
function callback(response, status) {
// See Parsing the Results for the basics of a callback function.
}
海拔服务
海拔服务提供了地球表面位置的海拔数据,包含海底深处位置(返回负值)。在这些情况下,Google 无法提供您请求的确切位置的精确海拔测量值,该服务将插入并返回四个最近位置的平均值。
function getElevation(event) {
var locations = [];
var clickedLocation = event.latLng;
locations.push(clickedLocation);
var positionalRequest = {
'locations': locations
}
// Initiate the location request
elevator.getElevationForLocations(positionalRequest, function(results, status) {
if (status == google.maps.ElevationStatus.OK) {
// Retrieve the first result
if (results[0]) {
//do something
} else {
alert("No results found");
}
} else {
alert("Elevation service failed due to: " + status);
}
});
}
地理编码服务
地理编码是将地址(如“1600 Amphitheatre Parkway, Mountain View, CA”)转换为地理坐标(如纬度 37.423021 和经度 -122.083739)的过程,您可以根据该地理坐标放置标记或定位地图。
与此相反,将地图上的位置转换成易于理解的地址这一过程则称为“反向地理编码”。
最大缩放图像服务
Google Maps API 为地图类型图像提供了多种不同缩放级别的地图图块。大部分道路地图图像的缩放级别为 0 到 18(举例而言)。卫星图像的缩放级别更广,因为此类图像不是系统生成的,而是直接拍摄的。
在一些偏远地区(人口稀少的区域或公海区域)卫星图像并不能始终提供较高的缩放级别,因此您需要事先了解指定位置的图像的最高缩放级别。MaxZoomService 对象提供了一个简单的界面,供您查看 Google 地图为其提供卫星图像的给定位置的最大缩放级别。
function showMaxZoom(e) {
maxZoomService.getMaxZoomAtLatLng(e.latLng, function(response) {
if (response.status != google.maps.MaxZoomStatus.OK) {
alert("Error in MaxZoomService");
return;
} else {
alert("The maximum zoom at this location is: " + response.zoom);
}
map.setCenter(e.latLng);
});
}
街景视图服务
Google 街景视图提供了从指定道路对整个覆盖范围的 360 度全景视角。
var panoramaOptions = {
position: fenway,
pov: {
heading: 34,
pitch: 10,
zoom: 1
}
};
var panorama = new google.maps.StreetViewPanorama(document.getElementById("pano"), panoramaOptions);
map.setStreetView(panorama);
Google Map API V3开发(4)的更多相关文章
- Google Map API V3开发(1)
Google Map API V3开发(1) Google Map API V3开发(2) Google Map API V3开发(3) Google Map API V3开发(4) Google M ...
- Google Map API V3开发(2)
Google Map API V3开发(1) Google Map API V3开发(2) Google Map API V3开发(3) Google Map API V3开发(4) Google M ...
- Google Map API V3开发(3)
Google Map API V3开发(1) Google Map API V3开发(2) Google Map API V3开发(3) Google Map API V3开发(4) Google M ...
- Google Map API V3开发(5)
Google Map API V3开发(1) Google Map API V3开发(2) Google Map API V3开发(3) Google Map API V3开发(4) Google M ...
- Google Map API V3开发(6) 代码
Google Map API V3开发(1) Google Map API V3开发(2) Google Map API V3开发(3) Google Map API V3开发(4) Google M ...
- Google map API V3
本文主要总结Google map API V3使用中最简单也是最常见的一些操作以及相关概念,如果需要更加详细的信息,请直接阅读Google提供的关于map的文档. google map api v3文 ...
- Google Map API V3调用arcgis发布的瓦片地图服务
由于最近项目需要用到CAD制作的地图,但之前一直使用的是用谷歌离线瓦片地图的方式,怎么样把CAD图像地图一样有缩放,移动的功能放到网页显示成了难题, 原先的谷歌地图的代码难道就不能用了?重新写一套代码 ...
- Google 地图 API V3 针对移动设备进行开发
Google官方教程: Google 地图 API V3 使用入门 Google 地图 API V3 针对移动设备进行开发 Google 地图 API V3 之事件 Google 地图 API V3 ...
- 如何使用Google Map API开发Android地图应用
两年前开发过的GoogleMap已经大变样,最近有项目要用到GoogleMap,重新来配置Android GoogleMap开发环境,还真是踩了不少坑. 一.下载Android SDK Manager ...
随机推荐
- MYSQL的常用命令和增删改查语句和数据类型
连接命令:<a href="http://lib.csdn.net/base/mysql" class='replace_word' title="MySQL知识库 ...
- javax.crypto.BadPaddingException: Given final block not properly padded 解决方法
下面的 Des 加密解密代码,在加密时正常,但是在解密是抛出错误: javax.crypto.BadPaddingException: Given final block not properly p ...
- 问题解决——MFC Ribbon 添加图标
=================================版权声明================================= 版权声明:本文为博主原创文章 未经许可不得转载 请通过右 ...
- Activemq Jolokia
打开JMX <broker … useJmx="true"> … <managementContext> <managementContext cre ...
- mac版本navicat连接oracle报错ORA-21561
最近电脑更换成mac,很多软件都和win不一样了,正在慢慢适应,连接oracle原来用的客户端是pl/sql develop,蛋疼的是没有了mac版本, 用了navicat,具体设置如下 1.新建连接 ...
- openstack命令备忘录
原文http://my.oschina.net/u/138210/blog/142661 查看rabbitmq 队列 rabbitmqctl list_queues 查看keystone的用户 key ...
- Nginx manifest 实现 HTML5 Application Cache
什么是Application Cache HTML5引入了应用程序缓存技术,意味着web应用可进行缓存,并在没有网络的情况下使用,通过创建cache manifest文件,可以轻松的创建离线应用. A ...
- 3. Python 简介
3. Python 简介 下面的例子中,输入和输出分别由大于号和句号提示符 ( >>> 和 ... ) 标注:如果想重现这些例子,就要在解释器的提示符后,输入 (提示符后面的) 那些 ...
- Win10 通过升级安装完成后出现了中文字体忽大忽小的问题解决。
解决方法: 下载Win10的中文语言包.
- C#基础-事件 继承类无法直接引发基类的事件
An event can be raised only from the declaration space in which it is declared. Therefore, a class c ...