Example #1
0
      esriJson.forEach(feature => {
        if (feature.geometry) {
          var graphic = new Graphic(feature);
          //project geometry to web mercator if needed

          if (graphic.geometry.spatialReference.wkid === 4326){
            graphic.setGeometry(
              webMercatorUtils.geographicToWebMercator(graphic.geometry)
            );
          }

          // Set the symbolDictionary depending on the geometry type
          if (!!this.symbolDictionary) {
            graphic.setSymbol(
              this.symbolDictionary[graphic.geometry.type]
            );
          }
          else {
            return this.emit('queryDrawError', {
              message: 'No symbolDictionary for feature'
            });
          }

          // esriJsonLayer.push(graphic);
        }
      });
Example #2
0
          esriJson.forEach((feature) => {
            // create a graphic out of the feature
            const graphic = new Graphic(feature);

            // convert to webmercator if necessary
            if (graphic.geometry.spatialReference.wkid === 4326) {
              const wmGeom = webMercatorUtils.geographicToWebMercator(graphic.geometry);
              graphic.setGeometry(wmGeom);
            }

            // create a symbolMap above and get the symbol colors from that
            let graphicSymbol;
            switch (graphic.geometry.type) {
              case 'polygon':
                graphicSymbol = new SimpleFillSymbol(
                  SimpleLineSymbol.STYLE_SOLID,
                  new SimpleLineSymbol(
                    SimpleLineSymbol.STYLE_SOLID,
                    new Color('red'),
                    1
                  ),
                  new Color('blue'),
                );
                break;
              case 'point':
                graphicSymbol = new SimpleMarkerSymbol(
                  SimpleMarkerSymbol.STYLE_CIRCLE,
                  5,
                  new SimpleLineSymbol(
                    SimpleLineSymbol.STYLE_SOLID,
                    new Color('red'),
                    1
                  ),
                  new Color('blue'),
                );
                break;
            }
            graphic.setSymbol(graphicSymbol);

            const popup = {
              title: {
                [lang]: 'Feature Title (change later)'
              },
              content: {
                [lang]: []
              }
            };

            Object.keys(graphic.attributes).forEach(attribute => {
              popup.content[lang].push({
                label: attribute,
                fieldExpression: attribute,
              });
            });

            // const graphicInfoTemplate = new InfoTemplate('Attributes', '${*}');
            graphic.setInfoTemplate(layerUtils.makeInfoTemplate(popup, lang));

            esriLayer.add(graphic);
            // return graphic;
          });