<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: How to Code a Simple Zip Code Locator in PHP</title>
	<atom:link href="http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/</link>
	<description>Web Development from the Front Lines</description>
	<pubDate>Wed, 20 Aug 2008 18:15:42 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: James Ehly</title>
		<link>http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/#comment-53708</link>
		<dc:creator>James Ehly</dc:creator>
		<pubDate>Thu, 01 May 2008 14:44:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/#comment-53708</guid>
		<description>A few people have asked me this, so here is the looping code you'll need.

Find this line and add some code like this...

&lt;code&gt;// now we can display closest store
// optionally you could loop over this to list multiple stores
$store = $storeinfo[key($stores)];
print &#34;&#60;p&#62;The web developers closest to: $findzip&#60;/p&#62;&#60;br&#62;\n&#34;;
$maploc = &#34;'You are here','$findzip',&#34;;
foreach($stores as $k=&#62;$v) {
  $output .= &#34;&#60;h3 style='margin:0;padding:0'&#62;&#60;b&#62;&#34;.$info[$k]['company'].&#34;&#60;/b&#62;&#60;br&#62;(approx &#34;.round($v).&#34; miles)&#60;/h3&#62;&#34;;
  $output .= &#34;&#60;p style='margin:0 0 10px 0;padding:0'&#62;&#60;a href='&#34;.$info[$k]['url'].&#34;'&#62;&#34;.$info[$k]['url'].&#34;&#60;/a&#62;&#60;br&#62;&#34;;
  $output .= $info[$k]['city'].&#34; &#34;.$info[$k]['state'].&#34;, &#34;.$info[$k]['zip'].&#34;&#60;/p&#62;&#34;;
  $maploc .= &#34;'&#34;.$info[$k]['company'].&#34;','&#34;.$info[$k]['address1'].&#34; &#34;.$info[$k]['city'].&#34; &#34;.$info[$k]['state'].&#34; &#34;.$info[$k]['zip'].&#34;',&#34;;
}
$maploc = substr($maploc,0,-1);&lt;/code&gt;

And here are the changes to the javascript:

&lt;code&gt;&#60;script&#62;
// this is the address we want to map (you can list several and it will mark each one)
var addresses = new Array(&#60;?=$maploc?&#62;);
// Create and display Map object at the address with zoom level 3
// Include your application ID.
var map = new Map(&#34;mapContainer&#34;, &#34;[your api key here]&#34;, &#34;&#60;?=$maploc?&#62;&#34;,20);
map.addEventListener(Map.EVENT_INITIALIZE, onMapInit);
map.addEventListener(Map.EVENT_MARKER_GEOCODE_SUCCESS,onMarkerGeocode);
function onMapInit(eventObj) {
map.addTool( new PanTool(), true );
for(var i=0; i&#60;addresses.length; i=i+2) {
//alert(addresses[i]);
//alert(addresses[i+1]);
// if you did do multiple addresses, then this would have to change some (because it would be the same store each iteration)
var marker = new CustomPOIMarker(addresses[i], '', addresses[i+1], '0x000000', '0xFFFFFF');
map.addMarkerByAddress( marker, addresses[i+1] );
}
map.addWidget( new ZoomBarWidget() );
}
function onMarkerGeocode(eventObj) {
var geocodeResponse = eventObj.response;
}
&#60;/script&#62;&lt;/code&gt;

Basically what you are doing is building an array of results and looping over then with the javascript.

Hope this helps.  James</description>
		<content:encoded><![CDATA[<p>A few people have asked me this, so here is the looping code you&#8217;ll need.</p>
<p>Find this line and add some code like this&#8230;</p>
<p><code>// now we can display closest store<br />
// optionally you could loop over this to list multiple stores<br />
$store = $storeinfo[key($stores)];<br />
print &quot;&lt;p&gt;The web developers closest to: $findzip&lt;/p&gt;&lt;br&gt;\n&quot;;<br />
$maploc = &quot;&#8217;You are here&#8217;,'$findzip&#8217;,&quot;;<br />
foreach($stores as $k=&gt;$v) {<br />
  $output .= &quot;&lt;h3 style=&#8217;margin:0;padding:0&#8242;&gt;&lt;b&gt;&quot;.$info[$k]['company'].&quot;&lt;/b&gt;&lt;br&gt;(approx &quot;.round($v).&quot; miles)&lt;/h3&gt;&quot;;<br />
  $output .= &quot;&lt;p style=&#8217;margin:0 0 10px 0;padding:0&#8242;&gt;&lt;a href=&#8217;&quot;.$info[$k]['url'].&quot;&#8217;&gt;&quot;.$info[$k]['url'].&quot;&lt;/a&gt;&lt;br&gt;&quot;;<br />
  $output .= $info[$k]['city'].&quot; &quot;.$info[$k]['state'].&quot;, &quot;.$info[$k]['zip'].&quot;&lt;/p&gt;&quot;;<br />
  $maploc .= &quot;&#8217;&quot;.$info[$k]['company'].&quot;&#8217;,'&quot;.$info[$k]['address1'].&quot; &quot;.$info[$k]['city'].&quot; &quot;.$info[$k]['state'].&quot; &quot;.$info[$k]['zip'].&quot;&#8217;,&quot;;<br />
}<br />
$maploc = substr($maploc,0,-1);</code></p>
<p>And here are the changes to the javascript:</p>
<p><code>&lt;script&gt;<br />
// this is the address we want to map (you can list several and it will mark each one)<br />
var addresses = new Array(&lt;?=$maploc?&gt;);<br />
// Create and display Map object at the address with zoom level 3<br />
// Include your application ID.<br />
var map = new Map(&quot;mapContainer&quot;, &quot;[your api key here]&quot;, &quot;&lt;?=$maploc?&gt;&quot;,20);<br />
map.addEventListener(Map.EVENT_INITIALIZE, onMapInit);<br />
map.addEventListener(Map.EVENT_MARKER_GEOCODE_SUCCESS,onMarkerGeocode);<br />
function onMapInit(eventObj) {<br />
map.addTool( new PanTool(), true );<br />
for(var i=0; i&lt;addresses.length; i=i+2) {<br />
//alert(addresses[i]);<br />
//alert(addresses[i+1]);<br />
// if you did do multiple addresses, then this would have to change some (because it would be the same store each iteration)<br />
var marker = new CustomPOIMarker(addresses[i], &#8221;, addresses[i+1], &#8216;0&#215;000000&#8242;, &#8216;0xFFFFFF&#8217;);<br />
map.addMarkerByAddress( marker, addresses[i+1] );<br />
}<br />
map.addWidget( new ZoomBarWidget() );<br />
}<br />
function onMarkerGeocode(eventObj) {<br />
var geocodeResponse = eventObj.response;<br />
}<br />
&lt;/script&gt;</code></p>
<p>Basically what you are doing is building an array of results and looping over then with the javascript.</p>
<p>Hope this helps.  James</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: josh</title>
		<link>http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/#comment-53707</link>
		<dc:creator>josh</dc:creator>
		<pubDate>Thu, 01 May 2008 14:17:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/#comment-53707</guid>
		<description>What do i have to do to show more stores?</description>
		<content:encoded><![CDATA[<p>What do i have to do to show more stores?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Internet Television</title>
		<link>http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/#comment-30115</link>
		<dc:creator>Internet Television</dc:creator>
		<pubDate>Thu, 24 Jan 2008 22:16:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/#comment-30115</guid>
		<description>That's absolutely beautiful, great work.</description>
		<content:encoded><![CDATA[<p>That&#8217;s absolutely beautiful, great work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: October 2007 Recap and Traffic Report &#124; DEVTRENCH: Web Development from the Front Lines</title>
		<link>http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/#comment-11360</link>
		<dc:creator>October 2007 Recap and Traffic Report &#124; DEVTRENCH: Web Development from the Front Lines</dc:creator>
		<pubDate>Fri, 02 Nov 2007 13:57:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/#comment-11360</guid>
		<description>[...] spam and web stats: Usi...How to Code a Simple Zip Code Loc...WPA Can also be Cracked!!...Out sick: Preparing for a regular...Getting Technorati Authority [...]</description>
		<content:encoded><![CDATA[<p>[...] spam and web stats: Usi&#8230;How to Code a Simple Zip Code Loc&#8230;WPA Can also be Cracked!!&#8230;Out sick: Preparing for a regular&#8230;Getting Technorati Authority [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Ehly</title>
		<link>http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/#comment-9652</link>
		<dc:creator>James Ehly</dc:creator>
		<pubDate>Mon, 22 Oct 2007 15:42:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.devtrench.com/how-to-code-a-simple-zip-code-locator-in-php/#comment-9652</guid>
		<description>Well I just figured out a logical error in the script. If you find by state first then that might not actually be the closest location to you (since there might be a closer location in the state next to you).  Just comment out the lines about querying the state first and you should be fine.  However, I assume doing this will slow the code down quite a bit if you have a ton of locations to search against.  Maybe caching the queries somehow would be in order.

James</description>
		<content:encoded><![CDATA[<p>Well I just figured out a logical error in the script. If you find by state first then that might not actually be the closest location to you (since there might be a closer location in the state next to you).  Just comment out the lines about querying the state first and you should be fine.  However, I assume doing this will slow the code down quite a bit if you have a ton of locations to search against.  Maybe caching the queries somehow would be in order.</p>
<p>James</p>
]]></content:encoded>
	</item>
</channel>
</rss>
