思路是在window.onload中当检测到加载Roboto字体时,skip掉就可以了。

如下:

 var head = document.getElementsByTagName('head')[0];// Save the original methodvar insertBefore = head.insertBefore;// Replace it!head.insertBefore = function (newElement, referenceElement) {if (newElement.href && newElement.href.indexOf('fonts.googleapis.com/css?family=Roboto') > 0) {console.info('Prevented Roboto from loading!');return;}insertBefore.call(head, newElement, referenceElement);};

完整代码如下:

<script type="text/javascript">var map, geocoder, bounds;//, marker, infowindow;window.onload = function() {var head = document.getElementsByTagName('head')[0];// Save the original methodvar insertBefore = head.insertBefore;// Replace it!head.insertBefore = function (newElement, referenceElement) {if (newElement.href && newElement.href.indexOf('fonts.googleapis.com/css?family=Roboto') > 0) {console.info('Prevented Roboto from loading!');return;}insertBefore.call(head, newElement, referenceElement);};// Creating a new mapvar options = {zoom: 10,center: new google.maps.LatLng(27.9679125,120.7272096),mapTypeId: google.maps.MapTypeId.ROADMAP,panControl: true,streetViewControl: false,scaleControl: true};map = new google.maps.Map(document.getElementById('map_canvas'), options);// Making the Geocoder callgetCoordinates("Parallelweg 2, Groenlo, Netherlands", "PR50S");return true;}// Create a function the will return the coordinates for the addressfunction getCoordinates(address, name) {// Check to see if we already have a geocoded object. If not we create oneif (!geocoder) {geocoder = new google.maps.Geocoder();}if (!bounds) {bounds = new google.maps.LatLngBounds();}// Creating a GeocoderRequest objectvar geocoderRequest = {address: address}// Making the Geocode requestgeocoder.geocode(geocoderRequest, function(results, status) {// Check if status is OK before proceedingif (status == google.maps.GeocoderStatus.OK) {// Center the map on the returned location//map.setCenter(results[0].geometry.location);// Creating a new marker and adding it to the map// at the position of the marker to the returned locationvar marker = new google.maps.Marker({map: map,position: results[0].geometry.location});if (name) {// Creating a new InfoWindowvar infoWindow = new google.maps.InfoWindow();// Creating the content of the InfoWindow to the address and the returned positionvar content = '<strong>' + name + '</strong><br />';content += '<strong>' + address + '</strong><br />';// Adding the content to the InfoWindowinfoWindow.setContent(content);// Opening the InfoWindow//infoWindow.open(map, marker);google.maps.event.addListener(marker, 'click', function() {infoWindow.open(map, marker);});}// Extend bounds to contain new markerbounds.extend(marker.getPosition());//bounds.extend(infoWindow.getPosition());map.fitBounds(bounds);}// Zoom out a little more to see some surroundingsmap.setZoom(map.getZoom() - 5);});}</script>

如何防止google map 加载Roboto字体相关推荐

  1. 加载elementor时出现问题_禁止elementor插件加载谷歌字体

    WordPress好几款不错的可视化编辑器插件,其中我个人最爱elementor了,现在如果要买主题,都会看是否支持使用elementor了,elementor有免费和专业版本,我们一般用免费版本就可 ...

  2. 怎么禁止WordPress后台加载谷歌字体?

    怎么禁止WordPress后台加载谷歌字体?最近发现登录WordPress后台异常缓慢,经常卡在fonts.googleapis.com,这是由于Wordpress后台外链加载了谷歌字体(代码位置在w ...

  3. 禁止古腾堡编辑器加载谷歌字体,WordPress编辑器加载很慢的解决办法

    用习惯了WordPress的古腾堡编辑器,真的不想再用回经典编辑器了. 近日看到很多用户说古腾堡编辑器加载好慢,后台发布个文章都费事,无奈之下又换回了经典编辑器. 这是因为古腾堡编辑器加载了谷歌字体C ...

  4. Google图片加载库Glide的简单封装GlideUtils

    Google图片加载库Glide的简单封装GlideUtils  

  5. html内嵌样式字体,html-通过内联C加载外部字体

    是否可以使用内嵌CSS加载外部字体? 不适用于外部CSS文件[....]. 是的,您可以按照Stephen Scaff的本文中的文章所示,对base64字体进行编码,然后将其放入页面的style块中, ...

  6. js加载第三方字体,检测加载完成事件

    最近在做一个项目涉及到加载第三方字体的问题,首批需要支持一百多种字体,然后首先想到的就是@fant-face,但是在实际应用中发现无法满足当前需求. 目前的项目是用canvas的一个开源库fabric ...

  7. html字体库otf文件使用,在webpack中加载.otf字体文件的正确方法是什么?

    使用webpack时加载.otf字体文件的适当方式是什么?我曾多次尝试包括在我的webpack.config.js的规则,没有任何成功的基础上,很多例子我大致如下的线路看出:对于在webpack中加载 ...

  8. 前端加载自定义字体及速度优化

    今天是2.14情人节,也是另一个重要的日子,那就是我的第一个全栈项目上线啦~~~ www.daren.com 这个是公司的官网,采用Python+Django做后端,前端也用了gulp自动化工作流,使 ...

  9. 微信小程序加载第三方字体

    1.加载本地字体 做小程序项目时,有时为了提升页面展示效果,会引入一些第三方字体,引入方式如下代码片段 /*每个页面公共css */ @font-face {font-family: "al ...

  10. java加载字体文件_Java的加载自定义字体文件(.TTF)

    我在下面这段代码中使用,并将其与该堆栈跟踪出现:Java的加载自定义字体文件(.TTF) java.io.FileNotFoundException: font.ttf (No such file o ...

最新文章

  1. (转)eclipse 代码自动补全
  2. 中国芯片首富捐资200亿办大学!落地宁波镇海,拟名「东方理工」
  3. C#开发WPF/Silverlight动画及游戏系列教程(Game Tutorial):(十一)地图遮罩层的实现
  4. H.264/AVC视频压缩编码标准的新进展
  5. 第一章 计算机网络 6 OSI参考模型 [计算机网络笔记]
  6. linux 串口信息记到日志,[linux学习笔记]之一:ubuntu ch340调试备忘
  7. 短线买股赚钱的概率有多大?python带你来分析
  8. 剑指offer——面试题35:第一个只出现一次的字符
  9. 每天一道剑指offer-二叉搜索树与双向链表
  10. 阿里云云计算 46 阿里云DDoS防护
  11. Ubuntu安装sqlmap
  12. 基于SSM的网上购物系统的设计与开发
  13. 使用HttpClient4来构建Spring RestTemplate
  14. kappa一致性检验教程_Kappa系数一致性检验和配对卡方检验SPSS图文详解
  15. php 786.00,美國佛羅裡達州區號786
  16. 什么是熔断? 熔断有哪几种状态 断路器的工作原理、如何开启熔断?
  17. source insight 4.0 使用make命令编译
  18. 运筹说 第75期 | 数学家欧拉也玩跨界
  19. 小企业如何利用区块链和大数据获利?
  20. 例5.8求Fibonacci(斐波那契)数列的前40个数。

热门文章

  1. win98万能显卡驱动_万能显卡驱动下载
  2. iOS的音频文件的格式转换
  3. 第55章、播放视频(从零开始学Android)
  4. vb 访问远程mysql_VB连接远程数据库
  5. Vysor 1.7.6 chrome 插件破解
  6. 计算机音乐apple,Apple Music苹果音乐电脑版
  7. loadrunner11下载
  8. win10家庭版下loadrunner11安装
  9. 用Wineskin 让Windows 的程序在Mac 上运行
  10. jlink6.80a烧写序列号(serial number)问题记录