[Google Maps API v3] LatLng at pixel location?

2011-10-28 Thread pinksy
Hi I'm really sorry if this has been answered - I can't find a clear answer, and am struggling to figure it out from the documentation... I have a map with known dimensions, and one side of the map will be obscured by a DIV which will have a variable width, leaving a visible portion of the

Re: [Google Maps API v3] LatLng at pixel location?

2011-10-28 Thread Barry Hunter
Just use the fromDivPixelToLatLng() function :) (passing in the pixel coordinates you have calculated as per the image) I know I strugged, to find a good example, of its use, from one of my sites... var overlay = null; function update_map() { if (overlay == null) {

Re: [Google Maps API v3] LatLng at pixel location?

2011-10-28 Thread Jeremy Geerdes
If the variable-width div is always going to be visible, why not adjust the width of your map to be the 200px - Zpx? Jeremy R. Geerdes Generally Cool Guy Des Moines, IA For more information or a project quote: jrgeer...@gmail.com If you're in the Des Moines, IA, area, check out Debra Heights

Re: [Google Maps API v3] LatLng at pixel location?

2011-10-28 Thread pinksy
Thanks for the reply Jeremy. I don't want to resize the map when the variable-width DIV is resized, because (as far as I know) to resize a map's canvas means completely reloading it (i.e., instantiating a new google.maps.Map object, passing in the resized DIV). For my purposes, the dimensions

Re: [Google Maps API v3] LatLng at pixel location?

2011-10-28 Thread pinksy
Thanks for the reply Barry. I'm not quite sure I completely understand - do you mean something like this (which doesn't appear to work)?: overlay = new google.maps.OverlayView(); overlay.draw = function() {}; overlay.setMap(map); var x = (200 - divwidth) / 2; var y = 50; var latLng =

Re: [Google Maps API v3] LatLng at pixel location?

2011-10-28 Thread Barry Hunter
I think its time for a link. We dont know what context you are calling that. Is the Map definitly existing when that code is called? All be weary of calling that many times in a row. If you create the overlay each time, you going to end up with lots of invisible overlays added to the map -

Re: [Google Maps API v3] LatLng at pixel location?

2011-10-28 Thread pinksy
This is work-in-progress, but... http://www.pinksy.co.uk/newsquare/index.php/tidysquare The DIV on the right is resizeable, exposing more or less of the map underneath as you resize it. As you resize it, the map is panned left or right by the same amount, so that the center of the visible area

Re: [Google Maps API v3] LatLng at pixel location?

2011-10-28 Thread pinksy
Here is a simplified example of the question: http://www.pinksy.co.uk/newsquare/overlaytest.html The map is 600px wide, 300px high. An overlay is created as suggested above. A click event is added. On click, it adds a marker at the LatLng at 300px,150px (i.e., what I expect to be the center of