Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 谷歌地图视觉刷新-如何在InfoWindow中禁用字体机器人_Javascript_Css_Google Maps_Google Maps Api 3 - Fatal编程技术网

Javascript 谷歌地图视觉刷新-如何在InfoWindow中禁用字体机器人

Javascript 谷歌地图视觉刷新-如何在InfoWindow中禁用字体机器人,javascript,css,google-maps,google-maps-api-3,Javascript,Css,Google Maps,Google Maps Api 3,只需在google maps javascript API的新版本3.12中尝试新选项google.maps.visualRefresh=true。虽然地图的新外观很棒,但现在我的信息窗口中的文本使用的是Roboto字体大小 新的InfoWindow内容div CSS是: font-family: Roboto, Arial, sans-serif; font-size: 13px; font-weight: 300; 这不是以前的情况,我的网站设计根本不起作用。您知道如何删除它以使用我的正文

只需在google maps javascript API的新版本3.12中尝试新选项
google.maps.visualRefresh=true
。虽然地图的新外观很棒,但现在我的信息窗口中的文本使用的是Roboto字体大小

新的InfoWindow内容div CSS是:

font-family: Roboto, Arial, sans-serif;
font-size: 13px;
font-weight: 300;

这不是以前的情况,我的网站设计根本不起作用。您知道如何删除它以使用我的
正文中定义的默认字体吗?

您仍然可以在信息窗口中使用自己的字体。只需提供HTML内容而不是纯文本,就可以使用内嵌CSS或样式表以任何方式对其进行样式设置。例如:


使用HTML内容并按照中的建议设置样式

但是,您需要具有更高特定性的CSS规则。见此(分叉自):

#mapbox.myinfo{font-family:Georgia,serif;font-size:18px;}

如果你像我一样很懒,你可以通过增加一个来超越谷歌。简单地重新定义自己的邪恶风格附属于你的身体定义

~z~我在本例中使用的是SASS,但您可以通过将def放到根目录下,然后在一个“主体”上固定来滚动您自己的香草CSS~

html, body {
 font-family: Helvetica, Arial, sans-serif;
 # steal/borrow their own styles to be used against them.
 # in this example I have set the font to 'comical' size.
 .gm-style div,
 .gm-style span,
 .gm-style label,
 .gm-style a { font-family:Helvetica,Arial,sans-serif;font-size:200px;font-weight:2000}.gm-style div,
 .gm-style span,
 .gm-style label{text-decoration:none}.gm-style a,
 .gm-style label{display:inline}.gm-style div{display:block}.gm-style img{border:0;padding:0;margin:0}
}

这种方法相当脆弱,但肯定会很快用splix修补你不稳定的字体。这个答案可能不值得被标记为hackshop 3.1以外的任何东西。

使用javascript使用地图时,您可以使用javascript侦听器解决这个问题。将此片段粘贴到源代码中MAP html内容输出之前的
标记中(例如,像我一样粘贴在
部分中):

它不会将所有动态加载的调用“咬住”到标题中,因为谷歌在各种视图更新中使用的方法不同。这仅包括
head.insertBefore
方法


/仅在2017年的现代浏览器中,而不是ie8(但在mods中会)。适用于我们的案例,但我不知道这种方法是否会与其他东西产生干扰。

你很可能不会。尝试用CSS覆盖它,但我的钱是在Roboto是谷歌首选字体这一事实上。
.myinfo { font-family:Georgia,serif; font-size:18px; }
html, body {
 font-family: Helvetica, Arial, sans-serif;
 # steal/borrow their own styles to be used against them.
 # in this example I have set the font to 'comical' size.
 .gm-style div,
 .gm-style span,
 .gm-style label,
 .gm-style a { font-family:Helvetica,Arial,sans-serif;font-size:200px;font-weight:2000}.gm-style div,
 .gm-style span,
 .gm-style label{text-decoration:none}.gm-style a,
 .gm-style label{display:inline}.gm-style div{display:block}.gm-style img{border:0;padding:0;margin:0}
}
var head = document.getElementsByTagName('head')[0];
var insertBefore = head.insertBefore;
head.insertBefore = function (newElement, referenceElement){
    if(newElement.href && newElement.href.indexOf('//fonts.googleapis.com/css?family=Roboto') > -1) {
        console.info('Prevented Roboto font from loading!');
        return;
    }

    // intercept style elements for modern browsers
    if(newElement.tagName.toLowerCase() === 'style' && newElement.innerHTML.indexOf('.gm-style') > -1){
        console.info('Prevented .gm-style from loading!');
        return;
    }
    insertBefore.call(head, newElement, referenceElement);
};