5

I have a form that allows you to preview coordinates via a google map. The user can dynamically add multiple sets of coordinates to the form. The amount of coordinates are variable.

I loop through the variables with this code which I feel it has to do with loading multiple instances of google maps. The first map loads just fine, but the second map only loads one tile in the far left hand corner. IF I update the coordinates on the form, then all of the maps only show one tile in the far left hand corner.

                while (tempClone != cloneCount) {   
var lat_lng = new google.maps.LatLng(lat, lng);              

                options = {
                    zoom: 14,
                    center: lat_lng,
                    panControl: false,
                    zoomControl: false,
                    mapTypeId: google.maps.MapTypeId.TERRAIN
                };

                map[tempClone] = new google.maps.Map(document.getElementById("map"+tempClone), options);

                var infowindow = new google.maps.InfoWindow({
                    content: inputBL[tempClone][0][1] + 'Entrance'
                }); 

                marker[tempClone] = new google.maps.Marker({
                    position: lat_lng,
                    map: map[tempClone],
                    title: inputBL[tempClone][0][1]
                }); 
}

Thank you for any help! Aaron

Matthias
  • 7,432
  • 6
  • 55
  • 88
Ratty
  • 436
  • 1
  • 7
  • 19
  • 1
    can you post a link to your live code, or put it up on JSFiddle so we can view it in context? It's hard to debug only part of the code. – Mano Marks Apr 23 '12 at 16:56
  • Yeah sure, I will try to get a fiddle up in a bit. Thanks. – Ratty Apr 23 '12 at 19:17
  • Hey Mano, sorry for the long wait. I can only upload the project to an external server. I hope that helps, since I couldn't emulate the issue under jsfiddle. Here is the link: http://s401600969.onlinehome.us/testing/yii-front/index.php/reportForm/create Hopefully, that gives you a better idea as to what is going on. The issues lie with the cave entrances. After you input coordinates(Degrees or Decimal) It shows the image just fine, if you edit the entrance again, it does not show up correctly. Here are some example coordinates: 59.32522, 18.07002 Thanks again for any help! – Ratty Apr 24 '12 at 03:36
  • 1
    To mark a question as solved it is fully sufficient to use the green check mark near the best answer (as you did). You do not need to add "solved" to your questions title. Cheers! – Matthias Apr 25 '12 at 09:47

1 Answers1

4

It almost looks like you're having trouble getting the map to resize. From what I recall this happens if the map container size changes. Can you try triggering a resize after showing the map?

google.maps.event.trigger(map, "resize");
Rick
  • 1,563
  • 9
  • 11
  • I <3 you. I thought it had to do with refresh problems since whenever I moved firebug up and down it corrected the issue, but I didn't know if that was a problem for sure or not. It is now fixed. Thanks for your help! =) – Ratty Apr 25 '12 at 04:29