This is the P2PU Archive. If you want the current site, go to www.p2pu.org!

Online Maps with OpenLayers

Just in time: OpenLayers Mobile Phone Features

Nick Doiron's picture
Fri, 2011-03-04 03:48

Last week, OpenLayers completed a Mobile Sprint to add new mobile-friendly features.

If you're interested in that for your interest project, this is the post to read:  http://openlayers.org/blog/category/sprint/
There are also several new examples to get you started: http://openlayers.org/dev/examples/?q=mobile

Geolocation Example in jsFiddle

I wanted to test whether these examples would work for us on jsFiddle.  I was particularly impressed with their geolocation example.  This uses a GPS chip, phone signal, or WiFi access to estimate where you are.  It works with laptops, too, using the WiFi mac address to estimate where you're connected.

The circle is the accuracy of the location estimate, and the variable e.point becomes a useful variable for your application.

Here it is, simplified down to the basics: http://jsfiddle.net/UAxun/97/

Comments

? All I get at that fiddle is

intro vert's picture
intro vert
Sun, 2011-03-06 05:23

? All I get at that fiddle is a blue screen. What do I need to do to see the map?

This uses a new web browser

Nick Doiron's picture
Nick Doiron
Sun, 2011-03-06 06:28

This uses a new web browser feature called HTML5 Geolocation. It's built into most mobile phones and tablets. The first time you use it, it'll ask if you want to share your location with the webpage. If all goes well, there'll be a circle and a red + near your location on OpenStreetMap.

Here is a really good (and constantly updated) guide of what it's for and what web browsers work: http://diveintohtml5.org/geolocation.html

If that doesn't work, you can still use other features such as Kinetic Movement (map keeps moving after you release the mouse) http://openlayers.org/dev/examples/kinetic.html

thx and still confused. I

intro vert's picture
intro vert
Sun, 2011-03-06 06:59

thx and still confused. I skimmed diveintohtml5 and it seems firefox should work. So, I ran your file from my machine and get "OpenLayers.Control.Geolocate is not a constructor".

What's the point of the kinetic movement? The map does not keep moving when I release the mouse. And the intersecting lines seem to appear at random places.

I can confirm that it works

Sean Horgan's picture
Sean Horgan
Sun, 2011-03-06 23:59

I can confirm that it works in chromium.