Page 1 of 2

Multible Locations from Database with Latitude and Longitude already present

Posted: Sun Jan 19, 2014 3:23 am
by Willie Sims

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


Multible Locations from Database with Latitude and Longitude already present

Posted: Sun Jan 19, 2014 3:33 am
by Alena Prykhodko

Please take a look at a similar question https://getsatisfaction.com/apperyio/...


Multible Locations from Database with Latitude and Longitude already present

Posted: Sun Jan 19, 2014 4:26 am
by Willie Sims

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?


Multible Locations from Database with Latitude and Longitude already present

Posted: Sun Jan 19, 2014 4:35 am
by Willie Sims

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


Multible Locations from Database with Latitude and Longitude already present

Posted: Sun Jan 19, 2014 6:18 am
by Willie Sims

?


Multible Locations from Database with Latitude and Longitude already present

Posted: Sun Jan 19, 2014 6:43 am
by Illya Stepanov

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


Multible Locations from Database with Latitude and Longitude already present

Posted: Sun Jan 19, 2014 11:26 am
by Willie Sims

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


Multible Locations from Database with Latitude and Longitude already present

Posted: Sun Jan 19, 2014 3:07 pm
by Willie Sims

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


Multible Locations from Database with Latitude and Longitude already present

Posted: Sun Jan 19, 2014 7:23 pm
by Willie Sims

I really, do need some help on this


Multible Locations from Database with Latitude and Longitude already present

Posted: Sun Jan 19, 2014 8:06 pm
by Alena Prykhodko

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