0

I want to use map.fitBounds to fit points on a google map. It works good, as soon as I use a taler icon for my point. my icon is 95px tall.

you can see how it looks like if I have 2 points in the map:

http://jsfiddle.net/EwQW5/4/

What I need is to calculate a point that is (95 px translated to decimal coordinates) north from the actual center of the marker markerLatlng, so that the whole icon is visible.

Any ideas on how to do this? Is there a better way?

otmezger
  • 10,410
  • 21
  • 64
  • 90
  • You didn't call `bounds.extend()`. See [updated example](http://jsfiddle.net/EwQW5/5/). What do you want to achieve? To set bounds so complete icon is visible? – Anto Jurković May 20 '14 at 17:38
  • 1
    You can do something similar to [this question: "Include open infowindows within bounds of map, when using fitbounds"](http://stackoverflow.com/questions/21002001/include-open-infowindows-within-bounds-of-map-when-using-fitbounds/21012179#21012179), but use your icon height, rather than that of the infowindow. – geocodezip May 20 '14 at 17:43
  • @AntoJurković I did call `bounds.extend()` after every new marker. (see like 30 and 36 of my example). Yes, the idea is to have the icon visible. – otmezger May 20 '14 at 17:50
  • @geocodezip I will try that out, thanks. I think this goes into the right direction. – otmezger May 20 '14 at 17:51

0 Answers0