Google Maps for Craft outputs data into script tags to add markers to map with Javascript. Everything works great until a user goes to cache the output of an entries loop. It works upon first page load, but all subsequent page loads do not contain any of the JS at the bottom of the page as it should.
Here is a simple example to duplicate this issue. I am not sure what to do about it. In my mind, there should be a way to output JS that can be cached and output to the page without the query running.
{% set options = {
id: 'map',
width: '400px',
height: '300px',
clustering: true
} %}
{{ craft.googleMaps.map(options) }}
{% cache %}
{% for entry in craft.entries.section('news') %}
{{ craft.googleMaps.data('map', entry.map) }}
test<br>
{% endfor %}
{% endcache %}
Within my add-on all the methods that use includeJs behave the same way. But this is just a simple example of what I am doing. I just instantiate an object with some data and include it in the JS.
craft()->templates->includeJs('new GoogleMaps.MapData('.$id.','.$data->toJson().','.$this->jsonEncode($options).');');
For additional information you can see it here in this support thread on the Github repo.
https://github.com/objectivehtml/Google-Maps-for-Craft/issues/12