Search code examples
javascriptarcgisesriarcgis-js-apiesri-maps

TextSymbol not working inside MapView(ESRI 4.3 arcgis)


The following is my code sample-

I tried rendering the map using the Picture Marker Symbol(as used in the example) and it works pretty well but if I use TextSymbol as mentioned in the documentation inside Graphic object, the application fails with the error saying TypeError: Cannot read property 'setTransform' of undefined and u is undefined. Can someone help me with what I'm doing wrong? Using Text Symbol Using Picture Marker Sumbol

    let mapProperties: any = {
        basemap: "streets",
        ground: "world-elevation"
      };

      let map: any = new Map(mapProperties);
      let constructMap = function (lat, long, popupTemplate) {
        var point = new Point({
          longitude: lat,
          latitude: long
        });
        var markerSymbol = new PictureMarkerSymbol({
          url: "https://unpkg.com/[email protected]/dist/images/marker-icon.png",
          width: "25px",
          height: "41px"
        });


        var textSym = new TextSymbol({
          text: "Sample Text"
        });
        console.log(textSym, markerSymbol);
        var pointGraphic = new Graphic({
          geometry: point,
          symbol: markerSymbol,
          popupTemplate: popupTemplate
        });
        var a = new MapView(mapViewProperties);

        a.graphics.add(pointGraphic);

Solution

  • Verify the order of the modules in your define, it must match the order of your function parameters exactly.