Willie Sims
Posts: 0
Joined: Wed Jul 10, 2013 4:37 pm

Multible Locations from Database with Latitude and Longitude already present

Ok I got myself messed up somehow and cant seem to remember how I did it the last time.
I have My Latitude and Longitude saved into my database this is the Jason Structure
code
"Delivery_Date":"2014-01-20 00:00:00.000",
"Driver":"Willie Sims",
"Home_Terminal":"Houston",
"Lat":"41.2147851",
"Lng":"-79.3853218",
"Status":"Loaded",
"Unit_Number":"13197",
"createdAt":"2014-01-17 18:44:11.467",
"id":"52d979fbe4b0139e7c361ef6",
"_updatedAt":"2014-01-18 21:20:50.424",
"location":"Clarion,PA"
/code
(Request URL: {database_url}/collections/Trucks Test)

Image
What I am trying to do is mark all the locations and use the Unit Numbers for Titles in the map markers and the Driver,Home_Terminal as information in the info window.
I have used examples from four or five different posts and I lost my clips I had on my other computer.
Please I know this is a beat dog but I have been hitting a wall all darn day trying to figure out how to get this data into local storage and map it out to my map

Willie Sims
Posts: 0
Joined: Wed Jul 10, 2013 4:37 pm

Multible Locations from Database with Latitude and Longitude already present

Thanks Alena,
I did so and Added
code
var response = JSON.stringify(data);
localStorage.setItem("json_response", response);
/code
This gives me my local Storage of code [{"Delivery_Date":"2014-01-20 00:00:00.000","Driver":"Willie Sims","Driver_Phone":"93","Home_Terminal":"Houston","Lat":"40.6872885","Lng":"-80.2714505","Status":"In Shop","Unit_Number":"14228","createdAt":"2014-01-17 18:46:00.695","id":"52d97a68e4b0139e7c361ef7","_updatedAt":"2014-01-18 21:13:35.219","location":"Monaca,PA"},{"Delivery_Date":"2014-01-20 00:00:00.000",/code under the key of json_response
I then added this with service success event
code
var list_coordinate = localStorage.getItem('json_response');
var obj = JSON.parse(list_coordinate);
var coordsArray = data.coordinate;
var marker;
(**This is the Error Line**)for (var i = 0, j = coordsArray&#46;length; i < j; i++) {
marker = new google&#46;maps&#46;Marker({
position: new google&#46;maps&#46;LatLng( coordsArray&#46;latitudine, coordsArray&#46;longitudine ),
map: Appery("map")&#46;gmap
});
}
/code
but get an error (Uncaught TypeError: Cannot read property 'length' of undefined )
any advice?

Willie Sims
Posts: 0
Joined: Wed Jul 10, 2013 4:37 pm

Multible Locations from Database with Latitude and Longitude already present

Or should I have concantenate the Lat Lng instead of using json_response after getItem?

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Multible Locations from Database with Latitude and Longitude already present

Hi Willie -

First you'll need to figure out what data is in 'coordsArray'? - you can make output by placing this line after declaring the variable:
preconsole&#46;log(coordsArray);/pre

Willie Sims
Posts: 0
Joined: Wed Jul 10, 2013 4:37 pm

Multible Locations from Database with Latitude and Longitude already present

Nothing is in the coordsArray it is showing undefined
and still shows the error
Image

Willie Sims
Posts: 0
Joined: Wed Jul 10, 2013 4:37 pm

Multible Locations from Database with Latitude and Longitude already present

codevar list_coordinate = localStorage&#46;getItem('list_coordinate');
var obj = JSON&#46;parse(list_coordinate);
console&#46;log(obj);
var coordsArray = obj;
var marker;
for (var i = 0, j = coordsArray&#46;length; i < j; i++) {
marker = new google&#46;maps&#46;Marker({
position: new google&#46;maps&#46;LatLng( coordsArray&#46;latitudine, coordsArray&#46;longitudine ),
map: Appery("map")&#46;gmap
});
} /code
I cannot get this to work, Been at it all night and just cannot figure out what I am doing wrong???
http://appery.io/app/view/a9f0f51b-0c...

Willie Sims
Posts: 0
Joined: Wed Jul 10, 2013 4:37 pm

Multible Locations from Database with Latitude and Longitude already present

I really, do need some help on this

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Multible Locations from Database with Latitude and Longitude already present

Willie, we'll take a look as soon as possible and will update.

Return to “Issues”