Search code examples
jquerygoogle-maps-api-3jquery-ui-map

jquery-ui-map: Search does not work (Google Maps API)


Trying to perform a search by address using jquery-ui-map plug-in.

Firefox reports: TypeError: h[b] is undefined /js/ui-map/jquery.ui.map.full.min.js Line: 2

$(document).ready(function() {
        $('#map_canvas').gmap('search', { 'address': 'Stockholm' }, function(isFound,results) {
            if (isFound) {
                $('#map_canvas').gmap('getMap').panTo(results[0].geometry.location);
            }
        });
});

Please help.

EDIT: Reported to developer at http://code.google.com/p/jquery-ui-map/issues/detail?id=64


Solution

  • instead of gmap('getMap') one should use gmap('get','map'). Besides you swapped isFound and results The correct sample is:

    $(document).ready(function() {
            $('#map_canvas').gmap('search', { 'address': 'Stockholm' }, function(results,isFound) {
                if (isFound) {
                    $('#map_canvas').gmap('get','map').panTo(results[0].geometry.location);
                }
            });
    });