sg

Perşembe, Aralık 01, 2005

Re: Quick - confirm marker property tree please


Wasn't it Will who wrote:
>
>mmm....(nods)...thats what I was concerned about.
>So, I've now switched to this:
>
>function createMarker(mypoint, mytext) {
> // Create marker at location using specified icon
> var marker = new GMarker(mypoint);
> // Add the click function
> GEvent.addListener(marker, "click", function(){
> marker.openInfoWindowHtml(mytext);
> });
> return marker;
>};
>
>
>
>its used with this:
>var newmarker = createMarker(point,
>SomeGlobalArrayofMarkers[n].window_data);
>
>
>then I just update like so:
>SomeGlobalArrayofMarkers[n].window_data = "new html";
>
>That should work right?

No. You're getting function closure on the "mytext" variable at the time
createMarker() closes, so you'll always get that version in the info
window.

In this case you DON'T want to get function closure on the info window
contents variable. (It is possible in standards compliant browsers to
modify variables that have function closure, but IE drops them on the
floor when you try it.)

This would work if you don't want to go with the marker.html strategy:

function createMarker(mypoint, n) {
var marker = new GMarker(mypoint);
GEvent.addListener(marker, "click", function(){
marker.openInfoWindowHtml(SomeGlobalArrayofMarkers[n].window_data);
});
return marker;
};

var newmarker = createMarker(point, n);

This strategy gives you function closure on the "n" variable, but leaves
you free to modify SomeGlobalArrayofMarkers[n].window_data.

--
The Blackpool Community Church Javascript Team
http://www.econym.demon.co.uk/googlemaps/

0 Comments:

Yorum Gönder

<< Home


Komik Videolar   islam  şarkı sözleri  yemek tarifleri  gelibolu  huzur   sağlık