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.htm>