My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 1523: Feature request: fromContainerPixelToLatLng (and vice versa)
24 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  d.l%[email protected]
Closed:  Jan 2010


Sign in to add a comment
 
Reported by [email protected], Jul 25, 2009
Implementing this on your own is hard. Different places on the world give
different values since its not evenly spreaded.

Making this feature available in v3 will make it possible for MarkerManager
to work, and perhaps there are more applications who really need this. I've
talked to Berry Ratliff and he has had limited succes in implementing his
own version.

The implementation of Berry can been seen here:

http://bjornbrala.com/markermanagerv3/weirdbounds.html
Jul 28, 2009
#1 d.l%[email protected]
(No comment was entered for this change.)
Jul 28, 2009
#2 d.l%[email protected]
Just to make sure I understand the request, you want LatLng coordinates translated to
absolute pixel coordinates?  Is that correct?
Summary: Feature request: fromLatLngToPixel
Status: Started
Jul 28, 2009
#3 d.l%[email protected]
Filing the feature request, but please confirm my question above.
Status: Acknowledged
Labels: Internal-2020458
Jul 28, 2009
#4 [email protected]
Yes, absolute pixel coordinates.
Jul 28, 2009
#5 [email protected]
Sorry, I just woke up, i meant to say. Yes, absolute pixel coordinates. Thanks for
the response :)
Jul 29, 2009
#6 d.l%[email protected]
Got it, thanks!
Nov 2, 2009
#7 d.l%[email protected]
Can you describe one (or a few) practical use cases where you'd need this instead of
using the one provided by the OverlayView class?
Nov 4, 2009
#8 [email protected]
Unfortunately, I can't speak for the "fromLatLngToPixel" crowd, but I can say that
I/we use (and would like in v3) "fromContainerPixelToLatLng". We use it specifically
to get a wider bounds for populating map markers.

In more detail:
When a user views a map, we create a buffer -- let's say 200 extra pixels on all
sides, and use the corresponding lat/lng bounds to get a set of data points within
the map through AJAX. This way when a user moves the map just a little within the 200
pixel buffer we don't have to do another AJAX request. It's essentially just a box
outside of the box. Without "fromContainerPixelToLatLng" we can't get accurate
lat/lng for the buffer box.

Correct me if I'm wrong, but wouldn't creating an Overlay (at least as described in
your examples) just be unnecessary overhead?
Nov 8, 2009
#9 d.l%[email protected]
Tariqseif, you can do this currently by subclassing an OverlayView to display a fixed
viewport over a map.  Granted this isn't the intended use case for an OverlayView (is
more of a custom control), it's certainly doable.

Check out the example I hacked up:
http://savedbythegoog.appspot.com/?id=ag5zYXZlZGJ5dGhlZ29vZ3ISCxIJU2F2ZWRDb2RlGL318AEM
Status: NeedsMoreInfo
Nov 8, 2009
#10 d.l%[email protected]
 Issue 1794  has been merged into this issue.
Nov 8, 2009
#11 d.l%[email protected]
Updated the title to reflect the equivalent v2 method missing from v3 which would
resolve this.
Summary: Feature request: fromContainerPixelToLatLng (and vice versa)
Nov 9, 2009
#12 [email protected]
Cross-posted with 1794: this request (1523) is different from 1794 feature request.
1523 is about converting absolute screen pixel coordinate into LatLng coordinates,
while 1794 is about getting map offset data from API to get absolute pixel
coordinates. While I may want to have LatLng in some cases, in other cases I do not
(for example, if I operate with tiles). Although it's possible to convert LatLng back
to pixels I'd like to avoid this unnecessary step. 
Nov 9, 2009
#13 [email protected]
Also, a suggestion for google folks: when you merge issues I think it makes sense to
combine their ratings (as long as they are from different users).
Nov 9, 2009
#14 d.l%[email protected]
What you're describing are different use cases of the same feature, which is the
ability to convert pixel coordinates relative to the developer provided map canvas
container to lat/lng coordinates on the map and vice versa.  With this capability
added, you can then calculate absolute pixel coordinates, etc.

I understand the request.  However, I'm still not understanding what it is you're
specifically trying to do and why.  For instance, if your intent is to position an
HTML container of some kind relative to the map canvas container you provided, for
what scenario would you ever need to translate these coordinates to lat/lng on the
map?  Are you seeking to place a fixed position HTML container over the map which
doesn't move as the map is dragged?  Even in this case, why do you need to calculate
the lat/lng coordinates underneath it?

It's important to note the v3 API doesn't yet support custom tile overlays nor does
it support custom map controls.  These should not be part of your justification to
add this feature and are instead completely separate feature requests.  In other
words, I'm trying to isolate what it is you really want from the API.  This request
sounds more like a workaround to add a feature not currently supported by the API,
e.g. custom controls/tiles.

Please followup with any comments on this issue.
Nov 10, 2009
#15 [email protected]
d... the "hacked up example" you gave will hopefully help serve my purposes, but I will 
take a look at it today and report back. I can say, however, that my portion of this 
feature request has nothing to do with custom controls/tiler and everything to do with 
marker management. Thanks!
Dec 19, 2009
#16 [email protected]
I have a similar problem:

How can I get bounds coordinates (four LatLng corners) by center's LatLng point,
width and height in pixels and zoom level?

I must calculate them on a server side - no javascript can be used.

"fromContainerPixelToLatLng" math formulas will be the best way.
Jan 19, 2010
#17 [email protected]
Now with custom map types, we've exposed this function as part of MapCanvasProjection:
https://code.google.com/apis/maps/documentation/v3/overlays.html#CustomMapTypes
Status: Fixed
Labels: Fixed-25
Dec 17, 2010
#18 [email protected]
There is now a related request: https://code.google.com/p/gmaps-api-issues/issues/detail?id=2879
You may be interested to vote it...
Sign in to add a comment

Powered by Google Project Hosting