Google StreetView/Maps API
Google StreetView/Maps API
我正在尝试在 Google 街景视图上叠加标记。我可以在 Google 地图上找到标记,但它没有显示在 GSV 中。
https://jsfiddle.net/gnxnm4nt/
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
<script>
function initialize() {
var baltimore = new google.maps.LatLng(39.283024, -76.601765);
var baltimore1 = new google.maps.LatLng(39.283223, -76.601851);
var mapOptions = {
center: baltimore,
zoom: 14
};
var map = new google.maps.Map(
document.getElementById('map-canvas'), mapOptions);
var cafeMarker = new google.maps.Marker({
position: baltimore1,
map: map,
icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=cafe|FFFF00',
title: 'Cafe'
});
var panoramaOptions = {
position: baltimore,
pov: {
heading: 34,
pitch: 10
}
};
var panorama = new google.maps.StreetViewPanorama(document.getElementById('pano'), panoramaOptions);
map.setStreetView(panorama);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
API参考:https://developers.google.com/maps/documentation/javascript/examples/streetview-overlays
https://developers.google.com/maps/documentation/javascript/examples/streetview-embed
谢谢!请检查我的 fiddle 以了解我到目前为止所获得的信息。应该是出现在回旋处的标记。
您还必须将标记添加到街景(并且与地图上的标记不同)。
var cafeMarker2 = new google.maps.Marker({
position: baltimore1,
map: panorama,
icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=cafe|FFFF00',
title: 'Cafe'
});
代码片段:
function initialize() {
var baltimore = new google.maps.LatLng(39.283024, -76.601765);
var baltimore1 = new google.maps.LatLng(39.283223, -76.601851);
var mapOptions = {
center: baltimore,
zoom: 14
};
var map = new google.maps.Map(
document.getElementById('map-canvas'), mapOptions);
var cafeMarker = new google.maps.Marker({
position: baltimore1,
map: map,
icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=cafe|FFFF00',
title: 'Cafe'
});
var panoramaOptions = {
position: baltimore,
pov: {
heading: 4,
pitch: 10
}
};
var panorama = new google.maps.StreetViewPanorama(document.getElementById('pano'), panoramaOptions);
var cafeMarker2 = new google.maps.Marker({
position: baltimore1,
map: panorama,
icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=cafe|FFFF00',
title: 'Cafe'
});
map.setStreetView(panorama);
}
google.maps.event.addDomListener(window, 'load', initialize);
html,
body,
#map-canvas {
height: 100%;
margin: 0;
padding: 0;
}
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk"></script>
<div id="map-canvas" style="width: 45%; height: 100%;float:left"></div>
<div id="pano" style="width: 45%; height: 100%;float:left"></div>
我正在尝试在 Google 街景视图上叠加标记。我可以在 Google 地图上找到标记,但它没有显示在 GSV 中。
https://jsfiddle.net/gnxnm4nt/
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
<script>
function initialize() {
var baltimore = new google.maps.LatLng(39.283024, -76.601765);
var baltimore1 = new google.maps.LatLng(39.283223, -76.601851);
var mapOptions = {
center: baltimore,
zoom: 14
};
var map = new google.maps.Map(
document.getElementById('map-canvas'), mapOptions);
var cafeMarker = new google.maps.Marker({
position: baltimore1,
map: map,
icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=cafe|FFFF00',
title: 'Cafe'
});
var panoramaOptions = {
position: baltimore,
pov: {
heading: 34,
pitch: 10
}
};
var panorama = new google.maps.StreetViewPanorama(document.getElementById('pano'), panoramaOptions);
map.setStreetView(panorama);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
API参考:https://developers.google.com/maps/documentation/javascript/examples/streetview-overlays https://developers.google.com/maps/documentation/javascript/examples/streetview-embed
谢谢!请检查我的 fiddle 以了解我到目前为止所获得的信息。应该是出现在回旋处的标记。
您还必须将标记添加到街景(并且与地图上的标记不同)。
var cafeMarker2 = new google.maps.Marker({
position: baltimore1,
map: panorama,
icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=cafe|FFFF00',
title: 'Cafe'
});
代码片段:
function initialize() {
var baltimore = new google.maps.LatLng(39.283024, -76.601765);
var baltimore1 = new google.maps.LatLng(39.283223, -76.601851);
var mapOptions = {
center: baltimore,
zoom: 14
};
var map = new google.maps.Map(
document.getElementById('map-canvas'), mapOptions);
var cafeMarker = new google.maps.Marker({
position: baltimore1,
map: map,
icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=cafe|FFFF00',
title: 'Cafe'
});
var panoramaOptions = {
position: baltimore,
pov: {
heading: 4,
pitch: 10
}
};
var panorama = new google.maps.StreetViewPanorama(document.getElementById('pano'), panoramaOptions);
var cafeMarker2 = new google.maps.Marker({
position: baltimore1,
map: panorama,
icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=cafe|FFFF00',
title: 'Cafe'
});
map.setStreetView(panorama);
}
google.maps.event.addDomListener(window, 'load', initialize);
html,
body,
#map-canvas {
height: 100%;
margin: 0;
padding: 0;
}
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk"></script>
<div id="map-canvas" style="width: 45%; height: 100%;float:left"></div>
<div id="pano" style="width: 45%; height: 100%;float:left"></div>