Page 1 of 4

Cascading dropdowns and Google maps

Posted: Wed Feb 19, 2014 8:34 am
by Eddie Willcox

Hi,

In my app I have a page with 2 dropdowns (the second one gets populated based on the selection in the first one) and a button. The button sets 2 local storage variables and then navigates to the page where the map is located. On page load on the map page, I set the property of 2 hidden labels on the page that reads from the local storage variables and then it fires a query service to collect data from the database. The query must fetch data based on the variables and it must match a column called province (no problems there) and a column called city. This is where the problem comes in. The value for city keeps giving me a "Bad Request" error.

Looking at the request this is what it sends through: where:{"Province": "Gauteng", "City": "​"Pretoria0""}

This is the code for the query: return '{"Province": "' + localStorage.getItem("province") + '", "City": "' + localStorage.getItem("city") + '"}';

Please tell me where I'm going wrong here.

Oh, here is the code I use on the dropdowns:

var selectedValue = this.value;
var data = { 'Gauteng': ['Pretoria', 'Johannesburg'],
'Western Cape': ['Cape Town', 'George', 'Worcester'],
'Free State': ['Bloemfontein'],
'Limpopo': ['Polokwane'],
'Mpumalanga': ['Witbank'],
'Kwazulu-Natal': ['Durban'],
'North West': ['Rustenburg']
};

var dropDown = $('[name=citySelector]');
dropDown.html('');
var newData = data[selectedValue];
for(i = 0; i < newData.length; i++) {
dropDown.append('​' + newData + '');
}
dropDown.selectmenu('refresh');


Cascading dropdowns and Google maps

Posted: Wed Feb 19, 2014 9:12 am
by Kateryna Grynko

HI Eddie,

You should use query parameter $and: http://docs.mongodb.org/manual/refere...


Cascading dropdowns and Google maps

Posted: Wed Feb 19, 2014 9:36 am
by Eddie Willcox

Thanks Katya.

I must still be doing something wrong because the map is not showing what I expect it to show and I get this message in my google chrome developer tools when the map page loads:

ReferenceError $and is not defined


Cascading dropdowns and Google maps

Posted: Wed Feb 19, 2014 3:42 pm
by Kateryna Grynko

Eddie,

Use the following code for a parameter 'where':prereturn '{"$and": [{"Province": "' + localStorage&#46;getItem("province") + '"},{ "City": "' + localStorage&#46;getItem("city") + '"}]}';/pre


Cascading dropdowns and Google maps

Posted: Thu Feb 20, 2014 11:37 am
by Eddie Willcox

Thanks Katya. The errors are gone now


Cascading dropdowns and Google maps

Posted: Mon Feb 24, 2014 6:54 am
by Eddie Willcox

I need some more help on this. The errors are gone now, but the map is not displaying what I expect it to display. Obviously I am doing something wrong. I have followed the tutorial on adding multiple location maps using Appery.io backend services and tried to change it to use a query service instead of list service, but this will not show my locations on the map.


Cascading dropdowns and Google maps

Posted: Mon Feb 24, 2014 3:25 pm
by Kateryna Grynko

Hi Eddie,

What is displayed? Do you see in service Test what you need?


Cascading dropdowns and Google maps

Posted: Mon Feb 24, 2014 4:01 pm
by Eddie Willcox

In the service test I do see what I'm looking for. In the app, I see ocean. It does not show my markers on the map.


Cascading dropdowns and Google maps

Posted: Mon Feb 24, 2014 4:36 pm
by Kateryna Grynko

Eddie,

Please share your application with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a and tell us where to find the issue in your application.


Cascading dropdowns and Google maps

Posted: Mon Feb 24, 2014 5:00 pm
by Eddie Willcox

The problem is on the stores page.