Technical Info

Integration of the map on your Internet page

It takes about 30 minutes to integrate GetMyPosition into your website. After your free registration, you will receive an email with your user identification ($id) and your secret key ($secret_key).

You only have to change two files on your web server:

  1. The file where you want the map to appear on (as an internal frame).
  2. The file that gets latitude and longitude as parameters to be processed.

The following PHP example code includes the map on a page:
<?
// You get the following two codes when you register (for free).
$secret_key "56YuHjkHpwI7GGZYLwhCOcdvkCwIF29GYXYz496nvFlcna1Zx9";
$id 1234;
// This can contain a session ID, user number, or whatever you want:
$user_ident "ExampleUser";
// Enter a colour code to make the map background fit your page's (don't start with a "#" sign!):
$page_color "ddddff";
// Enter the messages you want to appear on the maps (the default is shown, if you want none you can use empty strings):
// (Note that the output uses UTF8 encoding, so you should either edit this script in the same encoding or use the function utf8encode.)
$m1 "Please click on the map (1 of 3)";
$m2 "Please click on the map (2 of 3)";
$m3 "Please click on the map (3 of 3)";

$code sha1(($time=time()).$secret_key.GetHostByName($REMOTE_ADDR).$user_ident);

print 
"<IFRAME FRAMEBORDER=0 WIDTH=600 HEIGHT=340 SRC='http://www.getmyposition.com/pos?"
    
."c={$code}&amp;t={$time}&amp;n={$id}&amp;i={$user_ident}&amp;color={$page_color}&m1={m1}&m2={m2}&m3={m3}'></IFRAME>"
?>

In case you are not using PHP, but some other scripting language, please send us an email so that we can provide you with the relevant code.

The resulting page with the <IFRAME> could then look like in these demos: with or without a GetMyPosition logo.

You can include the above code in whichever page you choose, without notifying us. This is different with the results page, as GetMyPosition needs to know to which page to submit its results. During registration, you will thus be asked to supply its address. In case you supplied

http://www.opera-example.com/show_results.php,
the page would be called like this:
http://www.opera-example.com/show_results.php?lat=10.123&lon=-20.456&ident=123456
The number (or string) supplied as ident is the same that you supplied as $user_ident in the above PHP example and allows GetMyPosition to tell your results page which user (or whose session) the positioning belongs to.

Receiving Coordinates

As an example for the coordinate-relevant part of a results page, the following PHP code simply displays the resulting coordinates:
<? print "Got coordinates from visitor {$_REQUEST['ident']}:"
    
."Longitude {$_REQUEST['lon']}, Latitude {$_REQUEST['lat']}?>

Positive latitudes are Northern, positive longitudes are Eastern.

Alternative Presentation of the Map

Of course, the map-creating code can be part of a page that you previously opened in a pop-up window, and later feed the results to the main window. Or it could be hidden using CSS and only shown (using JavaScript) once the user clicks on a button to begin the positioning process. Basically, you can adapt the presentation of the map how you could adapt any of your own content.

Skipping the world map

If you expect your users to come from a specific country, you can skip the first map displayed by appending a parameter of the form
&startpos=49/2
to the <IFRAME> address. The values chosen above will take you to a map around 49°N 2°E, centered between London and Paris. For southern latitudes or western longitudes, use negative values. Please note that the map cannot be exactly centered on arbitrary points.

The entered numbers can be decimals like &startpos=49.1/2.234. If instead, you wish to enter coordinates in degrees, minutes and seconds, simply concatenate them like this: 30°21′54″N and 12°48′33″E becomes &startpos=30/21/54/12/48/33. You can also leave the seconds away and round the expression to &startpos=30/21/12/48.

You can test this functionality in this demo, which uses the 49/2 example.

Position Display Service

Once you have registered a coordinate as determined by a user, you can mark it with a red crosshair on a map by appending parameters like
&startpos=47.554/10.736&showonly=3
to the original <IFRAME> address. In this case, Neuschwanstein Castle in Germany would be shown, as can be seen in the respective demo.

One useful example of this functionality is to redirect to the position display from your script after the user has entered his coordinates.

Of course, you can enter any coordinates here without having determined them using GetMyPosition. In any case, no credits will be deducted from your account, but a GetMyPosition logo will be displayed in case you have no positioning credits on your account.

The showonly parameter chooses the starting zoom level and can be 2 or 3, indicating the corresponding step in the positioning service. This level, however, can still be toggled by the user by clicking on a magnifying-glass icon.

In case you only want to use the position-display service, but not the positioning service, you do not have to create an account, but can simply link to

www.getmyposition.com?lat=47.554&lon=10.736&text=Neuschwanstein Castle
This is used in the following example links, with a small and with a normal-sized browser window, both showing the specified text as annotating title.

Computing Distances

At imaginerc.com, you can download a PHP class that allows the computation of the distance between two places on Earth, as used in this site's demo examples.