Eddie Willcox
Posts: 0
Joined: Thu Nov 14, 2013 6:55 am

Cascading dropdowns and Google maps

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');

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Cascading dropdowns and Google maps

HI Eddie,

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

Eddie Willcox
Posts: 0
Joined: Thu Nov 14, 2013 6:55 am

Cascading dropdowns and Google maps

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

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Cascading dropdowns and Google maps

Eddie,

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

Eddie Willcox
Posts: 0
Joined: Thu Nov 14, 2013 6:55 am

Cascading dropdowns and Google maps

Thanks Katya. The errors are gone now

Eddie Willcox
Posts: 0
Joined: Thu Nov 14, 2013 6:55 am

Cascading dropdowns and Google maps

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.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Cascading dropdowns and Google maps

Hi Eddie,

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

Eddie Willcox
Posts: 0
Joined: Thu Nov 14, 2013 6:55 am

Cascading dropdowns and Google maps

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.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Cascading dropdowns and Google maps

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.

Eddie Willcox
Posts: 0
Joined: Thu Nov 14, 2013 6:55 am

Cascading dropdowns and Google maps

The problem is on the stores page.

Return to “Issues”