Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Problem with Listener
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
schlumsch  
View profile  
 More options Jul 23 2008, 7:12 am
From: schlumsch <schlum...@gmx.net>
Date: Wed, 23 Jul 2008 04:12:21 -0700 (PDT)
Local: Wed, Jul 23 2008 7:12 am
Subject: Problem with Listener
Hi all,

i`ve got a little Problem adding correct Listeners to my map. My
function gets an array called namensListe with Names for my Markers.
The following code places markers at their correct position, but when
u click on them one and the same Name (the last one in my array) is
displayed.

Example:
Map with 3 Markers
namensListe[0]="bla1", namensListe[0]="bla1", namensListe[0]="bla2"
Opening window when click on Marker 1, 2 or 3 shows "bla2"

I`m sure this can be solved easy, thank u.

lg schlumsch

Function getURLParam is parsing the Querystring and returnes a
value... works correctly...

   function load(namensListe) {
        for ( var i = 0; i <= (namensListe.length-1); i = i+1 ){

                var longitude = "long"+String(i+1);
                var latidude = "lat"+String(i+1);
                var name = "name"+String(i+1);
                map.setCenter(new
GLatLng(getURLParam(longitude),getURLParam(latidude)), 13);
        var point = new
GLatLng(getURLParam(longitude),getURLParam(latidude));
        var marker = new GMarker(point);

var a = namensListe[i];

        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(a);
          });

        map.addOverlay(marker);

}

      }
    }

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
warden [Andrew Leach - Maps API Guru]  
View profile  
 More options Jul 23 2008, 9:05 am
From: "warden [Andrew Leach - Maps API Guru]" <andrew.leac...@googlemail.com>
Date: Wed, 23 Jul 2008 06:05:51 -0700 (PDT)
Local: Wed, Jul 23 2008 9:05 am
Subject: Re: Problem with Listener
On Jul 23, 12:12 pm, schlumsch <schlum...@gmx.net> wrote:

> Hi all,

> i`ve got a little Problem adding correct Listeners to my map. My
> function gets an array called namensListe with Names for my Markers.
> The following code places markers at their correct position, but when
> u click on them one and the same Name (the last one in my array) is
> displayed.

You have fallen into Pitfall Number Three and need a "helper" function
like Mike's createMarker to make this work.

What's happening at the moment is that at within your loop, you add a
listener to each marker. When you click on a marker, the listener is
function is run, and that opens the infoWindow of something called
"marker". What is "marker"? The loop has finished and "marker" is the
last marker you added.

See http://econym.googlepages.com/basic1.htm

Andrew


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
schlumsch  
View profile  
 More options Jul 23 2008, 3:05 pm
From: schlumsch <schlum...@gmx.net>
Date: Wed, 23 Jul 2008 12:05:14 -0700 (PDT)
Local: Wed, Jul 23 2008 3:05 pm
Subject: Re: Problem with Listener
Yeah!!!

Thanx a lot! Works fine. But another Question: I`d like to
print the map and furthermore print some additional text under it.
When i do so using document.writeln(....) only the text is shown, no
map. Cause i`n new using JScript I`m sure this is also easy to solve.

lg schlumsch

On 23 Jul., 15:05, "warden [Andrew Leach - Maps API Guru]"


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
warden [Andrew Leach - Maps API Guru]  
View profile  
 More options Jul 23 2008, 5:55 pm
From: "warden [Andrew Leach - Maps API Guru]" <andrew.leac...@googlemail.com>
Date: Wed, 23 Jul 2008 14:55:16 -0700 (PDT)
Local: Wed, Jul 23 2008 5:55 pm
Subject: Re: Problem with Listener
On Jul 23, 8:05 pm, schlumsch <schlum...@gmx.net> wrote:

> Yeah!!!

> Thanx a lot! Works fine. But another Question: I`d like to
> print the map and furthermore print some additional text under it.
> When i do so using document.writeln(....) only the text is shown, no
> map. Cause i`n new using JScript I`m sure this is also easy to solve.

I've no idea what you have done. Please follow the posting guidelines
and post a link. (Some things are common and a description and the
code snippet allow diagnosis; others really do need a link).

It sounds as though you are injecting stuff into the page when a
"Print" button is clicked. It's far easier to do that sort of thing
with screen and print style sheets, and simply display and print
separate content.

Andrew


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Geary  
View profile  
 More options Jul 23 2008, 8:53 pm
From: "Michael Geary" <m...@mg.to>
Date: Wed, 23 Jul 2008 17:53:05 -0700
Local: Wed, Jul 23 2008 8:53 pm
Subject: RE: Problem with Listener
You can't use document.write after the page is completely loaded. The
document has been closed at that time, and when you call document.write, it
re-opens the document, deletes *everything* in it, and starts writing a new
document. Sound like what you saw? :-)

If you need to change your document after it's loaded, you can use DOM
manipulation. For example, with jQuery (www.jquery.com), if you have an
element whose ID is "foo" and you want to set its content, you would write:

$('#foo').html( '...html code here...' );

But as Andrew said, for printing it may be better to have the extra content
already in the page, but have it hidden in the normal stylesheet and shown
in the print stylesheet.

After all, if you insert extra content in the page for printing, that
content will still be there when you're done printing. Is that what you
want?

-Mike


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »