1

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

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

那么如果我想在这段代码中初始化街景而不是标准地图怎么办?

  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>
4

0 回答 0