我正在尝试自定义Google地图的信息窗口,但我无法删除白框。
有人可以帮助我吗?
代码(CSS):
import { Component, OnInit, Input } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import { AngularFireDatabase } from 'angularfire2/database';
import { AngularFirestore, AngularFirestoreCollection, AngularFirestoreDocument } from 'angularfire2/firestore';
import { AuthService } from '../../services/auth.service';
import { Invoice } from '../invoiceModel';
@Component({
selector: 'app-view-invoice',
templateUrl: './view-invoice.component.html',
styleUrls: ['./view-invoice.component.scss']
})
export class ViewInvoiceComponent implements OnInit {
userId: string;
invoiceId: any;
invoicesCollection: AngularFirestoreCollection<Invoice>;
invoices: Observable<Invoice[]>;
invoice: Observable<Invoice>;
constructor(private authService: AuthService, private db: AngularFirestore, private route: ActivatedRoute) {
this.userId = this.authService.user.uid;
this.route.params.subscribe(params => {
this.invoiceId = params.id;
})
this.invoicesCollection = this.db.collection('/invoices');
this.invoices = this.invoicesCollection.snapshotChanges().map(changes => {
return changes.map(a => {
const data = a.payload.doc.data() as Invoice;
data.id = a.payload.doc.id;
return data;
})
})
}
ngOnInit() {
this.getInvoice();
}
getInvoice() {
var docref = this.db.collection('/users').doc(this.authService.user.uid).collection('/invoices').doc(this.invoiceId);
docref.ref.get()
.then(function(doc) {
if (doc.exists) {
var invoice = doc.data(); <------WORKS
// this.invoice = doc.data(); <------DOESN'T WORK
console.log('Invoice data: ', doc.data());
} else {
console.error('No matching invoice found');
}
})
}
}
答案 0 :(得分:2)
将/*Code to remove arrow and close button*/
下的规则替换为:
.gm-style div div div div div div div {
visibility: hidden;
}
.gm-style-iw + div {
display: none;
}
.gm-style div div div div div div.gm-style-iw div div {
visibility: visible;
}
第一条规则隐藏了白框,但也隐藏了黑色信息窗口中的文字,因此第三条规则使文字再次可见。
看一下this JSBin,看一个有效的例子。