Unverified Commit 983a7793 authored by Jacob Kaufman's avatar Jacob Kaufman Committed by GitHub
Browse files

Merge pull request #96 from kaitlyndlee/testing

Added test to LayerCollection and added DrawControl tests
parents 8ae6f0f0 46f26471
Loading
Loading
Loading
Loading
+15 −23
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ import React, { Component } from "react";
import AstroMap from "../../js/AstroMap";
import ProjectionControl from "../../js/ProjectionControl";
import MousePositionControl from "../../js/MousePositionControl";
import Draw from "../../js/Draw";
import AstroDrawControl from "../../js/AstroDrawControl";
import "leaflet";
//import newAutocomplete from "../../js/autocomplete/customIndex";

@@ -41,17 +41,13 @@ export default class MapContainer extends Component {
    let drawnItems = new L.FeatureGroup();
    map.addLayer(drawnItems);

    new Draw({
      draw: {
        circle: false,
        marker: false,
        circlemarker: false
      },
    map.addControl(
      new AstroDrawControl({
        edit: {
          featureGroup: drawnItems
      },
      targetMap: map
    }).addTo(map);
        }
      })
    );

    map.addControl(new L.Control.Scale({ imperial: false }));

@@ -90,17 +86,13 @@ export default class MapContainer extends Component {
    let drawnItems = new L.FeatureGroup();
    map.addLayer(drawnItems);

    new Draw({
      draw: {
        circle: false,
        marker: false,
        circlemarker: false
      },
    map.addControl(
      new AstroDrawControl({
        edit: {
          featureGroup: drawnItems
      },
      targetMap: map
    }).addTo(map);
        }
      })
    );

    map.addControl(new L.Control.Scale({ imperial: false }));
  }
+20 −16
Original line number Diff line number Diff line
import "leaflet";
import L from "leaflet";
import "leaflet-draw";
import Wkt from "wicket";

/**
 * @class AstroDraw
 * @aka L.Control.AstroDraw
 * @class AstroDrawControl
 * @aka L.Control.AstroDrawControl
 * @extends L.Control
 * @classdesc
 * Class that extends from the class L.Control.Draw and handles the back-end when a user draws on the leaflet map.
@@ -17,23 +17,23 @@ import Wkt from "wicket";
 * map.addLayer(drawnItems);
 *
 * // add draw control to map
 * let drawControl = new Draw({
 * let drawControl = new AstroDrawControl({
 *   edit: {
 *      featureGroup: drawnItems
 * },
 *    targetMap: map
 *   }
 * }).addTo(map);
 */
export default L.Control.AstroDraw = L.Control.Draw.extend({
export default L.Control.AstroDrawControl = L.Control.Draw.extend({
  options: {
    position: "topleft",
    draw: {},
    draw: { circle: false, marker: false, circlemarker: false },
    edit: false
  },

  /**
   * @function AstroDraw.prototype.onAdd
   * @description Adds the draw control to the map provided. Creates an on-draw and on-click event that allows users to draw polygons onto the leaflet map.
   * @function AstroDrawControl.prototype.onAdd
   * @description Adds the draw control to the map provided. Creates an on-draw and on-click event
   *              that allows users to draw polygons onto the leaflet map.
   * @param  {AstroMap} map - The AstroMap to add the control to.
   * @return {Object} The div-container the control is in.
   */
@@ -76,8 +76,10 @@ export default L.Control.AstroDraw = L.Control.Draw.extend({
  },

  /**
   * @function AstroDraw.prototype.shapesToWKT
   * @description Is called when a user draws a shape using the on map drawing features. Converts the shaped drawn into a Well-Known text string and inserts it into the Well-Known text box.
   * @function AstroDrawControl.prototype.shapesToWKT
   * @description Is called when a user draws a shape using the on map drawing features.
   *              Converts the shaped drawn into a Well-Known text string and inserts it into
   *              the Well-Known text box.
   * @param  {DomEvent} e  - On draw.
   */
  shapesToWKT: function(e) {
@@ -93,8 +95,10 @@ export default L.Control.AstroDraw = L.Control.Draw.extend({
  },

  /**
   * @function AstroDraw.prototype.mapWKTString
   * @description  Is called when a user clicks the draw button below the AstroMap. Will take the Well-Known text string and draw the shape onto the map. If the Well-Known text string is invalid an error will show in the text box.
   * @function AstroDrawControl.prototype.mapWKTString
   * @description  Is called when a user clicks the draw button below the AstroMap.
   *               Will take the Well-Known text string and draw the shape onto the map.
   *               If the Well-Known text string is invalid an error will show in the text box.
   * @param  {DomEvent} e  - On Click of Well-Known text button.
   */
  mapWKTString: function(e) {
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ export default L.LayerCollection = L.Class.extend({
    for (let i = 0; i < layers.length; i++) {
      let layer = layers[i];
      if (layer["primary"] == "true") {
        this._defaultLayerIndex = layers.length - 1;
        this._defaultLayerIndex = i;
      }
      let baseLayer = L.tileLayer.wms(
        String(layer["url"]) + "?map=" + String(layer["map"]),
+0 −0

File moved.

Loading