Search results to map markers

Permalink
I have a property search site. When someone searches by city or zipcode, an array of results is returned. The normal list results are fine. However, there is Map results option. I am able to get the lat/long to return but need that to create markers on a Google map. Has anyone done this before? I tried to use the Pagelist Google Map plugin but that didn't suit the searching needs. Below is what I'm using to return the lat/long.
$allProperties = $pageList->get(9999);
if(count($allProperties) > 0){
    foreach($allProperties as $page){ 
        echo $th->entities($page->getAttribute('long'));
        echo $th->entities($page->getAttribute('lat'));   
    } 
}


I hope someone can help!

 
hutman replied on at Permalink Reply
hutman
Adding this should work - make sure to put your API Key in where it says YOUR_API_KEY

<?php
$json = Loader::helper('json');
$propertyArray = array();
$allProperties = $pageList->get(9999);
if(count($allProperties) > 0){
    foreach($allProperties as $page){ 
        $propertyID = $page->getCollectionID();
        $title = $th->entities($page->getCollectionName());
        $lat = $page->getAttribute('lat');
        $lng = $page->getAttribute('long');
        $propertyArray[] = array('id' => $propertyID, 'title' => $title, 'lat' => $lat, 'lng' => $lng);
    } 
}
?>
<div id="locationsMap" style="width: 100%; height: 400px;"></div>
GrizzlyAdams replied on at Permalink Reply
Thanks for the reply Hutman. I am getting this error now...

"You have included Google Maps API multiple times on this page. This may cause unexpected errors."

Looking at the source code I don't see it more than once. am i missing something?
hutman replied on at Permalink Reply
hutman
Can you provide a link to the page? I have no way to know this without seeing the rest of the page content.
hutman replied on at Permalink Reply
hutman
And actually the code I pasted has it twice, remove the first one.
GrizzlyAdams replied on at Permalink Reply
Tried removing the first one but no luck. I think you might have been involved in this site. There is a package called Hutman that is part of this, unless it was something they purchased from the community. Here's the linkhttp://aptlivingguide.com/index.php/property-search-results/map...
hutman replied on at Permalink Reply
hutman
Looking at that page I can see that this line of code is still there, it has not been removed

<script type="text/javascript" src="https://maps-api-ssl.google.com/maps/api/js?v=3&sensor=false"></script>
GrizzlyAdams replied on at Permalink Reply
I put it back because it didn't fix the issue. I took it out now again.
hutman replied on at Permalink Reply
hutman
Try moving the Google Maps API line below the other javascript, it looks like the callback is failing because it's not finding the initialize function.
GrizzlyAdams replied on at Permalink Reply
Tried that, and moving it to the header element, and the footer element. Same issues regardless. Frustrating, seems like it should be working.
hutman replied on at Permalink Reply
hutman
There is a missing comma after title: item.title
GrizzlyAdams replied on at Permalink Reply
YAY! It's loading the markers now. Just need to get it to zoom to the group and link to the property URL. Any guidance there? You are so much help, THANK YOU!
hutman replied on at Permalink Reply
hutman
Not really, you can try following what is done here -https://stackoverflow.com/questions/15719951/google-maps-api-v3-auto...