I don't usually work with info windows, but if I recall the version 3 of
the API only has 1 info window for the entire map.  So what I believe was
probably happening was that you were showing the info window before the new
data that was going to be shown in the info window was assigned to the info
window so it had the old data from when it was previously shown.  What I
would do to check if this is the case is either clear the information in the
info window before showing it, or set the new data to the info window before
showing it.  The 2nd option would probably be best.

On Thu, Jun 24, 2010 at 5:12 PM, 3D-kreativ <[email protected]> wrote:

> This is the code I used from the beginning, but I hade problem with
> the content in the infoWindow showing the content from an old
> infoWindow.
>
>
> <script type='text/javascript'>
> // GoogleMapScript
>
> function initialize() {
> var latlng = new google.maps.LatLng(55.6762944,12.5681157);
> var settings = {
> zoom: 11,
> center: latlng,
> mapTypeControl: true,
> scaleControl: true,
> mapTypeControlOptions: {style:
> google.maps.MapTypeControlStyle.DROPDOWN_MENU},
> navigationControl: true,
> navigationControlOptions: {style:
> google.maps.NavigationControlStyle.DEFAULT},
> mapTypeId: google.maps.MapTypeId.ROADMAP
> };
>
> var map = new google.maps.Map(document.getElementById('map_canvas'),
> settings);
>
> // Declare infowindow as a global variable
> var infowindow;
>
> // Creating an array wich will contain the tooltip for markers
> var tooltip_names=[];
> // Adding information
> tooltip_names.push('Kommandantens Gaard');
> tooltip_names.push('Bikuben Kollegiet');
> tooltip_names.push('Tietgenkollegiet');
>
> // Creating an array which will contain the coordinates for the cities
> var places=[];
> // Adding a LatLng object for each city
> places.push(new google.maps.LatLng(55.667093,12.581255));
> places.push(new google.maps.LatLng(55.662767,12.593293));
> places.push(new google.maps.LatLng(55.660794,12.58972));
>
> // Creating an array wich will contain info in Info Windows
> var infow = [];
> // Adding info to Info Windows
> infow.push("<div><a href='?p=visa&id=0001'><img src='../bilder/
> bilder_medium/0001_2m.jpg' width='150' height='113' border='0' /></
> a><br /><a href='?p=visa&id=0001'>Kommandantens Gaard</a></div>");
> infow.push("<div><a href='?p=visa&id=0002'><img src='../bilder/
> bilder_medium/0002_1m.jpg' width='150' height='113' border='0' /></
> a><br /><a href='?p=visa&id=0002'>Bikuben Kollegiet</a></div>");
> infow.push("<div><a href='?p=visa&id=0003'><img src='../bilder/
> bilder_medium/0003_1m.jpg' width='150' height='113' border='0' /></
> a><br /><a href='?p=visa&id=0003'>Tietgenkollegiet</a></div>");
>
> // Loop to create Markers and Info Windows
> for (var i = 0; i < places.length; i += 1) {
> // Call function
> addMarker(places[i], i);
> }
>
> // Creating Markers and Info Windows
> function addMarker(latlng,no) {
> var marker = new google.maps.Marker({
> position: latlng,
> map: map,
> icon: 'http://google-maps-icons.googlecode.com/files/factory.png',
> title: tooltip_names[no]
> });
>
> // Add click event to the marker
> google.maps.event.addListener(marker, 'click', function() {
> // Check to see if the infowindow already exists and is not null
> if (!infowindow) {
> // if the infowindow doesn't exist,create an
> // empty InfoWindow object
> infowindow = new google.maps.InfoWindow();
> }
> // Set the content of the InfoWindow
> infowindow.setContent(infow[no]);
> // Tie the InfoWindow to the marker
> infowindow.open(map,marker);
> });
> }
>
> }
>
> </script>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-maps-js-api-v3%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" 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-js-api-v3?hl=en.

Reply via email to