"Hello World" doesnt work

3 views
Skip to first unread message

nchreyes

unread,
Mar 4, 2009, 3:28:43 PM3/4/09
to Loki API
Hi I m try to make it work, I just create a html page with followin
code inside

<html>
<body>
<script type="text/javascript" src="http://loki.com/plugin/files/
loki.js"></script>
<script type="text/javascript">
function init() {
var loki = new LokiAPI();
loki.onSuccess = function(location) {
document.getElementById("address").innerHTML =
location.house_number+' '+location.street+'<br/>'+location.city+',
'+location.region_code+' '+location.postal_code+'<br/
>'+location.latitude+', '+location.longitude;
};
loki.onFailure = function(error, msg){
alert('An error has been encountered ('+error+'). '+msg);
};
loki.setKey('beta');
loki.requestLocation(true,loki.FULL_STREET_ADDRESS_LOOKUP);
}
window.onload = init;
</script>
<div id="address">
</div>
</body>
</html>

but Just a blank page is displayed.

ChrisRogers

unread,
Mar 20, 2009, 1:13:34 PM3/20/09
to Loki API
Try this:

<html>
<body>
<div id="address">
</div>
<script type="text/javascript" src="http://loki.com/plugin/
files/loki.js">
</script>
<script type="text/javascript">
function init(){
var loki = new LokiAPI();
loki.onSuccess = function(location){
document.getElementById('address').innerHTML =
location.house_number + ' ' + location.street + '<br/>' +
location.city + ', ' + location.region_code + ' ' +
location.postal_code + '<br/>' + location.latitude + ', ' +
location.longitude;
};
loki.onFailure = function(error, msg){
alert('An error has been encountered (' + error +
'). ' + msg);
};
loki.setKey('beta');
loki.requestLocation(true,
loki.FULL_STREET_ADDRESS_LOOKUP);
}

window.onload = init;
</script>
</body>
</html>

Ryan Sarver

unread,
Mar 20, 2009, 1:26:54 PM3/20/09
to loki...@googlegroups.com
Chris,

Thanks for following up on that. Just be sure to change setKey() to
your own key. Beta is used for demos and gets limited to a small
amount of calls per day and therefor you might get an "unauthorized"
error

Thanks guys, Ryan

CommerceXP

unread,
May 5, 2009, 2:59:17 AM5/5/09
to Loki API
I put it exactly as the same sample code as above, but it only shows
the latitude, longtitude, but no street number, name, city etc. do you
know any reason for that? is it because my API key does not have
enough permission?

http://pc604.com/loki/loki.html

Thanks,

Michael
> >> but Just a blank page is displayed.- Hide quoted text -
>
> - Show quoted text -

Ryan Sarver

unread,
May 5, 2009, 9:38:56 AM5/5/09
to loki...@googlegroups.com
Michael,

It worked for me when I tested -- I get the full street address. I
should note though that reverse geocoding is only available in the US.
So if you are viewing the page from outside the United States, you
won't get any street address information returned.

Where are you trying to run it from?

Best, Ryan
Reply all
Reply to author
Forward
0 new messages