Continuing Location discovery

25 views
Skip to first unread message

kevin....@gmail.com

unread,
Mar 17, 2014, 10:02:59 AM3/17/14
to codenameone...@googlegroups.com
Hi everyone,

I am developing an application which makes use of the location abilities of the mobile platform in conjunction with Google's places directory.  When I query the places API for local places, I get a response which includes everything I'm interested in, including the location (geometric) information.  I then create a PointLayer and insert Points for each of the items in the response.  I then add the points layer to the map that is being displayed, which map icons for each location.  A typical addition might be for something like this:

[Network Thread] 0:0:4,248 - Adding new point-of-interest: 40.719819 -74.008383 Bubby's

However, when I then click on an icon in the map for this location, the location data is not correct: 

[EDT] 0:0:9,964 - pressed {'longitude':-8238575.508846745, 'latitude':4971102.4549792465} Bubby's

As you can see, the latitude and longitude for this location have changed.  I have debugged this to the point of seeing that the points I add have the correct location data, but in inspecting the PointsLayer, all of the values are incorrect.

Anyone else seeing this type of behavior?

Thanks.

Chen Fishbein

unread,
Mar 17, 2014, 10:42:32 AM3/17/14
to codenameone...@googlegroups.com, kevin....@gmail.com
The coordinates are being project to be be able to show on the map.

If you want the original coordinates you will need to transform it back.
PointsLayer pl;
point = pl.getProjection().toWGS84(point);
                            

kevin....@gmail.com

unread,
Mar 17, 2014, 11:00:26 AM3/17/14
to codenameone...@googlegroups.com, kevin....@gmail.com
Thanks Chen, I will check it out.  So now my follow-up question:  Can I call a navigation app from this data?  And if so, how does one do that, say for instance if I wanted to bring up the Google Maps navigation app?

Thanks for the speedy reply.

Kevin Penrose

unread,
Mar 17, 2014, 11:58:22 AM3/17/14
to codenameone...@googlegroups.com
Okay - I must be missing something - when I click on the map point, I get a callback to my ActionListener, and I get the PointLayer from the event:

                pl.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        PointLayer pl = (PointLayer) evt.getSource();
                        Log.p("pressed " + pl);
//                        System.out.println("pressed " + pl.getLatitude() + " " + pl.getLongitude() + " " + pl.getName());
                        Dialog.show("Details", "" + pl.getName(), "Ok", null);
                    }
                });

I'm not sure where in that code I should be doing the un-projection to which you refer.  I don't know if I have a reference to the PointsLayer that I need to get the projection, and how I get the point you refer to (which I guess would be a Coord or PointLayer?).  

Thanks again.


kevin....@gmail.com

unread,
Mar 17, 2014, 12:05:05 PM3/17/14
to codenameone...@googlegroups.com, kevin....@gmail.com
Nevermind - I figured it out - You get a Coord back from the translation, I was looking for a PointLayer.
Reply all
Reply to author
Forward
0 new messages