gpt4 book ai didi

google-maps - 在Google Maps API中设置标签大小

转载 作者:行者123 更新时间:2023-12-04 05:23:12 26 4
gpt4 key购买 nike

这段代码是在标签点上设置标题,但是
如何更改字体大小?

label: {text: marcadores[i][0], color: 'black', TAGFORFONTSIZE: valuesize}

我的代码:
<html lang='es'> 
<head>
<meta charset='UTF-8'>
<style type='text/css'>
#mapa { height: 500px; }
</style>
<script type='text/javascript' src='http://maps.google.com/maps/api/js?sensor=false'></script>
<script type='text/javascript'>
function initialize() {
var marcadores = [
['usu1', -5.31987835340327, -52.8212431459598],
['usu4', 42.3617, -3.6789]
];

var map = new google.maps.Map(document.getElementById('mapa'), {
zoom: 7,
center: new google.maps.LatLng(41.503, -5.744),
mapTypeId: google.maps.MapTypeId.ROADMAP
});

var infowindow = new google.maps.InfoWindow();
var marker, i;

for (i = 0; i < marcadores.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(marcadores[i][1], marcadores[i][2]),
map: map,
label: {text: marcadores[i][0], color: 'black'}
});

google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(marcadores[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
}

google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id='mapa'></div>
</body>
</html>

最佳答案

the documentation:

fontSize Type: string

The font size of the label text (equivalent to the CSS font-size property). Default size is 14px.

marker = new google.maps.Marker({
position: new google.maps.LatLng(marcadores[i][1], marcadores[i][2]),
map: map,
label: {
text: marcadores[i][0],
color: 'black',
fontSize: "8px"
}
});
proof of concept fiddle
代码段:

function initialize() {
var marcadores = [
['usu1', -5.31987835340327, -52.8212431459598],
['usu4', 42.3617, -3.6789]
];
var map = new google.maps.Map(document.getElementById('mapa'), {
zoom: 7,
center: new google.maps.LatLng(41.503, -5.744),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < marcadores.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(marcadores[i][1], marcadores[i][2]),
map: map,
label: {
text: marcadores[i][0],
color: 'black',
fontSize: "8px"
}
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(marcadores[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
}
google.maps.event.addDomListener(window, 'load', initialize);
html,
body,
#mapa {
height: 100%;
width: 100%;
margin: 0px;
padding: 0px
}
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk"></script>
<div id="mapa"></div>

关于google-maps - 在Google Maps API中设置标签大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40490129/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com