Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have made a custom search for houses.

The problem is that I have to show in the search results page, a "googlemaps" with the points at which there is a house, according to the search results obtained.

How can I do it?

Thanks.

share|improve this question
add comment

1 Answer 1

@Richard, it's hard to answer this in detail with this little details. Do you need to pinpoint a single house? Will you use an address or will you use latitude and longitude?

My suggestion would be to take a look at this excellent Google Maps Plugin for jQuery. jQuery is part of any WordPress installation, so you wouldn't need to install anything else. Additionally this is quite easy to load.

Below a quick example of how I've implemented this, using custom fields to store both a latitude and a longitude. But you could just as well get an address returned as a search result and add that:

    <!--Map implementation-->
<?php
//Quick conditional to make sure I don't show maps on items where no two coordinates are available  
        if (($wtr_latitude) && ($wtr_longitude)) { ?>
<div id="map" style="width:680px; height: 203px; background-color:grey;"></div>   
<script type="text/JavaScript">                                                     
      $("#map").gMap({
          controls: false,
                  scrollwheel: false,
                      controls:               ["GSmallZoomControl3D", "GScaleControl"],
                      maptype: G_PHYSICAL_MAP,
                  markers: [{ latitude: "<?php echo $latitude; ?>",
                              longitude: "<?php echo $longitude; ?>",
                              popup: false }],
                          zoom: 10 });              
   </script>
 <?php } ?>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.