File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Google maps current location Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Google maps current location" Watch "Google maps current location" New topic

Google maps current location

Louise Hill

Joined: Apr 26, 2014
Posts: 1

I'm attempting to develop a basic app on XDK (cross platform) and all I want it to do for now is find the current user's location on the map. I'm using the basis of a map which currently is hard coded to locate to Sydney. I have tried different things such as declaring lat as position.coords.latitude and the same for longitude but any time i place them in instead of hard coding, no map even prints to the screen. Find my code below. Any help would be much appreciated.

Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

From what I can see from the documentation at getCurrentPosition Method, you have to pass a function which accepts a parameter to the method. The parameter, naturally enough, represents the current location. Your "initialize" method doesn't do that, and therefore you can't write code which uses that location parameter.

Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

And welcome to the Ranch!
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

To find the user's current location, you'll need to use the geolocation API.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Google maps current location
It's not a secret anymore!