我的自定义Google地图存在问题。它没有显示街道名称。
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script>
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(42.753633, 13.952404),
zoom: 10,
mapTypeId: google.maps.MapTypeId.SATELLITE,
scrollwheel: true
}
var map = new google.maps.Map(document.getElementById('google-map'), mapOptions);
var ctaLayer = new google.maps.KmlLayer({
url: 'http://128.199.209.42/klinkfiles/mlmsurvey.kmz'
});
ctaLayer.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
<body onload="initialize()">
<div id="google-map" class="google-map"></div>
答案 0 :(得分:0)
如果您想要地图图块上的街道名称,请不要请求SATELLITE地图类型,您需要HYBRID。
var mapOptions = {
center: new google.maps.LatLng(42.753633, 13.952404),
zoom: 10,
mapTypeId: google.maps.MapTypeId.HYBRID,
scrollwheel: true
}
代码段
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(42.753633, 13.952404),
zoom: 10,
mapTypeId: google.maps.MapTypeId.HYBRID,
scrollwheel: true
}
var map = new google.maps.Map(document.getElementById('google-map'), mapOptions);
var ctaLayer = new google.maps.KmlLayer({
url: 'http://128.199.209.42/klinkfiles/mlmsurvey.kmz'
});
ctaLayer.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
html,
body,
#google-map {
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
}
<script src="https://maps.googleapis.com/maps/api/js"></script>
<div id="google-map"></div>