Sie sind nicht angemeldet.

1

Freitag, 2. April 2021, 11:42

Get current geolocation of phone in map, and automatically orient panorama

Dear all, I am making an on-location panoramic tour with a couple of panoramic renders (around a place where once was an old castle). Now I want people to walk to that location, stand on the spots on the map, and look at the castle on their phone. Two things are missing: 1) is there a way to put the current location of the user/phone on that map, like you can in google maps itself, 2) and is there a way in which the panorama can automatically orient itself, aligning (in my case) North.
This is the current state: https://dataportal.nioz.nl/visualmodels/VR/
Any further suggestions are also welcome!
Thanks for any suggestion. Johan

2

Freitag, 2. April 2021, 12:15

Hi,

you can use the browsers Geolocation API for this:
https://developer.mozilla.org/en-US/docs…location-objekt

Here a quick example:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<action name="get_geo_location" type="Javascript"><![CDATA[
        
    krpano.actions.showlog();
    
    if ("geolocation" in navigator)
    {
        navigator.geolocation.getCurrentPosition( 
            function(position)
            {
                krpano.trace(1,"latitude=" + position.coords.latitude);
                krpano.trace(1,"longitude=" + position.coords.longitude);
                krpano.trace(1,"heading=" + position.coords.heading);
            },
            function(err)
            {
                krpano.trace(1,"geolocation error: "+err.message);
            }
        );
    }
    else
    {
        krpano.trace(1,"no geolocation support by the browser");
    }
]]></action>
    
<!-- a button for testing: -->
<layer name="get_geo_location" keep="true"
    type="text"
    html="Get Geo Location"
    align="center"
    onclick="get_geo_location();"
    />


Best regards,
Klaus

3

Freitag, 2. April 2021, 13:25

Placing it where...

Thanks, the button surely works and gives data. But where to put the action and have a button attached to it? In tour.xml, or in the skin where the map is defined.

I must admit I am not really sure how to do that. Anybody?
Thanks in advance, Johan

4

Mittwoch, 12. Mai 2021, 21:54

Hi,

you can use the browsers Geolocation API for this:
https://developer.mozilla.org/en-US/docs…location-objekt

Here a quick example:

Quellcode

1
2
3
4
5
6
<layer name="get_geo_location" keep="true" 
    type="text"
    html="Get Geo Location"
    align="center"
    onclick="get_geo_location();"
    />


Best regards,
Klaus
Please help how to use this code to xml.

Regards