NigelG
Posts: 0
Joined: Mon Jun 01, 2015 5:43 am

Geopoint on Rest to Map Maker

Hi there,

New appery.io user here.

I am creating a small test app that saves locations to a database via REST, and then I would like to pull this back onto a map when this item is selected from a detail list.

The geolocate and save seems to be working ok, and I can do a list of the items in the collection, but I am really struggling with getting the geopoint column back and into a form that the google maps marker will understand.

Do I need to split it into a lat long from the geopoint data ?

Any help much appreciated. Nigel.

NigelG
Posts: 0
Joined: Mon Jun 01, 2015 5:43 am

Geopoint on Rest to Map Maker

So, have tried to make sure the Geopoint is stored propery. I have, [51.2658, -1.1015] in the database. Which is correct, and have rounded it.

So what I am trying to do is pull that back when I show that record, and display the position on a map. Along with the other fields, which display ok.

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

Geopoint on Rest to Map Maker

Hi Nigel -

Could you please show how you're passing GeoPoint into Google map markers?

This tutorial should be helpful here: https://devcenter.appery.io/tutorials...

NigelG
Posts: 0
Joined: Mon Jun 01, 2015 5:43 am

Geopoint on Rest to Map Maker

Hi Illya,

Thanks, yes I have based my app on that tutorial. I am get the marker to drop on the map as it does on the start page. Then I save that location.

On a details page, I am mapping back the database values into a storage array, then splitting them into two separate storage variables, markerLat and Marker Lng. From the console this does get the right values back.

I then edited the code from the tutorial ....

var mapLatLng = new google.maps.LatLng(localStorage.getItem('markerLat'), localStorage.getItem('markerLng'));

var marker = new google.maps.Marker({
position: mapLatLng,
map: map,
title: "test",
animation: google.maps.Animation.DROP
});

bounds.extend(mapLatLng);
map.fitBounds(bounds);

But nothing happens. No errors.

NigelG
Posts: 0
Joined: Mon Jun 01, 2015 5:43 am

Geopoint on Rest to Map Maker

Although I do have two maps. So maybe I need a separate bit of JS for the 2nd map, and refer to that in the map : xxxxxmap ?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Geopoint on Rest to Map Maker

Hello,

Sure, you should use different map variables for different map components.

NigelG
Posts: 0
Joined: Mon Jun 01, 2015 5:43 am

Geopoint on Rest to Map Maker

Tried that. Duplicated the map js, and rename it detmap, so changed the above to map : detmap

Still not working.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Geopoint on Rest to Map Maker

Please provide us with a public app link: (http://devcenter.appery.io/documentat...) and steps to reproduce.

NigelG
Posts: 0
Joined: Mon Jun 01, 2015 5:43 am

Geopoint on Rest to Map Maker

http://appery.io/app/mobile-frame?src...

Use "Interact" button on nav bar. The select a list item. The map should show the location.

I am using the same code as with the tutorial, and looking at the local variables the marker variable is ok.

Also having issues refreshing the map when you return, using "Collect" nav bar button.

Thanks.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Geopoint on Rest to Map Maker

Please use initialize on "page show" event instead of "load"

Return to “Issues”