Google Maps V3:初始化街景+地理编码

时间:2013-10-23 14:10:56

标签: javascript google-maps

Daer我在项目中设置了Google地图并且工作正常。现在我想用“街景全景图”而不是标准图初始化以下脚本。

我在谷歌开发者身上找到了一个例子,但我无法将其与地理编码功能结合起来。

那么如果我想在此代码中初始化街景而不是标准地图呢?

  var geocoder;
  var map;
  function initialize() {
  geocoder = new google.maps.Geocoder();
  var latlng = new google.maps.LatLng(-34.397, 150.644);
  var mapOptions = {
  zoom: 16,
  center: latlng,
  mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
  }//*I need street view instead of standard map (StreetViewPanorama)

  function codeAddress() {
  var address = document.getElementById("address").value;
  geocoder.geocode( { 'address': address}, function(results, status) {
  if (status == google.maps.GeocoderStatus.OK) {
    map.setCenter(results[0].geometry.location);
    var marker = new google.maps.Marker({
        map: map,
        position: results[0].geometry.location
    });
   } else {
    alert("Geocode was not successful for the following reason: " + status);
  }
 });
 }

HTML

 <div id="map-canvas" style="width: 600px; height: 450px; float:right"></div>
 <div>
 <input id="address" type="text" value="Milan, Italy Viale Tunisia 30">
 </div>

0 个答案:

没有答案