Google Maps - Stop pop up for points with no info to show


I'm working on a villa rntal site and want to have pop up windows where a villa has information, but no pop up windows if there is no information.  I'm not good at Javascript, and think that an if/end if should work on the function creating the map click, but am not sure how to do this.  Properties with info will have a green icon (type=green;) and properties without info would have a different icon, so I'm hoping it would be possible to only call the pop-up function if the type= green.

Here's my code:

<script language="javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript">

      var customIcons = {
            green: {
                  icon: '',
                  shadow: ''

      var xmlsource = '<%=xmlss%>';
      $(document).ready(function() {
            var latlng = new google.maps.LatLng(<%=lat%>, <%=lng%>);
            var myOptions = {
                  zoom: <%=zoom%>,
                  center: latlng,
                  mapTypeId: google.maps.MapTypeId.HYBRID
            var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
//        var marker2 = new GMarker(center, {draggable: true});  
//        map.addOverlay(marker2);
//            var marker = new google.maps.Marker({ map: map, position: latlng, icon: icon.icon, shadow: icon.shadow });
//            google.maps.event.addListener(marker);
            var infoWindow = new google.maps.InfoWindow;
            $( $.parseXML( xmlsource ) ).find("marker").each(function() {
//            $(xmlsource).find("marker").each(function() {
                  var name = $(this).attr("name");
                  var town = $(this).attr("town");
                  var typer = $(this).attr("typer");
                  var beds = $(this).attr("beds");
                  var thumb = $(this).attr("thumb");
                  var distance = $(this).attr("distance");
                  var type = $(this).attr("type");                  
//                  var type = "green";
                  var lat = parseFloat($(this).attr("lat"));
                  var lng = parseFloat($(this).attr("lng"));
                  var point = new google.maps.LatLng(lat, lng);
                  var html = '<div id="content">';
//                  html += '<div id="siteNotice">' + '</div>';
                  html += '<h3 id="firstHeading" class="firstHeading">' + name + '</h3>'
                  html += '<div id="bodyContent">'
                  html += '<img src="' + thumb + '" height="120" width="160"/><br />' + town + '&nbsp;Bedrooms:' + beds
                  html += '&nbsp;Distance:' + distance
                  html += '</div>';
                  html += '</div>';
                  var icon = customIcons[type] || {};
                  var marker = new google.maps.Marker({ map: map, position: point, icon: icon.icon, shadow: icon.shadow });
                  bindInfoWindow(marker, map, infoWindow, html);
      function bindInfoWindow(marker, map, infoWindow, html) {
            google.maps.event.addListener(marker, 'click', function() { infoWindow.setContent(html);, marker); });


Thanks in advance for your help!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tom BeckCommented:
I'm assuming you intend to have at least one more color:

     var customIcons = {
            green: {
                  icon: '',
                  shadow: ''
            red: {
                  icon: '',
                  shadow: ''

If so, then you could do this:
              /*the rest of your code*/ 

                        var icon = customIcons[type];
                        var marker = new google.maps.Marker({ 
                            map: map, 
                            position: point, 
                            icon: icon.icon, 
                            shadow: icon.shadow 
                        if(type == 'green'){
                            bindInfoWindow(marker, map, infoWindow, html);

                        /*the rest of your code*/

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nico2011Author Commented:
Thanks but for some reason (*I* am probably the reason), it's not working... you can see the page here:

Thnks and hope to hear from you soon!
Tom BeckCommented:
The link you provided does not reflect the changes I suggested. Maybe you forgot to upload the latest version?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Nico2011Author Commented:
Right - I think I need a holiday - I wrote the code in the wrong page - really sorry - I did say the issue was probably me, but didn't imagin doing anything quite so embarassingly dumb!

Thank you - it works perfectly!
Nico2011Author Commented:
Perfect solution - thank you!
Tom BeckCommented:
You're welcome and don't beat yourself up over that. It's easy to confuse the development environment with the live web server. Thanks for the points.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.