Google Maps
10 posts by 2 authors in: Forums > CMS Builder
Last Post: July 23, 2008 (RSS)
By edandrea - July 17, 2008 - edited: July 18, 2008
Working with Google Maps. I have worked the .xml to output to my featured listings page and shows all properties on a map very well. For the detail page I have a map but allways shows the first record on the map only. How can I get it to show specific data for specific file?
Here is my .xml code:
<?php header('Content-type: application/xml; charset=utf-8'); ?><?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
<?php
require_once "/home/content/s/m/o/smoaklandco/html/cmsAdmin/lib/viewer_functions.php";
list($customRecords, $customDetails) = getRecords(array(
'tableName' => 'custom',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$customRecord = $customRecords[0]; // get first record
?>
<markers>
<?php foreach ($customRecords as $customRecord): ?>
<marker lat="<?php echo $customRecord['lat'] ?>" lng="<?php echo $customRecord['long'] ?>" />
<?php endforeach; ?>
</markers>
.xml files:
www.smoaklandco.com/location_detail.xml.php?4
www.smoaklandco.com/location_detail.xml.php?5
www.smoaklandco.com/location_detail.xml.php?6
I have tried adjusting the code on the .xml, can get it to show 1 marker on a map but only the first record.
http://smoaklandco.com/ds_detail.php?4
I tried deleting the 'where' and 'limit' and also $customRecord = $customRecords[0]; // get first record but only show first record.
Hope you can help???
Re: [edandrea] Google Maps
By Dave - July 18, 2008
If you want it to show all listings you need to remove: where, limit, and $customRecord = ....
If you want it to only show featured listings you'd re-add something like this:
'where' => "featured = "1"',
Also, if you always want it to show all the featured listings and not just a specific listing you don't need the number (?1) after the xml url.
Do you still only get 1 result after you do that?
Let me know what happens after you remove those 3 things.
interactivetools.com
Re: [Dave] Google Maps
By edandrea - July 21, 2008
1. I have allready created a map showing all featured listings and shows great, www.smoaklandco.com/ds_featured.php.
2. When a user clicks on a featured listing only one marker shows.
3. I had allready attempted to remove the where, limit and custom but all markers show. When I added the 'where' =>"feature="(1)"' it didnt work and I also tried 'featured="(1)"' along with 'num = "(1)"'.
4. The way, I think you have it but I could be wrong, seems like it is only manually generating a specific data, is the way you have it coming up dynamically because that is what I think I need.
5. my .xml.php files display the correct single marker if I type in the specific url www.smoaklandco.com/location_detail.xml.php?4 or 5 or 6.....
I appologize for any confusion, but I sure appreciate any help you offer
Regards Emil
Re: [edandrea] Google Maps
By Dave - July 21, 2008
You need to add the record number to the url that google maps downloads. Can you add it to this line:
GDownloadUrl("location_detail.xml.php", function(data, responseCode) {
Maybe something like this (your $variable name might be different):
GDownloadUrl("location_detail.xml.php?<?php echo $record['num'] ?>", function(data, responseCode) {
Let me know if that helps!
interactivetools.com
Re: [Dave] Google Maps
By edandrea - July 21, 2008
That did the trick. I have a problem with my record numbers not refreshing on the featured listings page. If one record is deleted it allways starts with the next number. So if record # 3 is deleted it starts at #4. Is there a way to have it show #1?
Re: [edandrea] Google Maps
By Dave - July 22, 2008 - edited: July 22, 2008
'where' => "num = '1'",
interactivetools.com
Re: [Dave] Google Maps
By edandrea - July 22, 2008
You see, I had started off with 3 listings as a test ( #1, 2, 3). Now my client added listing number 4,5,6... and so on, so I deleted the origional listings (1,2,3). But the listings now start at # 4 not begin at #1 record number.
Re: [edandrea] Google Maps
By Dave - July 22, 2008
What are you trying to do or how do you want it to work?
interactivetools.com
Re: [Dave] Google Maps
By edandrea - July 22, 2008
I have used the record number provided by the system to number each listing. I was thinking that the record numbers would be refreshed some how. If you take a look at the link you would understand.
If you delete the first listing (record 'num" 1), the next listing wil be record "num" 2 which I have displayed on each listing. The number 2 does not change to number 1 after number 1 is deleted, which makes perfect sence to me, the more I think about it I think it cant be done without messing with MYSQL.
What do you think?
Thanks for the reply
Emil
Re: [edandrea] Google Maps
By Dave - July 23, 2008
<?php echo @++$counter ?>
like this:
<marker lat="33.038995" lng="-80.555819" num="<?php echo @++$counter ?>" />
Hope that helps!
interactivetools.com