Показать URL изображения, сохраненный в Firebase на изображении карты? - PullRequest
3 голосов
/ 13 января 2020

Мне нужна помощь для отображения изображения на изображении карты с URL-адресом, который я получаю из своей базы данных в firebase С помощью ключа я получаю информацию об узле и визуализирую различные объекты. С помощью ключа я получаю информацию об узле и визуализирую различные объекты. Я также получаю URL изображения, но я не знаю, как поместить URL на карту.

edit-regu.comp onet .ts

   @Component({
  selector: 'app-edit-regu',
  templateUrl: './edit-regu.component.html',
  styleUrls: ['./edit-regu.component.css']
})
export class EditReguComponent implements OnInit {

  visible = true;
  selectable = true;
  removable = true;
  addOnBlur = true;
  languageArray: Language[] = [];
  @ViewChild('chipList',{ static: false }) chipList;
  readonly separatorKeysCodes: number[] = [ENTER, COMMA];
  selectedBindingType: string;
  editBookForm: FormGroup;
  BindingType: any = ['Procesado', 'En Proceso', 'Informacion Erronea'];

  ngOnInit() {
    this.updateBookForm();
  }

  constructor(
    public fb: FormBuilder,    
    private location: Location,
    private bookApi: BookService,
    private actRoute: ActivatedRoute,
    private router: Router
  ) { 
    var id = this.actRoute.snapshot.paramMap.get('id');
    this.bookApi.GetBook(id).valueChanges().subscribe(data => {
      this.languageArray = data.languages;
      this.editBookForm.setValue(data);
    })
  }

  /* Update form */
  updateBookForm(){
    this.editBookForm = this.fb.group({
      name: ['', [Validators.required]],
      Fec_Dia: ['', [Validators.required]],
      Direccion: ['', [Validators.required]],
      Imagen: ['', [Validators.required]],
      Comentario: ['', [Validators.required]],
      Fec_Mili: ['', [Validators.required]],
      latitud: ['', [Validators.required]],
      longitud: ['', [Validators.required]],
      id: ['', [Validators.required]],
      Cedula:['', [Validators.required]],
      proceso: ['', [Validators.required]], 
      tipo_de_irregularidad: ['', [Validators.required]] 

    })
  }


  /* Get errors */
  public handleError = (controlName: string, errorName: string) => {
    return this.editBookForm.controls[controlName].hasError(errorName);
  }



  goBack(){
    this.location.back();
  }


  updateBook() {
    var id = this.actRoute.snapshot.paramMap.get('id');
    if(window.confirm('Are you sure you wanna update?')){
        this.bookApi.UpdateBook(id, this.editBookForm.value);
      this.router.navigate(['list-gad']);
    }
  }

}

edi-regu.component. html

<!-- Title group  -->
<div class="title-group">
    <h1 class="mat-h1">Procesar Irregularidad</h1>
    <mat-divider fxFlex="1 0"></mat-divider>
  </div>

  <!-- form -->
  <div class="inner-wrapper">
    <form [formGroup]="editBookForm" (ngSubmit)="updateBook()" novalidate>
      <mat-card>
        <div class="controlers-wrapper">
          <!-- Book name -->
          <mat-form-field class="example-full-width">

            <input matInput placeholder="Tipo de Irregularidad" formControlName="tipo_de_irregularidad">

          </mat-form-field>


          <mat-form-field class="example-full-width">
            <input matInput placeholder="Fecha" formControlName="Fec_Dia">
          </mat-form-field>


          <mat-form-field class="example-full-width">
            <input matInput placeholder="Dirección" formControlName="Direccion">
          </mat-form-field>


           <mat-form-field class="example-full-width">
            <input matInput placeholder="Emisor de Irregularidad" formControlName="name">
          </mat-form-field>



          <mat-form-field class="example-full-width">
            <textarea matInput placeholder="Comentario" formControlName="Comentario"> </textarea>
          </mat-form-field>

        </div>
      </mat-card>

      <mat-card>
        <div class="controlers-wrapper" >
          <!-- Book binding -->
          <mat-form-field>
            <mat-label>Estado del Proceso</mat-label>
            <mat-select [(value)]="selected" formControlName="proceso">
              <mat-option [value]="bindingType" *ngFor="let bindingType of BindingType">{{bindingType}}</mat-option>
            </mat-select>
          </mat-form-field>

          <mat-card class="example-card">

            **<!-- card image code -->** <img class="example-card" mat-card-image  ng-src="Imagen" alt="Imagen">
          </mat-card>

        </div>
      </mat-card>


      <!-- Submit & Reset -->
      <mat-card>
        <div class="full-wrapper button-wrapper">
          <div class="button-wrapper">
            <button mat-flat-button color="warn">Update</button>
            <button mat-flat-button color="war" type="button" (click)="goBack()">Go Back</button>
          </div>
        </div>
      </mat-card>
    </form>
  </div>

Screenshot of a site with inputs and a sidenav

Screenshot of a site with inputs, a sidenav and an image

1 Ответ

0 голосов
/ 13 января 2020

Просто добавьте [src]="urlVariable" в тег img.

В вашем случае

<img class="example-card" mat-card-image [src]="book.image_url" alt="Imagen">

[src] позволяет вам установить sr c изображения с помощью компонентной переменной.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...