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);
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.
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]"
> > 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.
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.
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?
> 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.