首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >agm-map更改整个页面的字体

agm-map更改整个页面的字体
EN

Stack Overflow用户
提问于 2020-08-13 04:16:59
回答 1查看 53关注 0票数 0

我使用的agm-map与angular 9,当我的页面加载它加粗所有字体。我试着在没有agm-map的情况下测试我的前端,一切正常,但是当我添加特定的行时,它加粗了所有内容,这是我的代码

代码语言:javascript
复制
<mat-card class="example-card">
<agm-map
            class="temp"
            [latitude]="lat"
            [longitude]="lng"
            [zoom]="zoom"
          >
            <agm-marker [latitude]="lat" [longitude]="lng"></agm-marker>
          </agm-map>
        </mat-card>

我的css

代码语言:javascript
复制
agm-map {
  height: 450px !important;
  width: 100%; /* This is really important*/
}

before loading the map and after loading the map任何建议或任何人能指出我在这里做错了什么吗?非常感谢

EN

回答 1

Stack Overflow用户

发布于 2021-06-22 22:33:25

一种解决方案是通过指令阻止加载Google font //fonts.googleapis.com/css?family=Roboto

文件google-fonts-loading-disable.directive.ts

代码语言:javascript
复制
import { Directive } from '@angular/core';
    
@Directive({
  selector: '[appGoogleFontsLoadingDisable]'
})
export class GoogleFontsLoadingDisableDirective {
  constructor() {
    const head = document.getElementsByTagName('head')[0] as any;
    const insertBefore = head.insertBefore;
    head.insertBefore = function (newElement: any, referenceElement: any) {
      if (newElement.href && newElement.href.indexOf('//fonts.googleapis.com/css?family=Roboto') > -1) {
        return;
      }
      insertBefore.call(head, newElement, referenceElement);
    };
  }
}

添加在app.modules.ts中注册的指令

代码语言:javascript
复制
@NgModule({
declarations: [
    AppComponent,
    GoogleFontsLoadingDisableDirective,

并在Google地图中使用该指令

代码语言:javascript
复制
<agm-map appGoogleFontsLoadingDisable [latitude]="event.geo.lat" [longitude]="event.geo.lgtd" [zoom]="14" style="height: 60vh;">
    <agm-marker [latitude]="event.geo.lat" [longitude]="event.geo.lgtd" [label]="event.eventCd" [title]="event.eventCd+' '+event.eventCreatedDtm"></agm-marker>
</agm-map>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63384146

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档