geolocation-8.x-3.x-dev/modules/geolocation_google_maps/js/GoogleShapeMultiLine.js

modules/geolocation_google_maps/js/GoogleShapeMultiLine.js
import { GeolocationShapeMultiLine } from "../../../js/Base/GeolocationShapeMultiLine.js";
import { GoogleShapeTrait } from "./GoogleShapeTrait.js";
import { GeolocationCoordinates } from "../../../js/Base/GeolocationCoordinates.js";

/**
 * @prop {GoogleMaps} map
 *
 * @mixes GoogleShapeTrait
 */
export class GoogleShapeMultiLine extends GeolocationShapeMultiLine {
  constructor(geometry, settings = {}, map) {
    super(geometry, settings, map);

    Object.assign(this, GoogleShapeTrait);

    this.googleShapes = [];
    this.geometry.lines.forEach((lineGeometry) => {
      const line = new google.maps.Polyline({
        path: [
          lineGeometry.coordinates.map((value) => {
            return { lat: value[1], lng: value[0] };
          }),
        ],
        strokeColor: this.strokeColor,
        strokeOpacity: this.strokeOpacity,
        strokeWeight: this.strokeWidth,
      });

      if (this.title) {
        this.setTitle(line, this.title, this.map);
      }

      line.addListener("click", (event) => {
        this.click(new GeolocationCoordinates(event.latLng.lat(), event.latLng.lng()));
      });

      line.setMap(this.map.googleMap);

      this.googleShapes.push(line);
    });
  }

  remove() {
    this.googleShapes.forEach((googleShape) => {
      googleShape.setMap();
    });

    super.remove();
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc