日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

如何防止google map 加载Roboto字体

發布時間:2023/12/10 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 如何防止google map 加载Roboto字体 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

思路是在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字体的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。