0

I have a custom Google Map containing many markers, each of which contains an image in its infowindow. When I embed the map on a site, the page seems to be downloading every single one of these images when the map is viewed, which results in an unnecessarily enormous page size (around 50MB on every view of the page). Since these images are loaded from our own server, that potentially represents a massive and unnecessary amount of strain on the server / use of bandwidth.

Is there any way of telling Google Maps not to pre-download these images, but instead to AJAX load a marker's content only when that particular marker is clicked on? Since this is the default behaviour on non-custom Maps, it feels like there must be a simple way of doing this.

Nick F
  • 9,781
  • 7
  • 75
  • 90

1 Answers1

0

I assume you mean the infowindows contain the image? You could use the InfoWindow.setContent() function to dynamically add content to an infowindow. Do this in conjunction with the event listener you already have in place that opens the infowindow, to do the ajax request to get that content.

duncan
  • 31,401
  • 13
  • 78
  • 99
  • Yes, sorry, the infowindow (the speech-balloon type pop-up when you click on the marker). I'm not currently using any custom javascript, though: I'm simply embedding a map which someone else has created (presumably via Google Maps' own "Custom map" creation interface), using Google Maps' own iframe HTML. I'm looking for the simplest possible way of preventing image-loading on a vanilla custom map - ideally one that doesn't involve writing custom javascript code (eg. a parameter in the iframe URL). – Nick F Sep 21 '12 at 13:24
  • ah ok... not sure this would be possible without using the Maps API. Can you post your code so I can see how you specify the content of the infowindows. – duncan Sep 21 '12 at 13:32
  • Ok. Here's [the map](http://goo.gl/maps/H8ACX). I'm just embedding it in an iframe, in basically the format Google Maps supplies if you press the "Link" button. – Nick F Sep 21 '12 at 15:33
  • Sorry no idea. I doubt you can insert javascript into the KML descriptions that Google will execute, so you'd have to do it with the API – duncan Sep 21 '12 at 16:44