<title>Google Maps JavaScript API Example: Street"> <title>Google Maps JavaScript API Example: Street"> <title>Google Maps JavaScript API Example: Street" />

URL parseren in api van Google Street View

Dit is een werkend voorbeeld van Street View API V3:

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example: Street View Events</title>
<link href="/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"
        type="text/javascript"></script>
<script type="text/javascript">

  var cafe = new google.maps.LatLng(37.869085,-122.254775);

  function initialize() {

    var panoramaOptions = {
      position: cafe,
      pov: {
        heading: 270,
        pitch: 0,
        zoom: 1
      },
      visible: true
    };
    var panorama = new google.maps.StreetViewPanorama(document.getElementById("pano"), panoramaOptions);

    google.maps.event.addListener(panorama, 'pano_changed', function() {
        var panoCell = document.getElementById('pano_cell');
        panoCell.innerHTML = panorama.getPano();
    });

    google.maps.event.addListener(panorama, 'links_changed', function() {
        var linksTable = document.getElementById('links_table');
        while(linksTable.hasChildNodes()) {
          linksTable.removeChild(linksTable.lastChild);
        };
        var links =  panorama.getLinks();
        for (var i in links) {
          var row = document.createElement("tr");
          linksTable.appendChild(row);
          var labelCell = document.createElement("td");
          labelCell.innerHTML = "Link: " + i + "";
          var valueCell = document.createElement("td");
          valueCell.innerHTML = links[i].description;
          linksTable.appendChild(labelCell);
          linksTable.appendChild(valueCell);
        }
    });

    google.maps.event.addListener(panorama, 'position_changed', function() {
        var positionCell = document.getElementById('position_cell');
        positionCell.firstChild.nodeValue = panorama.getPosition();
    });

    google.maps.event.addListener(panorama, 'pov_changed', function() {
        var headingCell = document.getElementById('heading_cell');
        var pitchCell = document.getElementById('pitch_cell');
        headingCell.firstChild.nodeValue = panorama.getPov().heading;
        pitchCell.firstChild.nodeValue = panorama.getPov().pitch;
    });
}
</script>
</head>
<body onload="initialize()">
  <div id="pano" style="width: 425px; height: 240px;float:left"></div>
  <div id="panoInfo" style="width: 425px; height: 240 px;float:left">
  <table>
  <tr>
    <td>Position</td><td id="position_cell"> </td>
  </tr>
  <tr>
    <td>POV Heading</td><td id="heading_cell">270</td>
  </tr>
  <tr>
    <td>POV Pitch</td><td id="pitch_cell">0.0</td>
  </tr>
  <tr>
    <td>Pano ID</td><td id="pano_cell"> </td>
  </tr>
  <table id="links_table">
  </table>
  </table>
  </div>
</body>
</html>

I've been searching all day on how to parse a Google maps street view url into a Google maps street view embed javascript, but I dont seem to find a solution anywhere, need to parse something like this: http://maps.google.com/?ll=37.588929,-87.337506&spn=1.201384,1.766052&t=m&z=9&layer=c&cbll=37.588929,-87.337506&panoid=C0tiQOjXuQtNmZRPkHbVxw&cbp=12,154.39,,0,-4.06

0

2 antwoord

Er is een querystringbibliotheek: https://github.com/visionmedia/node-querystring . Werkt in node.js en in de browser.

1
toegevoegd

panoropositie = 37.588929, -87.337506 de "ll =" Het lijkt erop dat "cbp =" u kop, hoogte en zoom geeft

http://www.geocodezip.com/v3_GoogleEx_streetview-simpleA.htm

Zie deze pagina op mapki.com voor hun betekenis.

UPDATE (Mapki.com lijkt verdwenen): Volgens deze site :

De 5 delen van "cbp =" zijn venstergrootte, koers (peiling), kanteling, zoom en pitch (in die volgorde).

0
toegevoegd