This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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: 19724

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: 19724

And welcome to the Ranch!
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63208

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

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Have you checked out Aspose?
subject: Google maps current location
jQuery in Action, 3rd edition