大佬教程收集整理的这篇文章主要介绍了Google Maps v3-防止API加载Roboto字体,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
您可以在Google脚本调用它之前替换insertBefore方法:
var head = document.getElementsByTagname('head')[0];
// Save the original method
var insertBefore = head.insertBefore;
// replace it!
head.insertBefore = function (newElement, referenceElement) {
if (newElement.href && newElement.href.indexOf('//Fonts.GoogleAPIs.com/CSS?family=Roboto') > -1) {
console.info('Prevented Roboto from loading!');
return;
}
insertBefore.call(head, newElement, referenceElement);
};
// check it!
new Google.maps.Map(document.getElementByID('map'), {
center : new Google.maps.LatLng(51.508742,-0.120850),
zoom : 16,
mapTypEID : Google.maps.MapTypEID.roaDMAP,
streetVIEwControl: false,
zoomControl : false,
panControl : false,
mapTypeControl : false
});
Google会在地图容器中添加覆盖我的样式的样式。
我知道该如何解决。但是API(v3.8 / 9 / exp)也会加载我实际上不需要/想要的webfont“ Roboto”。
是否有任何设置/选项/方法?
我可以阻止API添加额外的CSS吗?
这是google-maps-API添加到<head>
我页面的代码:
<style type="text/css">
.gm-style .gm-style-cc span,.gm-style .gm-style-cc a,.gm-style .gm-style-mtc div {
font-size:10px
}
</style>
<link type="text/css"
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700">
<style type="text/css">
@media print {
.gm-style .gmnoprint,.gmnoprint {
display:none
}
}
@media screen {
.gm-style .gmnoscreen,.gmnoscreen {
display:none
}
}
</style>
<style type="text/css">
.gm-style {
font-family: Roboto,Arial,sans-serif;
font-size: 11px;
font-weight: 400;
text-decoration: none
}
</style>
以上是大佬教程为你收集整理的Google Maps v3-防止API加载Roboto字体全部内容,希望文章能够帮你解决Google Maps v3-防止API加载Roboto字体所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。