Closed GoogleCodeExporter closed 9 years ago
Yes, posting code would help (you could attach your modified entry point and
other
necessary files to this issue if you like). We will need to re-write it in JS
to
reproduce it for the Maps API team.
Original comment by galgwt.reviews@gmail.com
on 28 Jan 2009 at 8:40
Here's the code; the related .gwt.xml is trivial. No css or anything. Let me
know
if I left something out, or if I can say or do more. Thanks!
Original comment by lucy.had...@gmail.com
on 28 Jan 2009 at 9:09
Attachments:
Two things:
1) If it's not obvious, the marker near Lawrence, MA (018) is the best one for
getting this behavior.
2) Do *you* have any suggestions for a workaround? I'm not seeing an obvious
way to
figure out how much more to pan the map and then do so.
I really appreciate the prompt response you've given this issue; thanks.
Original comment by lucy.had...@gmail.com
on 29 Jan 2009 at 2:03
I am sorry, I don't have any great ideas for workarounds. The only thing I can
think
of is that there is a MapWidget.convertLatLngToContainerPixel() and
MapWidget.convertLatLngToDivPixel() that might tell you if the position of the
info
window is close to the right edge, then you could manually reset the center.
You
might need to do this inside an InfoWindowOpenHandler callback.
Original comment by ericzun...@gmail.com
on 29 Jan 2009 at 2:29
I still see this behavior in version 1.1, using GWT 2.0.3.
Original comment by moor...@gmail.com
on 25 Jun 2010 at 7:02
In fact, for me, the infowindow opening behaves really bizarrely:
I am adding a MarkerClickHandler like so
public void onClick(MarkerClickEvent event) {
Marker marker = (MyMarker)event.getSender();
mapWidget.getInfoWindow().open(marker,infoWindowContent();
}
It opens the infowindow every time, but pans the map in seemingly random
directions.
Original comment by moor...@gmail.com
on 25 Jun 2010 at 7:19
For anyone else, here was my workaround.
I added this code to a MarkerClickHandler that opens the infowindow (where
getMap() returns the mapWidget). I have tested this in FF3.6 so far. This
also only works for North America, because of assumptions about the sign of
latitude and longitude, but should be extendable to different hemispheres.
-------------
LatLng markerLatLng = marker.getLatLng();
LatLng center = getMap().getCenter();
LatLng nePt = getMap().getBounds().getNorthEast();
LatLng swPt = getMap().getBounds().getSouthWest();
double latInView = Math.abs(nePt.getLatitude() - swPt.getLatitude());
double lngInView = Math.abs(nePt.getLongitude() - swPt.getLongitude());
double newLat = center.getLatitude(),newLng = center.getLongitude();
boolean panning = false;
if (markerLatLng.getLatitude() > center.getLatitude() + latInView/6d) {
newLat = center.getLatitude() + latInView/6;
panning = true;
}
// weird because of - longitudes
double boundEast = center.getLongitude() + lngInView*(3d/10);
double boundWest = center.getLongitude() - lngInView*(3d/10);
if (markerLatLng.getLongitude() > boundEast) {
newLng = boundEast;
panning = true;
} else if (markerLatLng.getLongitude() < boundWest) {
newLng = boundWest;
panning = true;
}
if (panning) {
LatLng newCenter = LatLng.newInstance(newLat, newLng);
getMap().panTo(newCenter);
}
-------------
The 1/6 (for latitude) and 3/10 (for longitude) ratios will differ based on the
size of your infowindow.
Hope this helps.
Original comment by moor...@gmail.com
on 25 Jun 2010 at 8:52
Err, actually, I found after a bit more time that this line in the
MarkerClickHandler works well:
----------
getMap().panTo(marker.getLatLng());
----------
That is, just pan to where the marker is.
Original comment by moor...@gmail.com
on 25 Jun 2010 at 9:22
Actually, neither solution I outlined above works 100% of the time. I ended up
just not using the info window and finding another way to display the data.
Original comment by moor...@gmail.com
on 29 Jun 2010 at 12:23
The Maps v2 API is now deprecated
Original comment by zundel@google.com
on 28 Oct 2011 at 3:44
Original issue reported on code.google.com by
lucy.had...@gmail.com
on 28 Jan 2009 at 8:36