bjorn2404 / jQuery-Store-Locator-Plugin

A store locator plugin using Google Maps API version 3
MIT License
495 stars 235 forks source link

Stores Count #57

Closed monocraft closed 9 years ago

monocraft commented 9 years ago

Hi Bjorn, Is there a way to get the count of the found location after search? Thank you for sharing this.

bjorn2404 commented 9 years ago

Hello,

Currently there is not but you could modify the callbackSuccess to do it. If you're using XML you can update on 1561:

_this.settings.callbackSuccess.call(this);

to:

_this.settings.callbackSuccess.call(this, $(data).find(_this.settings.xmlElement).length);

With JSON:

_this.settings.callbackSuccess.call(this, data.length);
monocraft commented 9 years ago

Do you have any example with callbackSuccess? I implemented that change but how would I access the data.length from front end?

monocraft commented 9 years ago

I couldn't figure out how you use callback so I just edit the source directly to give me the show store vs the total.

#line 1980
$('#write span').text(storeNumToShow + " Out of "+ data.length);
bjorn2404 commented 9 years ago

You'd do it like this:

$('#map-container').storeLocator({
    'callbackSuccess' : function ( dataLength ) {
         $('#something').text( dataLength );
    }
});
monocraft commented 9 years ago

Thank you Bjorn. Very clean.

monocraft commented 9 years ago

I wanted the current number on the list also so I created another callback.

#line 88
'callbackStoreNum'         : null,
#line 1800
            // Callback callbackStoreNum
            if (_this.settings.callbackStoreNum) {
                _this.settings.callbackStoreNum.call(this, storeNumToShow, data.length);
            }