Hi everyone
I've got a problem with a custom marker icon anchor in V3. In my site I have to draw some custom markers and depending on some parameters move a bit (some pixels) the icon image from its real coordinate. I do this using the anchor property of the icon. (For those of you who are curious, I have to move a bit the image because we don't want to draw it over the exact position as there may be some info there which the user may need).
Then, on clicking over the marker, I open an Infowindow and to better indicate the actual position of the marker, I draw a line from the icon anchor position to the real coordinate.
My problem is while trying to calculate the coordinate for the anchor. In API v2 I used map.fromLatLngToDivPixel, but in API 3 I hadn't been able to make it work (I'm using projection, see the code I use on the link I provide).
Has any one had to do something similar? Or can anyone give me a clue as to how to get the coordinate for the anchor or any other way to move a bit the icon from its coordinate and then draw a line from the icon to the coordinate???
I've built a sample of my app that can be found here:
http://www.lariereta.com/testCustomMarker/testCustomMarker.htmlSome info on the code and site:
- The problem with the coordinate of the anchor position is on the function "getIconLine".
- The possible movements are hardcoded (in pixels) at the beginning of the code (under 'Possible icon movements').
- I've commented the code and tried to make it easy, as I perfectly understand that solving this kind of problems from someone else maps isn't easy at all.
- The link site is not the real one (this domain is from a friend of mine) and the link is not for the real site either (the code is quite big and has lots of things which aren't related with this problem). I've just done this sample so that I could provide a link to the map and to make it easier for anyone to try to give me a hint on how to solve the problem. But in this sample I do exactly the same thing that in the site I'm developing and I have exactly the same problem with the line coordinates. I'm sure if I can sort out this problem in this sample code, I will fix it on the site I'm developing.
Any hint will be gratefully accepted.
Thanks in advance.
D.