[OpenLayers-Users] Defining icon sizes in OL

Phantasma jerko.klarica at gmail.com
Sun Oct 20 03:45:00 PDT 2013


Hi everyone!

I have a question about defining icon sizes in OpenLayers. Basically, I'm
loading icons (images), and creating Icon object for each image loaded.
These images vary in sizes, so one is i.e. 38x38 px and the other 38x40px.
This is the part where icons for each image are instantiated:

function loadIcon(style, url, hotSpot) {
	if (!icons[url]) {
            //var size = new OpenLayers.Size();
           //var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
            var image = "https://" + window.location.hostname + "/" +url;
            var icon = new OpenLayers.Icon(image, null, null);
            icons[style] = icon;
	  }
} 

I would like to get the real image size on my map (i.e. 38x38px). However,
I'm forced to use the Size object and to define the Icon size. If I try to
omit the Size object in the constructor, then I get a very small Icon in the
map (20 x 20 px) which size is defined somewhere in OL CSS.  

Is it possible to draw the Icon on the map using real size of the image? I
also tried using vectors, but it also doesn't work if external image sizes
are not defined. 

I'm currently overriding OL's CSS in order to get the real icon sizes on the
map:

img.olAlphaImg {
  width: auto !important; 
  height: auto !important;
}


Thank you in advance!





--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Defining-icon-sizes-in-OL-tp5084680.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list