Map dropdown list with json content Map dropdown list with json content json json

Map dropdown list with json content


If I understand the question right, you first need to pick the right data set based on the date property and then you will filter it again based on the place.

You can do this by using the filter method as your data is in an array.

var yourJson = "{}"; // your json variablevar dataForDate = yourJson.data.filter(function( obj ) {  return obj.date == '2018031406'; // your filter criteria});

dataForDate will be another array and if you have only one matching property, you can access it by dataForDate[0]

After this you can implement the same filter function if you want to filter location data based on some property.

If you want to loop through all the ps you can do the following

$.each( dataForDate[0].p, function( index, value ){    // you can access all the properties here    // example    // value.lat});


This is what I ended up using...

//Put the json file to a variablevar location = 'folder/script.json';//make a function called json, using the locaction variablejQuery.getJSON(location, function(json) {        jQuery("select").change(function(){              jQuery(this).find("option:selected").each(function(){                var optionValue = jQuery(this).attr("value");                var i;                for (i = 0; i < JSON.stringify(json.data[index].p.length); ++i) {                  //console.log(i);                  if (i == optionValue) {                    console.log(optionValue);                    var some_temp = JSON.stringify(json.data[index].p[i]["temperature"]);                    var some_temp2 = Math.round(some_temp);                    jQuery(".temp_div").html(some_temp2);                }              }              });            }).change();});