API
Basics
- 1.Render my location
- 2.Render my location in a specific element of my page
- 3.Show my location only when my page is loaded
- 4.Using other output formats (plain text, JSON, XML, ...)
- 5.Using with other programming languages
Basic module - Render my location
If you're not logged, your API Key will be replaced by "[your-user-key]".
This will generate the following code:
Street, Town & Countrydocument.write('30 cooper square, New-York, USA')
Preview: 30 cooper square, New-York, USA
Same, linked to Google Maps:
document.write('<a href="http://maps.google.com/?z=14&q=30+cooper+square%2C+New-York%2C+USA" target="_blank">30 cooper square, New-York, USA</a>')
Preview: 30 cooper square, New-York, USA
Note: This address is an example, it will be replace by yours
Render my location in a specific element of my page
First, if document.write() doesn't fit your needs, you can provide an id name and we will use it as an innerHTML instead.
This will generate the following code:
document.getElementById('mydiv').innerHTML = "30 cooper square, New-York, USA"
Show my location only when my page is loaded
You can use the following code to request your location only when the rest of your website is fully loaded. Our server can be slow (free products don't have cache servers everywhere like Facebook does...), but that's not a reason to slow YOU down.
Note: An id is needed (see "Render my location in a specific element of my page"). We put a <span id='pocketlocator'> as an example. Feel free to adapt to your needs.
Other output format
Oh great, so you want more? We don’t support SSH (yet?), but here is what we have for you:
Values
Here is the list of datas we do provide:
Label:
Full output, including link to external map service if chosen. This string may contain HTML tags.
This may also be a "custom text".
Full:
Contains Street name, Town nane & Country name if available.
Custom text:
A text typed by the user when submitting. This text is limited to 150 characters.
Default module behaviour replaces the location by this 'custom text' value.
Street:
Street name, based on Google API geocoding if the device has a GPS capability, otherwise via user submitted infos.
Town:
Town name, based on Google API geocoding if the device has a GPS capability, otherwise via user submitted infos.
Country:
Country name, based on Google API geocoding if the device has a GPS capability, otherwise via user submitted infos.
Lat:
GPS latitude. It will be empty if user device has no GPS capability.
Lng:
GPS longitude. It will be empty if user device has no GPS capability.
Mode:
Screening mode that the user has chosen during submission. Values are 'CT' for Custom text, 'STC' for Street+Town+Country, 'ST' for Street+Town, 'TC' for Town+Country, 'S' for Street only, 'T' for Town only or 'C' for Country only.
Link:
Map service choosen by user during location submission. It can be 'gmap' for Google Maps, 'bing' for Bing Maps, 'yahoo' for Yahoo! Local Maps or 'none' if the user ask for no link.
JSON object output URL:
http://www.pocket-locator.com/api/?k=[your-user-key]&f=json
This will output an object as the following:
{
"pocketlocator" : [
{
"label" : "At the office",
"full" : "30 Cooper Square, New-York, USA",
"street" : "30 Cooper Square",
"town" : "New-York",
"country" : "USA"
"lat" : "40.72809575709464"
"lng" : "-73.99128394699096"
"mode" : "CT"
"link" : "gmap"
}
],
}
Note: Yes, we do support JSONP too.
XML object output URL:
http://www.pocket-locator.com/api/?k=[your-user-key]&f=xml
This will output the following:
<?xml version="1.0"?>
<pocketlocator>
<custom>At the office</custom>
<street>30 Cooper Square, New-York, USA </street>
<street>30 Cooper Square</street>
<town>New-York</town>
<country>USA</country>
<lat>40.72809575709464</town>
<lng>-73.99128394699096</lng>
<mode>L</mode>
<link>gmap</link>
</pocketlocator>
Using with other languages
Flash ActionScript3
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, loadXML);
loader.load(new URLRequest("http://www.pocket-locator.com/api/?k=[your-user-key]&f=xml"));
function loadXML(e:Event):void
{
var pl:XML = new XML(e.target.data);
}
PHP
<?php
$myPLAddress = file_get_contents('http://www.pocket-locator.com/api/?k=[your-user-key]&f=txt');
echo $myPLAddress;
?>
ASP.Net
using System.Text;
using System.Net;
using System.IO;
HttpWebRequest urlRequest = (HttpWebRequest) WebRequest.Create("http://www.pocket-locator.com/api/?k=[your-user-key]&f=txt");
urlRequest.Method = "GET";
WebResponse urlResponse = urlRequest.GetResponse();
StreamReader stream = new StreamReader(urlResponse.GetResponseStream(), System.Text.Encoding.UTF8);
string result = stream.ReadToEnd();
stream.Close();
urlResponse.Close();
RUBY
require 'net/http'
myPLAddress = Net::HTTP.get_response(URI.parse("http://www.pocket-locator.com/api/?k=[your-user-key]&f=txt")).body
WORDPRESS WIDGET
In your Dashboard, go in "Appearance", "Widgets" and use a "RSS" widget. It should ask you a RSS Feed URL:
STILL HAVING TROUBLE?
Don't be shy, just contact us