In our work we like to create Google Maps links for our client’s (offices, stores, etc). However, the larger our clients presence, the more random links there are bound to be. When it comes to using Google Map’s javascript API to control the map, thats still perfectly fine. But how do I create a google maps link that only shows 1 entry? Turns out, there are several ways to do this:
- Manipulate the request such that it only shows your entryHow? For example, searching for “Holland, Singapore” will lead us to about 1,356 results. See here. So lets tweak it a little:
- Append
&mrt=ypto the url – That returns us all the business listings. (852 results) - Append
&start=16to the url – That skips the first 16 results (Shows results 17-26 of 852) - Append
&num=2to the url – That returns us only 2 results (Only shows 2 results)
For a more complete listing of Google Maps Parameters, consult mapki.com. Kudos to those guys for compiling that list. Really useful stuff
So there you have it, a simple way to link your business such that its the only entry there. However this method is relatively dangerous. Why? Cause you’ve got no idea of the exact ordering that Google maps may return. Today you could be entry 17, surely not in a year (hopefully for the better). As such, this is not the recommended solution. - Append
- Use the address with your long/lat coordinates to generate your entry.
- First get your GPS coordinates, there are a number of ways to do this. Check our this link
- Then create your link via the following structure:
http://www.google.com/maps?&ie=UTF8&hl=en&q=[urlescaped address]&ll=[GPS lat,long]&z=[Zoom]&iwloc=A - Still too troublesome? We’ve created a simple tool for our clients to use. Save yourself some time. Try it!
Done! Whats the downside to this? You can only show the address for the business. Because searching by business names returns us way too many results. So instead, we have to search for an address, Google interprets this as an address and only returns 1 result (which is the whole point of geocoding). At this point its easy to the map to what we need. We’d use this typically for this nifty little “Find us on a map” links (instead of embedding the actual map on your site).
Once again, if you’d rather embed Google maps directly into your site via the JS, then your options are much more open.
Good luck! Let us know if it works for you, of if you find a better way of doing things!

HOWTO: Readymade Form CSS and Highlighting
Author: gaweee | Filed under: development, howtoWe’ve been working on web development for awhile now, i’ve really only seen a handful of pretty forms. The interfaces seen at Uni-Form, mooflex and even to a certain extent linuxjournal are all intuitive and well thought out.
So in the good ol WITS culture, we’ve tried our hand at building our own version of a universal form interface. Alot of features were borrowed off work already done at Uni-Form. We just made it jQueried, lighter and more readable. Like all other jQuery plugins, insert jquery.js, insert the jquery.witsform.js script, insert the css, use the right html code, and you’re done! I’m pretty sure as time goes by i’ll keep improving it. So here’s version 1.0 meanwhile. We bothered so that you shouldnt have to.
download the jQuery WITSForm here: jQuery WITSForm
or view the demo here
HOWTO: PHP and jQuery upload progress bar
Author: gaweee | Filed under: development, howtoWith the controllable jQuery Progress Bar, writing a form upload progress bar seems like a piece of cake now. Hypothetically, all we need is to create the bar, poll for the progress of the file upload, derive the new progress bar value (in percentage) and set it.
To do that you need to prepare the php script to do it. By default PHP cant report the progress of upload progress. However people smarter than me have already solved that problem. In 5 mins i’ve found 2 solutions: the Alternative PHP Cache (APC) method as well as the UploadProgress method. Both of them are PECL packages. Because i couldnt get APC to work on my server properly, i’ll document the UploadProgress more in detail here…
pecl install uploadprogress
Once that is done, register the extension to your PHP with the following line in your php.ini
extension=uploadprogress.so
then restart your apache/httpd
<form id="uploadform" enctype="multipart/form-data" method="post"> <input id="progress_key" name="UPLOAD_IDENTIFIER" type="hidden" value="<?= $uuid ?>" /> <input id="ulfile" name="ulfile" type="file" /> <input type="submit" value="Upload" /> <span id="uploadprogressbar" class="progressbar">0%</span> </form>
this creates the form with a file field as well as a unique UPLOAD_IDENTIFIER hidden field that allows our script to check the progress of the form submission.
header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); if (@$_GET['id']) { echo json_encode(uploadprogress_get_info($_GET['id'])); exit(); }
The header no-cache declarations circumvents IE’s cache of the response. Basically this form does nothing but respond with a json encoded string of the uploadprogress_get_info function. The id argument is the same one we used in the form. Think of it as a form-upload-process-id. A typical response looks like this:
{"time_start":"1214384364","time_last":"1214384366","speed_average":"25889","speed_last":"40952","bytes_uploaded" :"51778","bytes_total":"8125518","files_uploaded":"0","est_sec":"311"}
the response encodes a good deal of data about the form submission. most importantly for us: bytes_uploaded and bytes_total
var progress_key = ''; // this sets up the progress bar $(document).ready(function() { $("#uploadprogressbar").progressBar(); }); // fades in the progress bar and starts polling the upload progress after 1.5seconds function beginUpload() { $("#uploadprogressbar").fadeIn(); setTimeout("showUpload()", 1500); } // uses ajax to poll the uploadprogress.php page with the id // deserializes the json string, and computes the percentage (integer) // update the jQuery progress bar // sets a timer for the next poll in 750ms function showUpload() { $.get("uploadprogress.php?id=" + progress_key, function(data) { if (!data) return; var response; eval ("response = " + data); if (!response) return; var percentage = Math.floor(100 * parseInt(response['bytes_uploaded']) / parseInt(response['bytes_total'])); $("#uploadprogressbar").progressBar(percentage); }); setTimeout("showUpload()", 750); }
viola! read the comments if you dont understand the code. it is _THAT_ straightforward. Of course there can be many improvements such as stopping the script when the upload reaches 100% but thats probably not really needed since the whole page is refreshed. But this approach allows the flexibility of ajax submissions and what nots.
Again, download the jQuery progressbar here: jQuery progressbar
or view the demo here
- Change the HTML hidden form field name from UPLOAD_IDENTIFIER to APC_UPLOAD_PROGRESS
- Change the PHP uploadprogress_get_info($_GET['id']) to apc_fetch(‘upload_’.$_GET['id']));
- Change the Javascript percentage calculation from:
Math.floor(100 * parseInt(response['bytes_uploaded']) / parseInt(response['bytes_total']));
to:
Math.floor(100 * parseInt(response['current']) / parseInt(response['total']));
Most Popular
- HOWTO: PHP and jQuery upload progress bar (48)
- JQuery Progress Bar 1.1 (42)
- Howto: Repackageable custom extension development in Magento - Part 2 - Admin Controller (24)
- Howto: Repackageable custom extension development in Magento - Part 8 - CRUD - Update (16)
- HOWTO: struts 2 i18n (13)
- JQuery Progress Bar 2.0 (12)
- JQuery Progress Bar 1.2 (11)
- Howto: Repackageable custom extension development in Magento (9)
- Howto: Repackageable custom extension development in Magento - Part 3 - Database (9)
- Howto: Repackageable custom extension development in Magento - Part 9 - Frontend - List (8)
Recent Comments
- learning methods: All the posts you talk
- best travel agency: Wow! I really enjoyed this
- Muzafar Ali: Hi, thanks for sharing a beautiful
- andy65007: After the progress bar
- Mark: Excellent tutorials. Most "how to
- Mark: As Jim said before, you
- Jeremy Roberts: I tried and it works
- Silas Nordes: Came to this site by
- 150cc mopeds: That was a superb blog
- Jason: if the situation is like
Latest Entries
- jQuery Progress Bar Configuration
- Extracting email addresses from inbox
- 10 Good (Free and Legal) Source for Photos and Images
- Howto: Backup Microsoft SQL Server Database, as in Dump it to a SQL Script (like MYSQL's sqldump)
- Managing client's expectation with wireframe software
- Howto: Repackageable custom extension development in Magento - Part 9 - Frontend - List
- JQuery Progress Bar 2.0
- HOWTO: Find icons for your new prototype system
- Google Maps Helper
- laying the cornerstones
