Archive

Posts Tagged ‘Google Maps’

Metrostop gets an Upgrade!

July 2nd, 2006

I spent a few hours this morning upgrading metrostop to the new Version 2 of the google maps api. It’s really nice improvement to the old api.

Software ,

Updated Metrostop.org

March 18th, 2006

It took much longer then I had expected, between work actually picking up, running into a few unexpected hickups with IE and learning Rails, I finally have a much improved metrostop.org.
This was almost a complete rewrite from my previous PHP.

The list of improvements include:

* Scalable Map – resizes with the browser width/height
* Back Button Support – after searching clicking the back button will return to the previous state
* Caching – I use a lot more caching now so performance should be much better

Updates: (things I forgot to mention)
* Entrance Level data
* Search Certainty raiting stars
* Nearly Validating markup all but the MS specific namespace validate

Software , , ,

Hacking Google Maps Geocoding

October 26th, 2005

Tonight I was experimenting with google maps and geocoding. It turns out it’s not too difficult to extract geocoordinates from google maps. Basically, the key is to add the extra query parameter ouput=js

Once you do that google outputs the response as javascript with a nice xml document embedded within. Using a few regular expressions to extract the xml and we have some very sophisticated results from our friends google.

The following is a very simple example, in php that searches for a location near DC. What someone might want to do with this little trickier and googles nice javascript api is beyond me ;-)

header('Content-Type: text/xml');

$address = strip_tags($_GET["address"]);
$query = 'http://maps.google.com/maps?q=' .
urlencode( $address ) .
'&sll=38.880660,-77.114642&sspn=0.023753,0.039439&hl=en' . // near DC
'&output=js';

$gm = fopen( $query, 'r' );
if( !$gm ){
return;
}
$buffer = "";
while( !feof( $gm ) ){
$buffer .= fgets($gm, 4096);
}
fclose($gm);

// correct end tags
// "/\\\//\//g"
$buffer = preg_replace( "/<\/\\//", "";
$locs = $doc->getElementsByTagName( "locations" );
echo $doc->saveXML($locs->item(0)) . "\n";

Update

This no longer works.  Google started returning JSON.  Also, google now has GeoCoding built in to their API.

Software , , ,

Metro Stop

October 15th, 2005

Alright I got a real domain for my metro maps project and even can say it supports all the major browsers now, including IE.

The main problem I was having in IE was caused by my lack of understanding how VML works in the browser. Reading the maps FAQ really helped clear things up.

The fun stuff is in showing metro alerts in the upper right hand corner. I setup my server to check the metro RSS feed once every hour. The php for this is really straight forward RSS using PHP DOM calls.

source: metro3.tar.gz

I hope to get back to XUL coding soon, but for the time being it looks like my work is going to force me into writing cross browser code.

Software , , , ,

Updated Maps

October 8th, 2005

Made a few improvements to the metro maps.

1. Works in Opera and Safari, still no IE.
2. Added a Search for locating the nearests Metro stop, given an address.

How it works:

To go from address to longitude/latitude, I used maps.google.com.

$query = 'http://maps.google.com/maps?q=' . $q .
              '&output=js';
$gm = fopen( $query, 'r' );
if( !$gm )
  return false;
$tmp = @fread($gm,30000);
fclose($gm);
$x = preg_replace ('/.* = 2 ){
  $lat = $ret[0];
  $long = $ret[1];
}

I learned about this technique while reading about geocoding here.

The algorithm for computing distances between longitude and latitude came from this link.

The rest of how it works is pretty straight forward – loop over all points, popup the mark at the end.

Update: Did I meantion – I’m in Barcelona!

Software , , , ,

Metroized Google Maps

September 29th, 2005

D.C. Metro maps with Google Maps API for that extra touch of spice! ;-)

To build this map I first scrapped wmata using the scrap.php file to build a first pass of the stations.xml file. About 12 stations addresses did not resolve to valid addresses when back referencing maps.google.com. I had to manually figure out the lng lat for each of those.

The next thing that I had to do manually was enter each of the linked tags into the stations.xml file. This was really the only sucky part, but vi and split screen made it pass quickly.

I noticed the ajax part is busted in IE/Opera/Safari. Maybe I’ll fix that, but I suspect the DOM walking would be busted in IE anyway so I’m not sure I’ll bother, of course it would be nice if it worked everywhere ;-)

Code: http://xullicious.com/metro.tar.gz

Software , , , ,