How to set width and height of an image

2008
2
06-27-2016 12:53 PM
PavelVasilyev
New Contributor


Hi,

I'm trying to add an image to the map using Javascript API 3.16. But I can't apply width and height to the image.

When I'm adding the image, style attribute of the image is set to width, height of map style. So the image is stretched.

Here is the piece of code I'm using:

    require(["esri/layers/MapImageLayer",

            "esri/layers/MapImage"],

            function(MapImageLayer, MapImage) {

                var newImage = MapImage({

                            'extent': self.map.extent.toJson(),

                            'href': url

                        });

                newImage.width = width;

                newImage.height = height;

                var imageLayer = new MapImageLayer({

                                id: layer_id

                            });

                imageLayer.addImage(newImage);

                self.map.addLayer(imageLayer);

}

Tags (1)
0 Kudos
2 Replies
DanPatterson_Retired
MVP Emeritus

normally, if you set one, you let the other autoscale, ... at least in most arc* software

0 Kudos
PanagiotisPapadopoulos
Esri Regular Contributor

maybe you have to define the correct image extent for the selected image width and height

0 Kudos