In the case of your "wrong" example, the PHP
if (get_post_meta(... != ""))
returns false.
That could either be because there is no post corresponding to your
$post->ID, or because there is such a post but its "city_value",
"state_value" and "zip_value" fields are empty. I can't tell from here
because all that happens inside your server.
The PHP code doesn't handle the condition where that "if" returns false,
and the GSmapSearchControl() is still performed, even though the PHP
code has determined that there's nothing to search for.
The whole thing could be rewritten with the logic switched round. I
don't do PHP, so I don't know the syntax, but what you might want to
achieve is something like
<?php if(get_post_meta($post->ID, "city_value","state_value",
"zip_value", $single = true) !="") : ?>
new GSmapSearchControl(
document.getElementById("mapsearch"),
", <?php echo get_post_meta($post->ID, "city_value",
$single = true); ?>, <?php echo get_post_meta($post->ID, "state_value",
$single = true); ?>, <?php echo get_post_meta($post->ID, "zip_value",
$single = true); ?>",
options
);
<?php else ?>
alert("No location to search for: ID= $post->ID");
<?php endif ?>
}
GSearch.setOnLoadCallback(LoadMapSearchControl);
So that the search only gets performed if there is something to search
for, and you get some sort of notification if there is nothing.
--
Mike Williams
http://econym.org.uk/gmap
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---