No results, No element found Creating a Store Locator with PHP, MySQL & Google Maps

195 views
Skip to first unread message

mes421

unread,
Nov 14, 2011, 11:38:23 AM11/14/11
to google-map...@googlegroups.com
Hello!  Reporting 3 days of struggle w/the Store Locator tutorial, "Creating a Store Locator with PHP, MySQL & Google Maps". 
 
I am working locally with WAMP installed on my Window7 laptop. Apache 2.2.17, PHP 5.3.4, MySQL 5.1.53 installed. Executing from the www, root folder.
 
I have tested connecting to MySQL to verify the db exists. 
 
Have used the provided .php and .htm code exactly as shown here, http://code.google.com/apis/maps/articles/phpsqlsearch.html
 
Uploaded my own addresses and lat, lng information.  Verified with the
phpsqlsearch_genxml.php script that I can indeed use the search script.  Meaning, I supply lat, lng, radius input parameters and get back valid XML of markers within the search radius.
 
I have run with both v2 and v3.  Both produce the same output, No results in the query window,and no element found in my firebug error message.  With firebug I can also clearly see that the google geocoder has processed the input address and returned criteria for the search.
 
Really at a loss here and hope no else wastes as much time as I did.  I found several references online that suggested commenting out the last line in phpsqlsearch_genxml.php, which is echo $dom->saveXML();.  That did not help either.
 
Any suggestions are welcome.
 
Thanks, MES
 

geoco...@gmail.com

unread,
Nov 14, 2011, 3:32:45 PM11/14/11
to Google Maps JavaScript API v3
On Nov 14, 8:38 am, mes421 <marthasnyderw...@gmail.com> wrote:
> Hello!  Reporting 3 days of struggle w/the Store Locator tutorial, "Creating
> a Store Locator with PHP, MySQL & Google Maps".
>
> I am working locally with WAMP installed on my Window7 laptop. Apache
> 2.2.17, PHP 5.3.4, MySQL 5.1.53 installed. Executing from the www, root
> folder.

We can't help much then...

>
> I have tested connecting to MySQL to verify the db exists.
>
> Have used the provided .php and .htm code exactly as shown here,http://code.google.com/apis/maps/articles/phpsqlsearch.html.
>
> Uploaded my own addresses and lat, lng information.  Verified with the
> *phpsqlsearch_genxml.php*<http://gmaps-samples.googlecode.com/svn/trunk/articles-phpsqlsearch/p...> script
> that I can indeed use the search script.  Meaning, I supply lat, lng,
> radius input parameters and get back valid XML of markers within the search
> radius.
>
> I have run with both v2 and v3.  Both produce the same output, No results
> in the query window,and no element found in my firebug error message.  With
> firebug I can also clearly see that the google geocoder has processed the
> input address and returned criteria for the search.
>
> Really at a loss here and hope no else wastes as much time as I did.  I
> found several references online that suggested commenting out the last line
> in *phpsqlsearch_genxml.php*<http://gmaps-samples.googlecode.com/svn/trunk/articles-phpsqlsearch/p...>,
> which is echo $dom->saveXML();.  That did not help either.
>
> Any suggestions are welcome.

1. Look at the output of phpsqlsearch (with reasonable parameters and/
or the ones your map is providing) in a browser.
2. If you see xml in #1 above, save it to your machine as an xml file
and see if accessing the xml _file_ rather than the php produced
output works differently.
3. Make your test environment available (at least your xml output) to
the outside world so we can investigate.

-- Larry

>
> Thanks, MES

mes421

unread,
Nov 14, 2011, 9:59:11 PM11/14/11
to google-map...@googlegroups.com
Hey!  Thanks for the suggestions.  Since I've posted my comments I noticed that there are 2 very similar links to this tutorial.   I've tried the final store locator code on both, 
 
 
 
Regardless, I'm still dead in the water. I think the problem is with the .php file called by the .html page.  Somehow the markers are not being returned.
 
I'd like to hear from anyone that it really works.  The first day I worked on this I kept getting xml errors and had issues with quotes (") vs. single quotes ('). 
 
Thanks again, MES 

Ralph

unread,
Nov 14, 2011, 10:26:52 PM11/14/11
to google-map...@googlegroups.com
Where is the link to your map?

Ralph

> --
> You received this message because you are subscribed to the Google
> Groups "Google Maps JavaScript API v3" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-maps-js-api-v3/-/HfF1kCdXuwcJ.
> To post to this group, send email to
> google-map...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-maps-js-a...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.

geoco...@gmail.com

unread,
Nov 14, 2011, 10:33:43 PM11/14/11
to Google Maps JavaScript API v3
On Nov 14, 6:59 pm, mes421 <marthasnyderw...@gmail.com> wrote:
> Hey!  Thanks for the suggestions.  Since I've posted my comments I noticed
> that there are 2 very similar links to this tutorial.   I've tried the
> final store locator code on both,
>
> a)http://code.google.com/apis/maps/articles/phpsqlsearch_v3.html,
>
> b)http://code.google.com/apis/maps/articles/phpsqlsearch.html.
>
> Regardless, I'm still dead in the water. I think the problem is with the
> .php file called by the .html page.  Somehow the markers are not
> being returned.
>
> I'd like to hear from anyone that it really works.  The first day I worked
> on this I kept getting xml errors and had issues with quotes (") vs. single
> quotes (').
>
> Thanks again, MES


This example:
http://www.rentalmatch101.com.php5-20.dfw1-1.websitetestlink.com/googlemap.php

From this search of the group:
http://groups.google.com/group/google-maps-js-api-v3/search?q=store+locator&start=0&scoring=d&

Works. I searched for Aurora, CO; distance 50 mi, 2 bedrooms, 2
baths, min price 0, max price 2000+.

I have seen lots of examples go by in the group that eventually
worked.

-- Larry

davie strachan

unread,
Nov 15, 2011, 5:30:55 AM11/15/11
to Google Maps JavaScript API v3
Hi

see http://daviestrachan.zxq.net/maps/stationmap5.php

The php file in this example uses has been modified to display the map
if no data is found in the database

This is the modified code that always returns XML located at the
location found by the geocoder indicating no record found

$result = mysql_query($query);
if (!$result) {
die("Invalid query: " . mysql_error());
}

header("Content-type: text/xml");
if (mysql_num_rows($result)==0)
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("name", "No Records Found");
$newnode->setAttribute("address","Centered on
Location);
$newnode->setAttribute("lat", $center_lat);
$newnode->setAttribute("lng", $center_lng);
$newnode->setAttribute("distance", 0);

else {
// Iterate through the rows, adding XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("name", $row['name']);
$newnode->setAttribute("address", $row['address']);
$newnode->setAttribute("lat", $row['lat']);
$newnode->setAttribute("lng", $row['lng']);
$newnode->setAttribute("distance", $row['distance']);
}

}
It used a database of UK railway stations
Try paris 25mls No record found centered on geolocation
Try paris 200 mls This picks up UK stations within 200 miles of
paris

This technique will always produce a map unless there is a problem
with your database.
Try using phpMyAdmin with the following query
SELECT name, lat, lng, ( 3959 * acos( cos( radians('55') ) *
cos( radians( lat ) ) * cos( radians( lng ) - radians('-4') ) +
sin( radians('55') ) * sin( radians( lat ) ) ) ) AS distance FROM
gbstn HAVING distance < '200' ORDER BY distance LIMIT 0 , 20

CHANGE 55(2 places) and -4 to your own lat lng AND gbstn to your own
table name

Regards Davie




On Nov 15, 3:33 am, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:
> On Nov 14, 6:59 pm, mes421 <marthasnyderw...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> > Hey!  Thanks for the suggestions.  Since I've posted my comments I noticed
> > that there are 2 very similar links to this tutorial.   I've tried the
> > final store locator code on both,
>
> > a)http://code.google.com/apis/maps/articles/phpsqlsearch_v3.html,
>
> > b)http://code.google.com/apis/maps/articles/phpsqlsearch.html.
>
> > Regardless, I'm still dead in the water. I think the problem is with the
> > .php file called by the .html page.  Somehow the markers are not
> > being returned.
>
> > I'd like to hear from anyone that it really works.  The first day I worked
> > on this I kept getting xml errors and had issues with quotes (") vs. single
> > quotes (').
>
> > Thanks again, MES
>
> This example:http://www.rentalmatch101.com.php5-20.dfw1-1.websitetestlink.com/goog...
>
> From this search of the group:http://groups.google.com/group/google-maps-js-api-v3/search?q=store+l...

mes421

unread,
Nov 15, 2011, 9:39:18 PM11/15/11
to google-map...@googlegroups.com
Hey!  Thanks for the feedback. If I save the file as .php vs. .htm it works!!!! 
 
Any ideas why?
 
Again, many thanks.
 
MES

geoco...@gmail.com

unread,
Nov 15, 2011, 11:25:07 PM11/15/11
to Google Maps JavaScript API v3
On Nov 15, 6:39 pm, mes421 <marthasnyderw...@gmail.com> wrote:
> Hey!  Thanks for the feedback. If I save the file as .php vs. .htm it
> works!!!!

.htm or .xml?

The headers generated by PHP are probably incorrect.

-- Larry
Reply all
Reply to author
Forward
0 new messages