开发者

Detect if Google Satellite Images Available

Using the Google Maps API is it possible to detect whether or not satellite tiles will be available given coordinat开发者_开发知识库es and a zoom level?


Yes, it is possible. Read the "Maximum Zoom Imagery" section of the Google Maps API v3 for an explanation and a code sample.

http://code.google.com/apis/maps/documentation/javascript/services.html#MaxZoom

Here is the sample code from that documentation that "shows a map of metropolitan Tokyo. Clicking anywhere on the map indicates the maximum zoom level at that location. (Zoom levels around Tokyo generally vary between zoom levels 18 and 21.)"

var map;
var maxZoomService = new google.maps.MaxZoomService();

var tokyo = new google.maps.LatLng(35.6894875, 139.6917064);

function initialize() {
  var mapOptions = {
    zoom: 11,
    center: tokyo,
    mapTypeId: google.maps.MapTypeId.HYBRID
  }
  map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

  google.maps.event.addListener(map, 'click', showMaxZoom);
}

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);
  });
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜