Geolocation and maps


I was wondering if anybody here has experience with geolocation and Hype? Is it possible to retrieve coordinates and display them on a map (Google maps for instance). I know this is all possible with HTML5, bit how to implement this in Hype? Any examples?
Also being able to use points of interest within a certain distance of the user of the app? Or display information or images/movies when you are on a hotspot?
Any clues would be much appreciated. Thanks!

(Mark Hunte) #2

Have a look at this thread:

Also in it you will see @warrenao was working on this.


Thank you for the link!
I’ll have a look.

(Warren Adams-Ockrassa) #4

Yup, it’s doable. You’ll want to download the JQuery library to fire up the geolocation, then prepare yourself for one hell of a ride as you decode the Google Maps JS API. Their maps are rather powerful, but their documentation is long on description and somewhat short on examples.


The tricky bit is getting your map to appear in Hype; for that you’ll want a widget with its inner HTML set up to load the map.

What I did was take it in slices, beginning with ironcladding the geolocation code, providing for fallback (such as a dummy lat/long) in case location services are refused by the user, or somehow unavailable.

After that I started tinkering with the GMap API. I still am, actually. Their docs are adequate for loading a default view centered on the user’s location, but as soon as you want to customize it or drop markers, it gets hairy, fast. StackExchange is your friend.


Thanks a lot for the insight!
So a little bumpy road ahead. Let’s see how this goes.
Thanks again, and I will probably come back for some feedback.

(kerguelen) #6

Hi Olav,
I’m really interested in being informed about your progress in this topic. Let me know !

(Warren Adams-Ockrassa) #7

Here’s the bare-bones version of a Google Maps wrapper. Turns out I was wrong about needing JQuery, which is a hell of a surprise.

The heavy lifting here is being done in the ‘externals.js’ script. There’s an initial function called from onSceneLoad in Hype; everything else is taking place in the JS file.

First there’s checking for geolocation, then acquisition of the user’s location. There’s fallback checking pretty much all the way along.

The external JS then tells the HTML widget in Hype to render the map.

There are about six trillion different gewgaws you can slap into the API calls for Google’s Maps, but this is a baseline-functional package. (21.0 KB)

(Warren Adams-Ockrassa) #8

Also note that, if you plan to get a lot of loads on the map view, you’ll want to register a developer API key with Google (yes, even with API version 3). The generic script pointer to Google that I have in the HTML head will max out at 2500 hits per day (by some unguessable magic, I suppose). A single-user developer API key raises the maximum by a factor of 10.


Thanks again Warren! Really appreciate your feedback and experiences. Saves me lot of initial troubles.

(Warren Adams-Ockrassa) #10

Quite welcome. Have fun hacking!