tags:

views:

122

answers:

1

I have generated a bunch of png files to use as markers on my site.
However when I applied them using GIcon(). I see that they are squeezed such that the height is more than the width.

This even though my png files are exactly 22x22 pixels.

I don't think I have the resources to generate the whole set to fit the odd 20x34 or some such size.

Is there any way this can be fixed ?

I tried specifying a GSize() to unsqueeze them, but that didn't work.

EDIT : Here is how I tried it and it didn't help -

var icon = new GIcon();
icon.iconSize = new GSize(22, 22);
icon.shadow = null;
icon.iconAnchor = new GPoint(11, 11);
icon.infoWindowAnchor = new GPoint(12, 1);
icon.infoShadowAnchor = new GPoint(12, 1);
icon.image = PATH_TO_MARKER + (imgCounter) + ".png";
addIconAttr(icon); // Create new marker with this icon, and various attributes
**var nm = new GMarker(point, {icon:icon, draggable:true, title:'You can drag this point !', bouncy:true, dragCrossMove:true});

+1  A: 

Something like this has worked for me (assuming no shadow):

var myIcon = new GIcon();
myIcon.image = '/images/icons/mymarker.png';
myIcon.iconSize = new GSize(22, 22);
myIcon.shadow = null;
myIcon.iconAnchor = new GPoint(11, 11);
myIcon.infoWindowAnchor = new GPoint(12, 1);
myIcon.infoShadowAnchor = new GPoint(12, 1);

point1 = new GLatLng(42.2659, -83.74861);
var marker1 = new GMarker(point1, {icon:myIcon})
map.addOverlay(marker1);    

If you are doing something similar and it is not working, you should post your code to see if someone sees an issue.

Mark
Thanks Mark, seems that didn't help. But I edited the question to have the code above. Are you sure your marker is an exact square ?
PlanetUnknown
Yep. I changed the code from 24x24 to 22x22 to match your size but otherwise it worked the way I have it. Can you also show your marker creation code where you use the icon? Make sure that you are setting the icon when you create the marker and not changing the icon after it is already created.
Mark
Figured out the issue !!!! There was another piece of my code "addIconAttr(icon);" which had the overriding features ! Thanks for helping me out. That made me review the code :)
PlanetUnknown