egeloen / ivory-google-map

Google Map API v3 integration for PHP 5.6+.
MIT License
325 stars 185 forks source link

Autozoom #232

Open jrswgtr opened 7 years ago

jrswgtr commented 7 years ago

I am using the library with Symfony 3.2.7 (through the bundle).

I am loading the map, rendered in a template with an ajax request. The initial loading goes perfect.

When I replace the map-container's content with a different map, with the same function, the correct makers are added. Only the map's auto zoom is not working.

Do you have any idea what could be causing this problem?

// main template

{% block map %}
    <div class="map-container"></div>
{% endblock %}
// returned rendered by ajax response

{{ ivory_google_map(map) }}
{{ ivory_google_api([map]) }}
// javascript

var map_container = $('.map-container');

// AUTO ZOOM WORKS PERFECTLY
$(document).ready(function()
{
    loadMap();
});

// AUTO ZOOM DOES NOT WORK AT ALL
$('.obs-select').change(function()
{
    loadMap();
});

var loadMap = function()
{
    var ctl = getControls();

    var routeName = 'map_filter_' + ctl.filter;

    var url = Routing.generate(routeName);

    $.ajax({
        type: "POST",
        url: url,
        success: function(response){
            if (response.length) {
                map_container.html(response);
            }
        },
        error: function(xhr){
            console.log("Oops something went wrong in the controller with route: " + url + " Returns: " + xhr.status + " " + xhr.statusText);
        }
    });
};
egeloen commented 7 years ago

@jrswgtr Hey! AFAIR, this is not possible to load multiple times the Google Map API. Do you have errors in your browser console?

egeloen commented 7 years ago

ping @jrswgtr