45
WordCampCB Location Based Services

WordCamp Columbus - Location Based Integrations

Embed Size (px)

Citation preview

Page 1: WordCamp Columbus - Location Based Integrations

WordCampCB

Location Based Services

Page 2: WordCamp Columbus - Location Based Integrations

Hash Tags and Whatnot

• #wccb – WordCamp Columbus

•#wccb #lbs – LBS Session

Page 3: WordCamp Columbus - Location Based Integrations

Introductions

50% of the United States population lives

within a 500 mile radius of Columbus.

Page 4: WordCamp Columbus - Location Based Integrations

Who are You and Why are You here?

• Understanding• Ideas or Insights• Technologies

Page 5: WordCamp Columbus - Location Based Integrations

Introductions

@LukePilon• Software Architect• WordPress • 4 Years as a User• 2 Years Designing Software• Community Involvement

• CEO at Mobiah• AC/DC, Lolcats, and the 80s

Movies

Mobiah, Inc• Services, Software, Data• Acquisition and Loyalty• GPL Software• Producers of GeoPosty• 3 Plugins in the .ORG

Repository

Page 6: WordCamp Columbus - Location Based Integrations

Content for Today

• Orientation – What is a LBS• Logic – When to leverage LBS• Methods – Access User Location• Basic Delivery – How to Deliver a Simple LBS Loop

Page 7: WordCamp Columbus - Location Based Integrations

What the what

• Location-Based Services refers to a broad range of services that are based on (or enhanced by) information about the physical location of a user and/or device.

• $10 billion in revenue by 2016*

http://www.businesswire.com/news/home/20110609006492/en/Strategy-Analytics-Cellphone-Privacy-Concerns-Short-Term-Barrier

Page 8: WordCamp Columbus - Location Based Integrations

What is a LBS?

They are a LBS and you are a LBS

Everyone’s a LBS, S, S, S….

Page 9: WordCamp Columbus - Location Based Integrations

LOCATION BASED SERVICESThe time and place to use them.

Page 10: WordCamp Columbus - Location Based Integrations

Location is Important

• What level of location do you actually need before your user starts to see value?• Continent • Nation• State• City• Block

Page 11: WordCamp Columbus - Location Based Integrations

Use Cases

• Ad Targeting• Digital Rights Management• Localizing Content• Fraud Prevention

Page 12: WordCamp Columbus - Location Based Integrations

Use Cases and You

• Providing Specific Deals, Moving Inventory• Protecting Your Content Rights / Restrictions• Enriching the User’s Experience • Blocking Unauthorized Users

Page 13: WordCamp Columbus - Location Based Integrations

Food For Thought on LBS

• 20% of all Google Searches Performed on a Desktop Involve Location

• 40% of all Google Searches Performed on a Mobile Devices Involve Location

Page 14: WordCamp Columbus - Location Based Integrations

ACCESSING USER LOCATION

Page 15: WordCamp Columbus - Location Based Integrations

Implementations

• IP Geolocation•HTML5

Page 16: WordCamp Columbus - Location Based Integrations

IP GEOLOCATIONYou have an IP Address & we know geographically where that is.

Page 17: WordCamp Columbus - Location Based Integrations

IP GEO Properties

• Always On• Static in Nature• No Permission• 25-50 Mile Localization

Page 18: WordCamp Columbus - Location Based Integrations

IP GEO LIBRARIESHow it gets done

• Agreements with ISPs• AppSourcing the Crowd• Mad Scientists with Mad Bots• Wifi Libraries

Page 19: WordCamp Columbus - Location Based Integrations

IP Geo Libraries

Service Providers

• IP2Location• MaxMind• Quova, a Neustar Service

Libraries in General

• 4B IP Addresses• ~ 20% Actively Changing• Accessible via DB, API

Page 20: WordCamp Columbus - Location Based Integrations

Plugins that do IP Geo

• GeoPosty 4,084 Downloads – 4.25 Stars• Quova IP Technology

• IP2Location Tags – 468 Downloads – 5 Stars• IP2Location IP Technology

• WP Geolocation – 1,120 Downloads – 2.75 Stars• MaxMind IP Technology

Page 21: WordCamp Columbus - Location Based Integrations

Plugin Features

• Shortcodes• Preconfigured Widgets• Redirection• 3rd Party LBS Integrations

Page 22: WordCamp Columbus - Location Based Integrations

Obligatory CODE SLIDE

<?php echo do_shortcode('[geocity]');  ?>

[geolongitude] and [geolatitude]

Page 23: WordCamp Columbus - Location Based Integrations

HTML5 GEOLOCATIONPermission based access to users’ location.

Page 24: WordCamp Columbus - Location Based Integrations

HTML5 Background

• A collection of HTML standards being brought into adoption.

• Not something that’s going to show up all at once, not even on your birthday. #sorry

• Many features are already in adoption with current browsers.

Page 25: WordCamp Columbus - Location Based Integrations

HMTL5 Geolocation

• A singular feature of the HTML5 Standard• Off By Default• Can be coded as dynamic• Permission Based, Error handling can be difficult• ~ 12 Meter Localization

Page 26: WordCamp Columbus - Location Based Integrations

HTML5 Geolocation APIHow it Gets Done

•Cell Tower Triangulation•Device GPS• IP Geo Libraries

Page 27: WordCamp Columbus - Location Based Integrations

HTML5 Geolocation API

• IE – 9.0+• Firefox – 3.5+• Safari – 5.0+• Chrome – 5.0+• Opera – 10.6• iPhone – 3.0+• Android – 2.0+

http://diveintohtml5.org/geolocation.html

Page 28: WordCamp Columbus - Location Based Integrations

Browser Adoption

24.90%

42.40%

25.90%4.00%

2.40%

% of Usage

Internet ExplorerFirefoxChromeSafariOpera

Page 29: WordCamp Columbus - Location Based Integrations

IE Support #Fail

IE Supported

IE 9

IE 6 - 8

Page 30: WordCamp Columbus - Location Based Integrations

Firefox Support

FF Support

FF 3.5 - 4

FF 3

Page 31: WordCamp Columbus - Location Based Integrations

A Safe AssumptionBefore the Opt-In

1+ out of 2 Users

Can Currently Support HTML5 Geolocation

Page 32: WordCamp Columbus - Location Based Integrations

Google Analytics Will Set You Free

Page 33: WordCamp Columbus - Location Based Integrations

Plugins

Page 34: WordCamp Columbus - Location Based Integrations

Obligatory CODE SLIDE

• function get_location() { navigator.geolocation.getCurrentPosition(show_map); }

// Callback function once location has been granted• function show_map(position) { var latitude =

position.coords.latitude; var longitude = position.coords.longitude; // let's show a map or do something interesting! }

Page 35: WordCamp Columbus - Location Based Integrations

STAND AND DELIVERYou, or your client, as an LBS

Page 36: WordCamp Columbus - Location Based Integrations

Best Practices

• Location, Location, Location with Balance, Balance, Balance

• Give the User A Logical Exit• Don’t Be Evil, Get Consent, Allow Record Removal• Privacy Policy FTW

Page 37: WordCamp Columbus - Location Based Integrations

Never, Never Never Ever

• Hello [geocity]! Welcome to my site!

• #FAIL #FAIL #FAIL #FAIL

Page 38: WordCamp Columbus - Location Based Integrations

Super Simple LBSing.

• Step 1: Put Your Content to City Categories• Step 2: Load The User’s Location Into Shortcodes• Step 3: Get Loopy

Page 39: WordCamp Columbus - Location Based Integrations

The Basic Geo Loop

<?php

$city = do_shortcode('[geocity]');

$args = array('category_name' => $city);

$myCityQuery = new WP_Query($args);

if ($myCityQuery->have_posts()): while ($myCityQuery->have_posts()): $myCityQuery->the_post();

//post stuff

endwhile; endif;

?>

Page 40: WordCamp Columbus - Location Based Integrations

BONUS MATERIAL

Page 41: WordCamp Columbus - Location Based Integrations

CODE – Useful Functions

// http://snipplr.com/view/2531/calculate-the-distance-between-two-coordinates-latitude-longitude/

function getGeoDistance($lat1, $lng1, $lat2, $lng2, $miles = true)

{

$pi80 = M_PI / 180;

$lat1 *= $pi80;

$lng1 *= $pi80;

$lat2 *= $pi80;

$lng2 *= $pi80;

$r = 6372.797; // mean radius of Earth in km

$dlat = $lat2 - $lat1;

$dlng = $lng2 - $lng1;

$a = sin($dlat / 2) * sin($dlat / 2) + cos($lat1) * cos($lat2) * sin($dlng / 2) * sin($dlng / 2);

$c = 2 * atan2(sqrt($a), sqrt(1 - $a));

$km = $r * $c;

return ($miles ? ($km * 0.621371192) : $km);

}

Page 42: WordCamp Columbus - Location Based Integrations

CODE – Useful Functions

// http://www.hashbangcode.com/blog/search-engine-spider-detection-php-258.html

function geoSpiderDetect() {

$agentArray = array("ArchitextSpider", "Googlebot", "TeomaAgent",

"Zyborg", "Gulliver", "Architext spider", "FAST-WebCrawler",

"Slurp", "Ask Jeeves", "ia_archiver", "Scooter", "Mercator",

"crawler@fast", "Crawler", "InfoSeek Sidewinder",

"almaden.ibm.com", "appie 1.1", "augurfind", "baiduspider",

"bannana_bot", "bdcindexer", "docomo", "frooglebot", "geobot",

"henrythemiragorobot", "sidewinder", "lachesis", "moget/1.0",

"nationaldirectory-webspider", "naverrobot", "ncsa beta",

"netresearchserver", "ng/1.0", "osis-project", "polybot",

"pompos", "seventwentyfour", "steeler/1.3", "szukacz",

"teoma", "turnitinbot", "vagabondo", "zao/0", "zyborg/1.0",

"Lycos_Spider_(T-Rex)", "Lycos_Spider_Beta2(T-Rex)",

"Fluffy the Spider", "Ultraseek", "MantraAgent","Moget",

"T-H-U-N-D-E-R-S-T-O-N-E", "MuscatFerret", "VoilaBot",

"Sleek Spider", "KIT_Fireball", "WISEnut", "WebCrawler",

"asterias2.0", "suchtop-bot", "YahooSeeker", "ai_archiver",

"Jetbot"

);

Page 43: WordCamp Columbus - Location Based Integrations

Parting Remarks

Imagine 2015

Page 44: WordCamp Columbus - Location Based Integrations

Parting Remarks

Go do something excellent.

Page 45: WordCamp Columbus - Location Based Integrations

Questions?

• Luke Pilon• [email protected]• @lukepilon