romo
Posts: 0
Joined: Sat May 10, 2014 9:58 am

adding-multiple-location-points-on-google-map-with-appery-io-backend-services

This My DB
Image

my service and mapping:
Image

result:
Image

Uncaught TypeError: Cannot read property 'length' of undefined!.
Stuck!
anybody can help.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

adding-multiple-location-points-on-google-map-with-appery-io-backend-services

Hi Romo.

In code you have an error.

Replace line of code:

pre
code

var coordsArray = obj.coordinate;

/code
/pre

With following line of code:

pre
code

var coordsArray = data;

/code
/pre

See details on screen shot: http://prntscr.com/3iqjn0/direct

Regards.

romo
Posts: 0
Joined: Sat May 10, 2014 9:58 am

adding-multiple-location-points-on-google-map-with-appery-io-backend-services

Dear Yurii.

Many thanx.
Image

Done!

adith visnu
Posts: 0
Joined: Mon Jul 07, 2014 6:32 am

adding-multiple-location-points-on-google-map-with-appery-io-backend-services

hi all,
i just wanna ask for line : var coordsArray = obj.coordinate;
for what that line ? and could you explain that ?
im so sorry, i'm newbie here

LuisMa Suárez Gutiérrez
Posts: 0
Joined: Mon Aug 18, 2014 9:12 pm

adding-multiple-location-points-on-google-map-with-appery-io-backend-services

ok this solved this same issue for me. it works! thanks Katya

only question : whats the difference between using
Appery("map_name").gmap
and this :
var map = Appery("googlemap_1").options.mapElement.gmap('get', 'map');
I used the first option to place markers. the second is Yuri's code i dopnt understand the difference.

s

LuisMa Suárez Gutiérrez
Posts: 0
Joined: Mon Aug 18, 2014 9:12 pm

adding-multiple-location-points-on-google-map-with-appery-io-backend-services

why can't i use this line with a database Geopoint?
'pin_place' contains a Geopoint mapped from a database.

var markerLatLng = new google.maps.LatLng(localStorage.getItem('pin_place'));

i need to use a seperate 'long' and 'lat' values and it works that way, but shouldn't it work with geopoints too?
Image

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

adding-multiple-location-points-on-google-map-with-appery-io-backend-services

Hi LuisMa,

  1. When you store object to LSV you need store there JSON string.

    So click "Add js" and populate JS editor with following code: http://prntscr.com/4l0ji2/direct

    pre

    return = JSON.stringify(value);

    /pre

    2 Then when you need to use this object you can parse this string(stored in LSV) to origin JS object. Here is code:

    pre

    var jsonString = localStorage.getItem('pin_place');

    var originObject = JSON.parse(jsonString);

    //here you can access origin object in accordance to your needs:
    console.log("first item = " + originObject[0]);
    console.log("second item = " + originObject[1]);

    /pre

    Regards.

LuisMa Suárez Gutiérrez
Posts: 0
Joined: Mon Aug 18, 2014 9:12 pm

adding-multiple-location-points-on-google-map-with-appery-io-backend-services

ok thank you, that makes sense.
but tried it , and it seems the Object never gets anything data from the LSV. I've attached an SS with :
-the DB showing the Geopoints,
-the console output
-the expressions watch
-and the code i inserted

also, I added this JS to the 'pin_place' mapping: "return JSON.stringify(value);"

so, supposing this code is correct, I would still need to do this :

codenew google.maps.LatLng(originObject[0],originObject[1]);/code

Instead of just:

codenew google.maps.LatLng( originObject);/code

right?

not much use for a geopoint i seems. do you recomend this approach then ? so far it has worked for me :

codevar markerLatLng=new google.maps.LatLng(

localStorage.getItem('lon') , localStorage.getItem('lat')

); /code

Image

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

adding-multiple-location-points-on-google-map-with-appery-io-backend-services

Hi LuisMa,

Here is code i've gave you:

pre

var jsonString = localStorage.getItem('pin_place');
var originObject = JSON.parse(jsonString);
//here you can access origin object in accordance to your needs:
console.log("first item = " + originObject[0]);
console.log("second item = " + originObject[1]);

/pre

So here is some debug code that's print information into browser console.
Could you be pleased to take a look into this console and find what this code logs?

There should be something like:

"rirst item = 45.2123"
"second item = 12.234"

pre

so, supposing this code is correct, I would still need to do this :

new google.maps.LatLng(originObject[0],originObject[1]);

/pre

Yes - it seem to be correct code. But you need to check whether you have correct values debug code.

Regards.

Return to “Issues”