在单击事件上返回带有 google 街景的地址栏中的地址
Returning the address in the address box with google street view on a click event
使用 Google 地图 API 我可以 return 使用 navigator.geolocation.getCurrentPosition
当前位置的街景。这会在 属性 图像左角的框中弹出地址,以及 'View in Google maps' link.
有没有办法覆盖标准点击事件并捕获框中的地址(第一行)?一旦我可以在警报中显示它,其余的就会随之而来。
那个地址是 StreetViewLocation description.
当 location_changed
事件在 panorama
上触发时访问它:
panorama.getLocation().description
location_changed
听众:
panorama.addListener('location_changed', function() {
var descriptionCell = document.getElementById('description');
descriptionCell.innerHTML = panorama.getLocation().description + '';
});
(function(exports) {
"use strict";
function initialize() {
exports.panorama = new google.maps.StreetViewPanorama(
document.getElementById("street-view"), {
position: {
lat: 37.86926,
lng: -122.254811
},
pov: {
heading: 165,
pitch: 0
},
zoom: 1
}
);
panorama.addListener('position_changed', function() {
var positionCell = document.getElementById('position');
positionCell.innerHTML = panorama.getPosition() + '';
});
panorama.addListener('location_changed', function() {
var descriptionCell = document.getElementById('description');
descriptionCell.innerHTML = panorama.getLocation().description + '';
});
}
exports.initialize = initialize;
})((this.window = this.window || {}));
html,
body {
height: 100%;
margin: 10;
padding: 0;
}
#street-view {
height: 90%;
}
<title>Street View Containers</title>
<script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=&callback=initialize&libraries=&v=weekly" defer></script>
<div id="info"></div>
<div id="description"></div>
<div id="position"></div>
<div id="heading"></div>
<div id="pitch"></div>
<div id="street-view"></div>
使用 Google 地图 API 我可以 return 使用 navigator.geolocation.getCurrentPosition
当前位置的街景。这会在 属性 图像左角的框中弹出地址,以及 'View in Google maps' link.
有没有办法覆盖标准点击事件并捕获框中的地址(第一行)?一旦我可以在警报中显示它,其余的就会随之而来。
那个地址是 StreetViewLocation description.
当 location_changed
事件在 panorama
上触发时访问它:
panorama.getLocation().description
location_changed
听众:
panorama.addListener('location_changed', function() {
var descriptionCell = document.getElementById('description');
descriptionCell.innerHTML = panorama.getLocation().description + '';
});
(function(exports) {
"use strict";
function initialize() {
exports.panorama = new google.maps.StreetViewPanorama(
document.getElementById("street-view"), {
position: {
lat: 37.86926,
lng: -122.254811
},
pov: {
heading: 165,
pitch: 0
},
zoom: 1
}
);
panorama.addListener('position_changed', function() {
var positionCell = document.getElementById('position');
positionCell.innerHTML = panorama.getPosition() + '';
});
panorama.addListener('location_changed', function() {
var descriptionCell = document.getElementById('description');
descriptionCell.innerHTML = panorama.getLocation().description + '';
});
}
exports.initialize = initialize;
})((this.window = this.window || {}));
html,
body {
height: 100%;
margin: 10;
padding: 0;
}
#street-view {
height: 90%;
}
<title>Street View Containers</title>
<script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=&callback=initialize&libraries=&v=weekly" defer></script>
<div id="info"></div>
<div id="description"></div>
<div id="position"></div>
<div id="heading"></div>
<div id="pitch"></div>
<div id="street-view"></div>