GeoLocation component

Hi,

I created a simple wrapper for the
GeoLocation API
as a Vaadin component.

Check it out for yourself:

Licensed under the Apache License 2.0.

Currently the only browsers supporting the GeoLocation API that I know of are Firefox 3.5+ and (at least some versions) of the Mobile Safari (on iPhone/iPod touch).

Hello, I’m new to Vaadin and I need to integrate the Google maps API.
I wonder if creating the addon for you is possible to create routes from point A to B.

If possible I would appreciate help, it would be a very useful guide since importing the addon to some code of how to use.

I use Netbeans + Vaadin (6.7.4)

Sorry I’m English, my English is basic, google translator helped me rsrsrs.
I’m from Brazil.

Thank you.

I got surprising behavior on a MacBook (running Lion 10.7.3) using the Safari browser.

I tried the demo:
http://teemu.virtuallypreinstalled.com/GeoLocation

The demo puts my location precisely where I was yesterday, in a house in Seattle. But today at this moment I am using a wifi at a library on Lopez Island in Puget Sound. That’s 100 miles away.

In contrast, Google Chrome 17 browser showed my correct location.

The problem is not with the add-on component. I tried the geolocation button on the web page:
http://maps.google.com/
in both Safari & Chrome. Same behavior: Safari has yesterday’s location, while Chrome is correct.

Any idea how the geolocation works on a Mac without any real GPS? Isn’t it based on the current wifi? Why would Safari be confused but not Chrome?

–Basil Bourque

Hi,

I’m not familiar with the exact details but the used wifi network surely has some effect. This can be easily verified by comparing results with AirPort on and off. I would guess that the IP address is also used to get a coarse location.

  • Teemu

Hi,

I have tried the addon which works great in IE 9.0.

I noticed in Firefox 13.0 the browser does not respond on the ‘send current location’ button click.
In Chrome 19.0 the location does not get reconized (position_unavailable) , but actions do get through.

Can you take a look at it or give us some work-arounds to resolve this?
Ofcourse, if that is within your reach.

Greetings, Remie

Hi Remie,

I quickly tested the
demo application
of GeoLocation add-on with Firefox 13 and Chrome 19 on Mac OS X (Snow Leopard) without any issues. What do you mean by the ‘send current location’ button? Are you referring to the “Show me on the map” button on the demo application or is this something on your own application?

Hi Teemu,

With send current location, i meant the popup where the browser asks the user for permission to send your current location. Though, i solved this, my local network was blocking these communications. Please disregard my last question therefore.

I tried the demo application. IE gives me different coordinates than Chrome and Firefox. Both are not the location that i expected.


Chrome and Firefox:

Latitude: 52.709799
Longitude: 5.863654


IE:

Latitude:52.366699
Longitude: 4.65


Supposed location:

Latitude:52.68593
Longitude: 4.792739

If the shown location would be near the supposed location it would be great. As tested above, the differences are abnormal.
Any clue why these positions are different ?

When you tested it at on your Mac OS X , was the location the same on each browser?

Thanks

After testing on different networks i found out that some get the exact location and some don’t.
So it isnt a issue comin from the Addon but more based on the current networkconnection which can be inaccurate.

Greetings, Remie

Geolocation systems are based on your IP address, which might come from a block that is very closely geographically grouped or not. They might e.g. know approximately where the next hop router is but not exactly where your computer is.
Some systems (e.g. smartphones) may also use the wifi networks near the computer for more accurate location.

All the systems are based on incomplete and not 100% reliable data, and different providers have different data sets but the quality is improving all the time.

Hi all
GeoLocation i cann’t use it on vaadin 7

Unfortunately I haven’t had time to port this add-on to support Vaadin 7 yet. :frowning:

  • Teemu

We started using Vaadin with v7. This would be a great addon for us if it is ported to v7. Are there plans to do so? Is there any documentation out there aobut how to port addons to v7?

Hi everybody! Have someone found the solution for Vaadin 7? How can we get the geolocation of the user? Help me pliiiiiz!!!

The code for the addon looks fairly straigforward. If you really need it you could just port it yourself.
Vaadin 6 basically had a Server and a client class and the communication worked through a updateFromUIDL method (as far as i know)
Vaadin 7 now uses a Server class - Connector - Client class pattern and has State classes and RPCs for communication.
More information can be found here un der Custom Widgets:
https://vaadin.com/wiki/-/wiki/Main/Vaadin+7

Or maybe I can do it by inserting the javascript??? I tried to insert it like this

JavaScript.getCurrent().execute(“navigator.geolocation.getCurrentPosition(function(position) {” +
" alert(position.coords.latitude);" +
“});”);

it shows me the latitude in the alert but, how can i get the value of latitude and longitude and use in it codes?

Explaining the logic in a few words probably won’t really work as the structure is not that easy (it’s not the most difficult thing either though). The best tutorials i can think of are the ones i link to in the Vaadin 7 wiki. You don’t really have to know how to build an addon but more how to build custom client side widgets.

If it’s just this one line of Javascript you’ll probably be better of not creating a custom widget but creating a JS component or extension as described
here(JS Component)
and
here(JS Extension)
. You essentially have to get the information from the client side (where the JS get executed) to the server side (where you’ll be able to process the information). If you’re following the JS Component tutorial for example you could instead of creating the actual component execute your Javascript and add the retrieved information to the state variable.

Another way if it’s really simple Javascript without additional libraries would maybe be to send a XMLHttpRequest from the client to the Vaadin Servlet in which you can then process the information if you’re more used to doing Client-Server communication this way.

Thank you very much!!! I will try it

Marius I have tried. I found tutorial I will attach the files of it. It works fine, I can transfer data from server to client in this example. But I can not understand how can i get the data from client to server-side.

You wrote me “If you’re following the JS Component tutorial for example you could instead of creating the actual component execute your Javascript and add the retrieved information to the state variable.” How can I retrieved information to the state variable?
Please help me again!!!
15735.java (193 Bytes)
15736.js (439 Bytes)
15737.java (486 Bytes)
15738.java (1.25 KB)
15739.js (16.5 KB)

To get data from the client to the server you have to use RPCs as States can only be used for server to client communication (sry that i didn’t mention that).
Here is a tutorial:
https://vaadin.com/wiki/-/wiki/Main/Simplified+RPC+using+JavaScript