Hi all,
I found out the problem in the addFilter is the ''eq'' operator.
Using the following code I am able to filter based on a number bigger
(''ge'') or smaller (''le'') then 10:
function showHouses(num, method) {
mapstraction.addFilter(''numhouses'', method, num);
mapstraction.doFilter();
};
onClick="showHouses(10, ''ge'');">More then
10</label></li>
onClick="showHouses(10, ''le'');">Less then
10</label></li>
But using this one is NOT working:
onClick="showHouses(10, ''eq'');">Equal to
10</label></li>
Is the equal operator in mapstraction.addFilter working? Is this a BUG? Has
someone made any experience with ''eq''?
Thank you for your help
Mauro
>
>
> Today''s Topics:
>
> 1. How filter works? (Mauro Vignati)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 9 Jul 2012 21:29:27 +0200
> From: Mauro Vignati <vignus at gmail.com>
> To: mapstraction at lists.mapstraction.com
> Subject: [Mapstraction] How filter works?
> Message-ID:
> <
> CAPixVuiNRCLiurSspa_AS97drNif6XzQyBc_4pwC7RWEcsZJjA at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi all,
>
> One more support question, sorry.
> I''m trying to implement the filter option: I read at least 20
times the
> book of Adam, the online resources and the few links about mapstraction
> filter.
>
> My JSON print is the following:
>
> {"username":"09adam","email":"09adam at
gmail.com
>
","countrycode":"CH","latitude":"46.1956","longitude":"6.1481"},
>
> The basic code for my map is:
>
> var mapstraction;
> var mapstraction = new
mxn.Mapstraction(''map-wrapper'', ''googlev3'');
>
> $(document).ready(function create_map() {
> $.getJSON("allusers.php", function(jobj) {
>
> for (var i=0; i<jobj.length; i++) {
> var place = jobj[i];
> var mk = new mxn.Marker(new mxn.LatLonPoint(place.latitude,
> place.longitude));
> mapstraction.addMarker(mk);
>
>
> This code will place a marker for every line of the JSON print. As far as I
> understand (I am not a programmer) the variable "place" contain
all the
> results coming from allusers.php. Next I add a marker for every
> place.latitude and place.longitude contained in the variable place. Until
> here it''s ok, the map works (I am already happy for that :)
>
> Now I have to filter. I would like to have on the map only the markers
> having "CH" as a country code. I can extract this information
using
> "place.countrycode". I mean, with "place.countrycode" I
have all the
> country code of all the markers. And I should be able to add a marker only
> if place.countrycode is equal to "CH":
>
> mapstraction.addFilter(''place.countrycode'',
''eq'', ''CH'');
> mapstraction.doFilter();
>
> place.countrycode is the value, ''eq'' is the operator
equal, and ''CH'' is the
> value for the comparison. As far I can understand, I do not have to add an
> attribute to the markers because all the markers have already all the
> attributes (allusers.php and the variable "place").
>
> I though I had only to add a simple function like this one:
>
> function showCHMarkers() {
> mapstraction.addFilter(''place.countrycode'',
''eq'', ''CH'');
> mapstraction.doFilter();}
> };
>
>
> And then the html code to fire the function:
>
> <li><label><input type="checkbox"
class="checkbox" id="CH"
> checked="checked" onClick="showCHMarkers();">CH
(Switzerland)</label></li>
>
> When I click on the checkbox, all the markers are placed on the map, not
> only the one having "CH" as a country code.
>
> I think it''s all about my limited brain, I am not able to
understand how
> should work. Can someone please help me?
>
> Many thanks
> Mauro
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
>
http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20120709/c3c322d5/attachment.html
> >
>
> ------------------------------
>
> _______________________________________________
> Mapstraction mailing list
> Mapstraction at lists.mapstraction.com
> http://lists.mapstraction.com/listinfo.cgi/mapstraction-mapstraction.com
>
>
> End of Mapstraction Digest, Vol 56, Issue 2
> *******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20120718/d66f6ad5/attachment.htm>