Re: Floating Map Windows
Michael ,
I can see a lot of problems putting the map in a floating div. The API
has to be able to translate between page coordinates and map
coordinates. I believe the way it is implemented, it assumes that the
map never changes its position on the page, so the code caches (or
precalculates) a number of conversion factors. You might have to send
the GMap object resize events (by calling it's resize handler) every
time the map div changes position relative to the page. Will the
browser send events whenever a floating div moves?
I think you should be able to isolate the map though, by putting it
into an iframe which is inside your floating div. As far as the map is
concerned, it never moves relative to its page inside the iframe.
Passing information back and forth between the main frame and the
iframe is a bit more complicated than the simple case where the map is
in the main frame.
The map API code should be included in the iframe only. When you
include the API script, it creates objects in the document scope. In
the main frame, you need to look for the GPoint object in the iframe's
document scope, rather than the main frame's document scope. Perhaps do
something like "new <iframe>.document.GPoint(...);" instead of "new
GPoint(...);". Or perhaps "GPoint = <iframe>.document.GPoint;" would
work. (See my example for one way to locate the iframe.)
Here is a link to my very simple example page:
http://www3.telus.net/DougHenderson/Map_in_iframe.html
I have a button on the main page which performs a
recenterOrPanToLatLng() on the map in the iframe. As I said, it's a
very simple example. I'm not sure that the way I dealt with the GPoint
scope issue is valid. It works for this example, but I'd try something
like I mention above, if I was doing it again.
Doug
0 Comments:
Yorum Gönder
<< Home