Here is the function we currently use to add the point images onto our map:
function addGraphic() {
var point = new Point();
point.setLongitude(document.getElementById("lon").value);
point.setLatitude(document.getElementById("lat").value);
var infoTemplate = new InfoTemplate();
infoTemplate.setTitle("Population");
infoTemplate.setContent("Hi<br/>Dude!");
var markerSymbol = new PictureMarkerSymbol();
markerSymbol.setUrl(document.getElementById("picture_url").value);
//markerSymbol.setHeight(64);
//markerSymbol.setWidth(64);
map.enableMapNavigation();
var graphic = new Graphic(point, markerSymbol);
graphic.setInfoTemplate(infoTemplate);
map.graphics.add(graphic);
}
You will notice that we commented out the setHeight and setWidth lines in hopes that it would simply render the actual image in its actual height and width.
We have a Google Maps application we are migrating to ESRI. In our application, we have a zillion little picture files that can be markerSymbol images on the map. The heights and widths of these images are different from one another. When I have ESRI render our images onto the map, it distorts them all into a one size fits all square.
Is there a way to make ESRI simply display an image on the map (whatever the zoom level) without distorting that image or must I manually set the width and height of each image (which is going to be a huge job to figure out the height and width of the zillions of images we have and store them in a database somewhere to have to manually set them in ESRI)?
Solved! Go to Solution.
Brian,
The height and width properties of the PictureMarkerSymbol have default values of 12
You would have to use JS native methods to get the images height and width.
var new_img = new Image();
new_img.onload = function() {
var width = this.width,
heigth = this.height;
}
new_img.src = ""
Brian,
The height and width properties of the PictureMarkerSymbol have default values of 12
You would have to use JS native methods to get the images height and width.
var new_img = new Image();
new_img.onload = function() {
var width = this.width,
heigth = this.height;
}
new_img.src = ""
Hi Robert,
Thanks for posting that work around solution.
It would be great if ESRI added an optional setting to render an image in its original size. For example, maybe markerSymbol.setHeight(-1); and markerSymbol.setWidth(-1)... Or maybe another markerSymbol.setSomething(true).
I just mentioned the above idea with the hopes that the developers of ESRI might read it and consider implementing this idea if it is feasible.
Thanks again for your help!
Brain,
Have you ever used ArcGIS Ideas? This is exactly what it is intended for.
Thanks! Because you showed me that link, I just posted this idea in there.