Google Maps mashup: I don't understand this

I’m working on a Google Maps mashup with custom icons that appear at various zoom levels. It’s going well, but I need to get the icons more accurately positioned. This requires me to specify the icon anchor wrt the icon origin (top left of the image).

In the Google Maps API documentation I’ve found the following lines:

icon.iconSize = new GSize(size.width, size.height);
icon.iconAnchor = new GPoint(size.width >> 1, size.height >> 1);

I’ve got the icon size OK (out of an array of icon data) but I don’t understand the meaning of ‘>>’ in this context. I hope it might be something to do with an offset from the icon width and height values ?

Any help gratefully received !

I don’t understand WHY, but I have worked out that the effect of the ‘>>’ is to divide the width and height of the icon by two, thereby setting the anchor point in the centre of the image. The Google maps default is to have the anchor point at the bottom centre (i.e. the point of the pin). This is achieved by:

icon.iconAnchor = new GPoint(size.width >> 1, size.height);

I shall now look for a way of defining the anchor point along with the size, so that each image can have an unique anchor point without a long list of conditionals in the JS. I’m sure someone will have done this before ?

PS I’ve posted this here because the Google Maps API is essentially just Javascript.

That’s because the >> operator performs a right-bit shift.

100 decimal = 01100100 binary

01100100 >> 1 =
00110010 binary which equals 50 decimal

In effect, right-shifting performs an integer division by 2.

Essentially?? The whole reason why it’s an API is that it’s a library of code that does so much more.

Should jQuery or Prototype or Yahoo User Interface or OJO or MochKit or any other JavaScript library be questioned here? Possibly, but issues that are library-specific are much more likely to be capable of receiving an appropriate answer, when they are presented to a domain-specific forum.

In other words, people on a forum dedicated to the Google Maps API know so much more about Google Maps issues and solutions.

Thank you, it’s good to learn something every day.

I agree it would have been better to post to a dedicated forum. I did look in the Sitepoint Forums, but the nearest I saw was ‘multi-media’. Maybe I missed something more specific ? If there is a Sitepoint Google Maps API Forum, please let me know, as I need to find out more about ‘anchors’.

The great thing about Sitepoint Forums is that nearly always you get a useful answer within a few hours (even if you post to an inappropriate place).