Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Scotch.io:
Achieving Geo-search with Laravel Scout and Algolia
Jul 19, 2017 @ 14:38:24

The Scotch.io site has posted a tutorial from author Julien Bourdeau showing you how to combine Laravel Scout, a tool that enables full-text searching on Eloquent models and the Algolia searching service to create a geo-search to locate items in your data based on physical location.

Laravel Scout makes it very easy to setup an external search engine to create consumer-grade search quickly. The package comes with Algolia as a default search engine. I'd like to demonstrate how to make use of the geo-location search feature with Scout.

In this tutorial, you'll learn how to prepare your data for Algolia and Laravel Scout to retrieve items based on location.

We recommend you use front-end search for your app because this implementation model is most efficient. That being said, there are cases where you need backend search, for instance, if you want to generate reports.

The tutorial is then broken up into several steps towards the goal of creating the application:

  • Install Scout
  • Format your data for indexing
  • Search for your records
  • Leveraging Macros

The searching they create allows for location of data either by searching in a given location (coordinates and radius) or locating items inside of a "zone" (a rectangle defined by at least two points). All code is included as well as examples of the data structure Algolia requires for your data input.

tagged: geosearch search geography tutorial laravel laravelscout algolia geolocation

Link: https://scotch.io/tutorials/achieving-geo-search-with-laravel-scout-and-algolia

Loïc Faugeron:
Mars Rover, Locating geolocation
Oct 05, 2016 @ 14:04:37

Loïc Faugeron is back with the next part of his "Mars Rover" series (you can find all of the articles so far here with his latest post covering the Locating class' geolocation functionality.

In this series we're building the software of a Mars Rover, according to the following specifications. It allows us to practice the followings: Monolithic Repositories (MonoRepo), Command / Query Responsibility Segregation (CQRS), Event Sourcing (ES) and Test Driven Development (TDD)

We've already developed the first use case about landing the rover on mars, and the second one about driving it. We're now developing the last one, requesting its location. [...] In this article we're going to create a new package for the geolocation value objects (Location, Coordinates and Orientation).

He starts off by creating the geolocation package and its matching composer.json file. He then creates the phpspec configuration for the package and commits this initial version. He pulls this new package into the larger current codebase and makes an update to the overall phpspec configuration to run its tests. With that in place he updates two related packages, location and navigation, to include the new library before integration (coming in the next part of the series).

tagged: mars rover tutorial series location geolocation package

Link: https://gnugat.github.io/2016/10/05/mars-rover-locating-geolocation.html

SitePoint PHP Blog:
Where are you? Implementing geolocation with Geocoder PHP
Oct 23, 2014 @ 16:45:17

The SitePoint PHP blog has a new tutorial posted by Arno Slatius showing you how to use geocoding in PHP to find the latitude and longitude of a point given its address or name. He makes use of the geocoder-php library to make things a bit simpler.

The beauty of SitePoint, to me, is that you can get inspired to try something or be told about some cool project out there. The internet is simply too big for one person to scout out on their own. Geocoder was one of those for me. I had never heard about it and came across it on the authors Trello board. I love working with maps and geographic information and I use (reverse) geocoding heavily for a project I did for a client; CableTracks. [...] I found out that Geocoder PHP actually is what I was missing for the integration of various services that we use.

He starts by helping you get the library installed (either via Composer or manually) and the creation of a simple Google Maps goecode request for a location. He includes an example of the results and mentions how the library handles locales in both the input and output. He also shows how the tool lets you do reverse geocoding - given a latitude and longitude, it can provide you address and location information. It also includes lookup support for IP addresses and output formatting and examples using both are also included.

tagged: geolocation geocoder tutorial library introduction geocoderphp

Link: http://www.sitepoint.com/implementing-geolocation-geocoder-php/

Paul Reinheimer:
Using GeoIP at WonderProxy
Nov 07, 2013 @ 16:57:09

Paul Reinheimer has a new post talking about some of his experience implementing GeoIP at his HTTP testing proxy service WonderProxy (and the steps you'd need to take to make it work for your application). The GeoIP service helps you identify the sources (geolocation) of connections to your applications.

At WonderProxy we’ve been helping people test their GeoIP sensitive applications since launch. It’s why we launched. Perhaps ironically it’s never been a technology we’ve used on our own website. With our upcoming re-design that’s changing.

He's broken it down into four major steps, each with a bit of description to go along with them:

  • Using GeoIP
  • Acquire a database
  • Rebuild Apache & PHP (with the Apache module)
  • Handle edge cases

This isn't a detailed tutorial to getting GeoIP support working in your app, but it does provide a good direction and links to several resources to help you along your way.

tagged: geoip geolocation wonderproxy overview tutorial database

Link: http://blog.preinheimer.com/index.php?/archives/421-Using-GeoIP-at-WonderProxy.html

Etsy Code as Craft:
There and Back Again: Migrating Geolocation Data to GeoNames
Apr 01, 2013 @ 16:48:36

On the Etsy "Code as Craft" blog there's a recent post about their move to using the GeoNames service internally rather than the external, third-party API previously in use.

People are passionate about where they live. At Etsy we need to keep track of lots of different locations, such as buyers’ billing and shipping addresses and sellers’ shop locations. As Etsy continues to expand internationally we wanted to provide better localization and translations for our location place names. We determined that the best way to effect this change was to move from using a closed location API provider to internal services backed by the open GeoNames data set.

The post details some of the steps in the process including the mapping of the current data to the new structure (the script is available on github). They talk about how they mapped their old data over (trial and error sometimes) and the creation of a database of "GeoNameIDs" for each customer in their records. They've also implemented a Lucene/Solr search for improved searching and auto-suggestion based on the user's location.

tagged: data migration geonames geolocation api script

Link:

PPI Framework Blog:
Tutorial: GeoLocation with FourSquare and Google Maps
Jan 28, 2013 @ 19:06:28

On the PPI framework blog there's a recent post showing how to use the framework to create geolocation functionality via an interface with FourSquare and Google Maps.

In this article, we're going to learn how to work with the framework as a whole by writing a real-world application: making a module, controller, routes, templates (views) and services. In order to achieve this we are will use the Foursquare API, and APC for caching the API lookups. We will plot venues from Foursquare in Google Maps for display.

They help you set up a skeleton application and start on creating the "Foursquare Module" along with its controller and views. There's Javascript code included to use the Google Maps functionality and a simple class to work with the FourSquare API to get nearby venues. In the end, you'll have a basic application that maps out the points automatically.

tagged: geolocation foursquare googlemaps tutorial ppiframework

Link:

Sherif Ramadan:
Web Analytics with PHP and Google Visualization: Made Simple
Dec 19, 2012 @ 18:38:47

in this new post to his site Sherif Ramadan shares a method for visualizing your website's visitor data with the help of the Google Visualization APIs and some geolocation.

The web is a place where everyone is in your backyard. This can be both a blessing and a curse. How do you know where your website traffic is coming from and how much of it there is? [...] How was traffic led to your website in the first place and why? How long do people stick around and what do they like the most about your site? These are all some of the many questions you can answer with web analytic software, but the real question is why would you want to answer these questions at all and what’s the best way to look at the answer?

[...] If we look at a heat map it’s easier to spot where the majority of our visitors and traffic are coming from, geographically. It also helps us understand that people visiting a virtual space can, and will, be physically located in different parts of the world.

He includes the steps to recreate a map like the one included in this page showing the current view statistics on his site. He uses a MySQL backend to store the GeoIP data and parses out the Apache "access_log" to get the IPs of the visiting users. He then runs these against the GeoIP data and passes this country data on to Google's visualization for handling. He also recommends using the tools offered by the Google Webmaster Tools to further enhance your introspection into your site's visitors.

tagged: google analytics geolocation analytics visualization country

Link:

Chris Risner:
Mobile Geolocation Apps with Windows Azure Websites Part 1: The PHP Code
Sep 19, 2012 @ 13:14:46

Chris Risner has posted the first part of his series looking at mobile geolocation in PHP-based Azure applications as hosted on the Windows Azure service.

The first article in this mini-series on creating geolocation apps with the backend hosted in Windows Azure Websites is going to be a walkthrough of the PHP code that we’ll host in Windows Azure. The PHP site will be simple and expose just a few methods. Prior to getting into the code for the service, we need to setup a new website in Windows Azure and set up our database.

He walks you through some of the initial steps to create the PHP side of things - setting up the website instance and database, downloading the Silex PHP framework and the PHP code to get process the latitude and longitude of the current user. Also included is code to help find "interesting" points near the user and code to allow the user to add their own.

tagged: tutorial windowsazure azure geolocation mysql silex latitude longitude

Link:

PHPMaster.com:
Where on Earth are You?
Feb 02, 2012 @ 14:52:54

In PHPMaster.com's latest tutorial Lukas White introduces you to using the Yahoo "Placemaker" web service to geographically locate a place from a free-form text string. The results include "place details" like the type of the location, latitude, longitude and how confident they are in their match.

The challenge then is to do two things: work out what place you could be talking about, disambiguate if necessary, and then identify exactly where on Earth that is. That's what I'll show you how to do in this article; by using a freely available web service, we’ll write a simple program to ask users where they are (and ask them to clarify if necessary) before identifying their responses in concrete terms.

He shows how to make a request to the Placemaker web service, passing it a string coming from the user, to be located. The POST request contains a few pieces of data including an application ID , your desired output type and the language you're using for the input. His example code uses curl to make the request and handles it (the XML response at least) with a call to simplexml_load_string.

tagged: where geolocation yahoo placemaker webservice api tutorial

Link:

PHPMaster.com:
Targeted Geolocation with Geonames
Dec 13, 2011 @ 18:10:02

New on PHPMaster.com there's a tutorial from Lukas White about targeting users using geolocation based on the Geonames web service and a latitude/longitude. His example makes a call to find the closest "place" to the given coordinates.

Location-aware applications rely on being able to locate where you are, and this is what geolocation is all about. After all, once the application knows your location, it can go on to find the nearest store, guide you through the appropriate route to a destination, or target relevant advertisements to you. Geolocation, then, is simply the mechanism for identifying your geographical location.

He mentions two challenges associated with geolocation - finding where someone is and describing the location. With Geonames, he shows how to call the service's "findNearbyPlaceName" method to find the closest "place" to a given latitude/longitude combination. Included is a bit of sample PHP to connect to the service and Javascript to request the user's current location.

tagged: geolocation tutorial geonames webservice json location

Link:


Trending Topics: