<legend id='co1Kr'><style id='co1Kr'><dir id='co1Kr'><q id='co1Kr'></q></dir></style></legend>
    <i id='co1Kr'><tr id='co1Kr'><dt id='co1Kr'><q id='co1Kr'><span id='co1Kr'><b id='co1Kr'><form id='co1Kr'><ins id='co1Kr'></ins><ul id='co1Kr'></ul><sub id='co1Kr'></sub></form><legend id='co1Kr'></legend><bdo id='co1Kr'><pre id='co1Kr'><center id='co1Kr'></center></pre></bdo></b><th id='co1Kr'></th></span></q></dt></tr></i><div id='co1Kr'><tfoot id='co1Kr'></tfoot><dl id='co1Kr'><fieldset id='co1Kr'></fieldset></dl></div>

    <small id='co1Kr'></small><noframes id='co1Kr'>

      • <bdo id='co1Kr'></bdo><ul id='co1Kr'></ul>
    1. <tfoot id='co1Kr'></tfoot>

        用谷歌街景面对目标建筑

        时间:2023-09-25
      1. <tfoot id='WSUby'></tfoot>

            <i id='WSUby'><tr id='WSUby'><dt id='WSUby'><q id='WSUby'><span id='WSUby'><b id='WSUby'><form id='WSUby'><ins id='WSUby'></ins><ul id='WSUby'></ul><sub id='WSUby'></sub></form><legend id='WSUby'></legend><bdo id='WSUby'><pre id='WSUby'><center id='WSUby'></center></pre></bdo></b><th id='WSUby'></th></span></q></dt></tr></i><div id='WSUby'><tfoot id='WSUby'></tfoot><dl id='WSUby'><fieldset id='WSUby'></fieldset></dl></div>
                <legend id='WSUby'><style id='WSUby'><dir id='WSUby'><q id='WSUby'></q></dir></style></legend>
                  <tbody id='WSUby'></tbody>

              • <small id='WSUby'></small><noframes id='WSUby'>

                • <bdo id='WSUby'></bdo><ul id='WSUby'></ul>
                  本文介绍了用谷歌街景面对目标建筑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我的问题很简单.

                  我需要 heading 值才能知道如何定位 POV.

                  I need the heading value to know how to target the POV.

                  sv.getPanoramaByLocation() 在这种情况下返回一个 data 变量,其中包含两个箭头的 heading ,您可以在哪个方向上走得更远.

                  sv.getPanoramaByLocation() in this case returns a data variable containing the heading of both the arrows in which direction you can go further.

                  然而,它没有给我heading 值,用于查看建筑物的方式.但是可以在街景中使用标记来定位您的建筑物!示例

                  However it doesn't give me the heading value for which way to look at the building. However it is possible to use a marker in streetview to target your building! example

                  谁能帮我解决这个问题?我可以制作任何你想要的垃圾.

                  Can anyone help me with this? I can make whatever dump you people want.

                  推荐答案

                  对您要查看"的建筑物地址进行地理编码.使用几何库computeHeading(from:LatLng, to:LatLng) 函数计算街景位置和建筑物之间的方向.

                  Geocode the address of the building you want to "look at". Use the geometry library computeHeading(from:LatLng, to:LatLng) function to calculate the heading between the StreetView location and the building.

                  (假设地理编码器返回屋顶"地理编码)

                  (assumes that the geocoder returns a "rooftop" geocode)

                  示例(自由女神像)

                  另一种选择,使用路线服务:

                  相关问题:请求主路街景全景图而不是来自 API 的小巷

                  使用路线服务获取道路上的位置以用于街景相机"位置的代码片段(现在效果更好,您可以返回内部"街景位置):

                  code snippet that uses the directions service to get a location on the road to use for street view "camera" location (works better now that you can get "interior" streetview locations returned):

                  var map;
                  var berkeley = new google.maps.LatLng(37.869085, -122.254775);
                  var sv = new google.maps.StreetViewService();
                  var geocoder = new google.maps.Geocoder();
                  var directionsService = new google.maps.DirectionsService();
                  var panorama;
                  var myLatLng;
                  var address = "525 Beacon St. Boston, MA";
                  
                  function initialize() {
                  
                    panorama = new google.maps.StreetViewPanorama(document.getElementById("pano"));
                  
                  
                    directionsService.route({
                      origin: address,
                      destination: address,
                      travelMode: google.maps.TravelMode.DRIVING
                    }, function(response, status) {
                      if (status == google.maps.DirectionsStatus.OK) {
                        // myLatLng = response.routes[0].legs[0].start_location;
                        sv.getPanoramaByLocation(response.routes[0].legs[0].start_location, 50, processSVData);
                  
                        var marker = new google.maps.Marker({
                        position: response.routes[0].legs[0].start_location,
                        map: map,
                        title: "Directions"
                      });
                        map.setCenter(myLatLng);
                  
                  } else document.getElementById('info').innerHTML += "status:"+status+"<br>";
                    });
                  
                    geocoder.geocode({
                      'address': address
                    }, geocoderCallback);
                    
                    // Set up the map
                    var myOptions = {
                      zoom: 15
                    };
                  
                    map = new google.maps.Map(document.getElementById('map_canvas'),
                      myOptions);
                  }
                  google.maps.event.addDomListener(window, 'load', initialize);
                  
                  function processSVData(data, status) {
                    if (status == google.maps.StreetViewStatus.OK) {
                  
                      panorama.setPano(data.location.pano);
                      var camera = new google.maps.Marker({
                        position: data.location.latLng,
                        map: map,
                        draggable: true,
                        title: "camera"
                      });
                      var heading = google.maps.geometry.spherical.computeHeading(data.location.latLng, myLatLng);
                      document.getElementById('info').innerHTML += "heading:"+heading+"<br>"
                      + "location: "+myLatLng.toUrlValue(6)+"<br>"
                      + "camera:"+data.location.latLng.toUrlValue(6)+"<br>";
                      
                      
                      // alert(data.location.latLng+":"+myLatLng+":"+heading);
                      panorama.setPov({
                        heading: heading,
                        pitch: 0,
                        zoom: 1
                      });
                      panorama.setVisible(true);
                    } else {
                      alert("Street View data not found for this location.");
                    }
                  }
                  
                  function geocoderCallback(results, status) {
                    if (status == google.maps.GeocoderStatus.OK) {
                      myLatLng = results[0].geometry.location;
                      map.setCenter(myLatLng);
                      if (results[0].geometry.viewport) map.fitBounds(results[0].geometry.viewport);
                      else if (results[0].geometry.bounds) map.fitBounds(results[0].geometry.bounds);
                      else map.setZoom(15);
                      var marker = new google.maps.Marker({
                        position: myLatLng,
                        map: map,
                        title: address
                      });    
                  
                    } else {
                      alert("Geocode was not successful for the following reason: " + status);
                    }
                  };

                  html,
                  body {
                    height: 100%;
                    margin: 0;
                    padding: 0;
                  }
                  #map_canvas {
                    height: 100%;
                  }

                  <script src="http://maps.googleapis.com/maps/api/js?libraries=geometry"></script>
                  
                  <div id="pano" style="width: 425px; height: 400px;float:left"></div>
                  <div id="info"></div>
                  
                  <div id="map_canvas" style="width: 425px; height: 400px;float:left"></div>
                  <div id="map_center"></div>
                  <div id="streetview_pov"></div>

                  这篇关于用谷歌街景面对目标建筑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:谷歌地图:是多边形内的纬度/经度吗? 下一篇:查找邮政编码 10 英里范围内的城镇.谷歌地图AP

                  相关文章

                  最新文章

                    <legend id='1YQut'><style id='1YQut'><dir id='1YQut'><q id='1YQut'></q></dir></style></legend>
                      <bdo id='1YQut'></bdo><ul id='1YQut'></ul>
                    1. <i id='1YQut'><tr id='1YQut'><dt id='1YQut'><q id='1YQut'><span id='1YQut'><b id='1YQut'><form id='1YQut'><ins id='1YQut'></ins><ul id='1YQut'></ul><sub id='1YQut'></sub></form><legend id='1YQut'></legend><bdo id='1YQut'><pre id='1YQut'><center id='1YQut'></center></pre></bdo></b><th id='1YQut'></th></span></q></dt></tr></i><div id='1YQut'><tfoot id='1YQut'></tfoot><dl id='1YQut'><fieldset id='1YQut'></fieldset></dl></div>
                    2. <tfoot id='1YQut'></tfoot>

                      <small id='1YQut'></small><noframes id='1YQut'>