kosmaku / gmaps-samples-v3

Automatically exported from code.google.com/p/gmaps-samples-v3
0 stars 0 forks source link

Smart Infowindow appearing in the wrong position #24

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I am trying to implement the smart infowindow onto Google Maps on the site I am 
working on but for some reason the infowindow is getting the wrong position (as 
shown in the attached image). It seems to be the top and left position in the 
CSS being calulated incorrectly.

I create the markers with the following code:
for (var i = 0; i < data.locations.length; i++) {
   var dataPhoto = data.locations[i];
   var latLng = new google.maps.LatLng(dataPhoto.latitude,dataPhoto.longitude);

   latlngbounds.extend( latLng );

   var marker = new google.maps.Marker({
      position: latLng,
      icon: 'http://www.irishcottageholidays.com/images/cottage1.png'
   });  

   listenMarker(map,marker,InfoWindow,dataPhoto.mID)

   markers.push(marker);
}

I then create the smart infowindow:
function listenMarker (map,marker,InfoWindow,mID){
   google.maps.event.addListener(marker, 'click', function() {
      load_content(map,this,InfoWindow,mID);
   });
}

function load_content(map,marker,InfoWindow,mID){
   var $j = jQuery.noConflict();

   $j.ajax({
      type : 'GET',
      url : '/ajax/map_popup.asp',
      data: {
         mID : mID
      },
      success: function(result){
         new SmartInfoWindow({position: marker.getPosition(), map: map, content: result});
      }
   });
}

Thanks in advance for the help.

Original issue reported on code.google.com by stuartpb...@gmail.com on 25 Nov 2013 at 11:39

GoogleCodeExporter commented 8 years ago
I've attached an updated imaging with the marker that the infowindow should be 
linked to.

Also, when I was using the standard infowindow there wasn't an issue, it just 
seems to be now that I've tried adding the smart infowindow.

Original comment by stuartpb...@gmail.com on 25 Nov 2013 at 11:42

GoogleCodeExporter commented 8 years ago

Original comment by stuartpb...@gmail.com on 25 Nov 2013 at 11:44

Attachments:

GoogleCodeExporter commented 8 years ago
I have found that it seems to be an issue with when the map is created it is 
being assigned a relative position. When I untick this option in the Firefox 
Inspector, the map moves to the top left of the page and the smart infowindow 
seems to be correctly positioned. So my question would be: is there an option I 
am missing or something for the infowindow to not move position with the map?

Original comment by stuartpb...@gmail.com on 25 Nov 2013 at 11:58

GoogleCodeExporter commented 8 years ago
This issue is now fixed. The problem was that the popup was being appended to 
the body which assumed the map was in the top left of the window so altering 
the code to append to my map canvas put the popups in the correct position.

Original comment by stuartpb...@gmail.com on 16 Dec 2013 at 3:58