This project is fairly simple yet, complicated.
50+ addresses are present
User will input or import addresses
Script must take addresses and provide non-optimized(or optimized [fastest/shortest]) direction between each address
Script must be able to map directions on map and provide information such as total distance, proximate time.
On side note script must validate address if it's valid or not. If not then tell user to fix it.
So far the company was using a desktop application for tracking, routing, directions, etc.
Now they want a web version.
I was thinking about using microsoft's bing service or google's maps.
Which do you think would suit better?
For address validation you could use Google's Geocoding API. It's not a perfect solution as it allows for addresses that might be partially wrong. An example is a user typing in 3002 Such and Such Street when 3002 doesn't actually exist.
Also, if the link doesn't have to be internal then you can provide a link to Google maps with the format http://maps.google.com/maps?saddr=[STARTING ADDRESS]&daddr=[DESTINATION ADDRESS]
I'd imagine there is also a way to handle directions with the Maps API but I'm not sure.
Related
Does anyone know of a piece of code that can run on a server that pipes the data from Apache logs into Google Analytics? I've got a bunch of websites that generate logs, but the users would likely object to injecting Google tracking codes into them. This might be a nice way to get the basics, what's being requested from where, and have it all sorted for me in with my other Google Analytics pages.
You can use the new measurement protocol (available for universal analytics account only) to implement a serverside solution.
Piping logs would probably not work very well (at least if you want to do a batch job - I don't think you can send a timestamp via the measurement protocol, so it would look as if all hits occured at the same time) but it shouldn't be necessary anyway, just create an url with the relevant parameters pointing to the google endpoint and sent it in the background via CURL (or similiar).
If you're in the European Union remember privacy guidelines still apply and you need to inform users and provide an opt-out link.
For non-Universal Analytics accounts, you can use php-ga - Server-Side Google Analytics Client -- it's essentially a server-side implementation of ga.js.
One caveat: If you want the location metrics to record something other than the location of your server, you'll need to log with a Google Analytics mobile tracking ID. Just replace the "UA" in the tracking ID with "MO", like "MO-12345678-1"
GA needs JavaScript, I think, so that various things like screen resolution can be grabbed. So even if this were possible, you'd be missing a good deal of info for some of your users, skewing your other percentages. Also, if your users are suspicious of Google, they probably would not want you to upload their IP addresses to GA.
With all that in mind, I wonder whether a self-hosted GA-like system would fit the bill? If so, try Piwik.
I am building an web app (with PHP) that requires users to subscribe. I would like for them to identify where they are from. So what is the best way to validate there country/state(or province)/city/postal code? Is there a DB with all the information? Which one is the best?
There are many options for address validation. The main issue is how much traffic your website will receive and whether or not you need support. If you are relatively small, you can get away with the free services like the following:
Google Maps API (example) (you may be breaking the TOS)
UPS Address Verification API (example)
USPS Address Web Tools
If you need something more robust or customizable, it will probably be necessary to pay for a service.
I know this is old, but to prevent others from going down the wrong path, the chosen answer to use Google API's may not have been aware of the google terms of service license (...the Geocoding API may only be used in conjunction with a Google map; geocoding results without displaying them on a map is prohibited.)
If you're not using a map...
and your requirements do not require commercial grade data, this sums up some options and what to look for.
however, if you need commercial data, greatdata.com and melissadata.com both sell real commercial level data products.
This thread is also helpful: stackoverflow thread on zip code data
Use the Google Geocoding API They allow 2,500 requests per day and you can pay for more. It will take an address and give you very detailed information on it and provide validation if you code it into your application.
Use the USPS Address Information API.
I've utilized data that can be purchased inexpensively from http://zipcodedownload.com/ to provide zip code validation/address correction in our applications.
I am looking for a PHP script to parse through a name and address field, the kind that people attach to the end of their emails. It would be uploaded as plain text and would be in this format:
John Q. Public
Director of Some Thing
123 Elm Street
Anytown, ST 11001
(000) 555-1212
(000) 555-1213 FAX
The addresses tend to vary in format, which is why I am wondering if anyone has taken this on yet. Thanks.
Because addresses can vary so much, this is not a trivial parsing task. If possible, I would recommend using a proven service such as The Google Geocoding API.
You could use PHP's file_get_contents() to retrieve the answer and json_decode() to read it (JSON is one of several formats the Geocoding API can return).
SmartyStreets offers an extraction tool to do this sort of thing. You can paste in any block of text and it will scrape through to extract any addresses that might be in it. SmartyStreets specializes in address validation, so our developers have already sorted out the parsing problem. You can check it out here. The extractor is a web tool, but you can use it programmatically using PHP. It does require at least a free subscription.
Here's a look at what it found from your fake email signature above:
(Just to be clear, I do work at SmartyStreets.)
Google Geocoding has a limit of 2,500 per day.
If you have alot of data being parsed, I suggest using another services.
The cheapest geocoding api that can return a formatted address similar to Google would be Geocode Farm. They have jSON also, so you can still use file_get_contents with json_decode(). I would suggest you use their 25,000/day ($25/mo) and parse it out through that if you have alot of data. If more than that, upgrade to a different plan. If you only need 2,500 but more in the future, I suggest you still use them because they are free for 2,500 too and you can upgrade the plan instantly to paid one in their dashboard.
Kind of biased towards using GeocodeFarm because their service is the only one that I have found that is better than Google, dirt cheap, and returns close to the same results if not spot on most times. Never had downtime and love them. I use GeocodeFarm for all my geocoding and address parsing.
The down site:
They don't provide the address components as Google does, only the returned / corrected address... :/ Hopefully they add address components in the future. The only thing I've found that's missing. :(
P.S. Either Google them or I linked their site to the word "Geocode Farm" above...
P.S.S. Sorry for late reply, but hopefully this will help someone else who looks for this...
today i tested the geolocation system implement by google on Chrome, with this page: http://www.browsergeolocation.com/ , the think is, is possible to use this service but without my ip?, i mean, using other ip to retrive the geo info.
PS 1: I know the are many sites that offer iptogeo services, but they only give you a very general address. This particular service gave not only the country and the state, it gave even the street!
PS 2: I post this question here because i know the solution may be on code. Thanks!
According to W3C,
The Geolocation API must be agnostic
to the underlying sources of location
information.
So no, given that the source might be an onboard GPS or triangulation based on on nearby SSIDs, it cannot be done with only an IP. You'd anyway only get as good result as from the iptogeo services if it worked, as Google can't reach into my computer and read my GPS. Yet.
I don't think you can use it for other peoples IP. The site uses location aware browsing which is a browser feature and needs to be authorized by the user. The user's browser also may provide additional information that only they have access too.
You can read more about location aware browsing at Geolocation in Firefox. This page is for firefox, but describes some important things.
FYI the accuracy for my result was limited to just my city.
Lately geo-targeting has been pretty popular in technology. By IP, cell tower, GPS, using browser plugins, HTML5?, mobile devices ...
Since I'm about to add some geo-targeted features on our site, I wanted to know what's the best approach. Is there some API that uses a mix of all those technologies? Or at least, what API/service would you recommend I use?
The service I'm working on doesn't need to be 100% accurate, so I'm OK with geo-IP, but if there's an easy way to do better, why not.
Technologies used are php, javascript, ajax, java.
Whatever you do please please please don't set the language of your website based on the user's IP, and then make it almost impossible to change unless you know said language and you feel like wasting hours (like ebay and paypal, among others, do). Use the browser's language.
Not everyone in, let's say, France speaks or wants to speak French.
I guess it's not very related to your question but i felt the need to rant about this, sorry :)
GEO IP is probably the best approach for now.
HTML5 looks promising, but it'll be a while before it's widely supported. And even then it requires explicit user approval, which kind of limits the possibilities for using it (for example auto-redirecting to a country specific version of a website)
For a start try the free http://api.hostip.info?ip=x.x.x.x (www.hostip.info for website)
It'll give you city and country in a xml structur. I've a small proxy-script writen in PHP on the http-server, which a html page calls with ajax and show the infomation in text and on a Google map using the Google geocoding api. Later on you can easy replace the api.hostip.info with an other api.
I would use IP address detection by default, and then optionally ask for a more specific location using the Javascript/HTML5 navigator.geolocation API when present. (For example, in iPhone Safari)
Most users are still using devices that don't know the location themselves, so plugins that are available will not get a better location than IP address detection does anyway. (Alternatively, they'll prompt users to manually enter data, which is annoying)
Max Mind is good. But if you are looking for a free solution, you may want to consider using the javascript geocoder. Eventually they will support addresses and country, but right now, they only give you a latitude and longitude.