> Which seems simple enough - like I say, the show/hide thing is
> working, and I already have an event listener set up that opens an
> infowindow when a line is clicked.
To get you started : The API needs to know where to place an
infowindow on the map.
In the case of a marker, which is a 'point' object, that's self-
evident. If you trigger a real or simulated click on a marker, the
required location is available from the marker's coordinates.
In the case of a polyline you must tell the API - you might want one
of the ends, or somewhere along its length, it can't guess.
For a real click on a poly, you can extract the mouse coordinates from
the click event and use those.
That is what your code does at the moment :
GEvent.addListener(poly, "click", function(pts) {
map.openInfoWindowHtml(pts,html)
If you simulate a click on the poly, that won't work - the mouse
coordinates are rubbish.
Two challenges then - figure out where you want the infowindow to be
placed. Then use that placement to open an infowindow.
This is probably going to be easier to manage without involving
simulated poly clicks at all i.e. make a new a special function that
handles the sidebar clicks and does these jobs directly.
Figuring out where to put the infowindow along a zigzag polyline is a
challenge in itself. There is no simple method, but code is available
to calculate the length of the poly, then find a point at 'n' distance
along it, so you can find the "middle".
After you've got that working, as a refinement, you might want to
centre and zoom the map on the selected polyline - the infowindow
behaviour is going to look a bit odd in some situations, if your user
is zoomed in close for example.
--
You received this message because you are subscribed to the Google Groups
"Google Maps API V2" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-api?hl=en.