I have over 200 customposts and each has customfields (add_city, add_state, add_location) in each custompost is googlmap with customfield (geo_longitude geo_latitude) Help please, display in googlmap multiple markers, depending on more meta_key meta_value.
To sort kustomposts I use this beautiful code :
<?php $args = array(
'meta_query'=> array(
array(
'key' => 'add_state',
'value'=> 'ill'
),
array(
'key' => 'add_city',
'value' => 'chicago'
))); $posts = query_posts($args); ?>
On the details page, I use this code for googlmap:
<?php
$add_arr = array();
if(get_post_meta($post->ID,'address',true))
{
$add_arr[] = get_post_meta($post->ID,'address',true);
}
if(get_post_meta($post->ID,'add_city',true))
{
$add_arr[] = get_post_meta($post->ID,'add_city',true);
}
if(get_post_meta($post->ID,'add_state',true))
{
$add_arr[] = get_post_meta($post->ID,'add_state',true);
}
$add_str = '';
if($add_arr)
{
$add_str = implode(',',$add_arr);
}
if($add_str)
{
$geo_longitude = get_post_meta($post->ID,'geo_longitude',true);
$geo_latitude = get_post_meta($post->ID,'geo_latitude',true);
?>
<div class="propertymap">
<?php if($geo_longitude && $geo_latitude){
require_once (TEMPLATEPATH . '/library/map/preview_map.php');
preview_address_google_map($geo_latitude,$geo_longitude,$add_str);
}else{?>
<iframe src="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=<?php echo $add_str;?>&ie=UTF8&z=14&iwloc=A&output=embed" height="358" width="239" scrolling="no" frameborder="0" ></iframe>
<?php }?></div>
Then I created a page and a lot of time trying to string any of these codes.
He received only a white screen.
Please help me solve this puzzle !!!
The only way to get multiple markers on a map is to use the Google Maps API.
https://developers.google.com/maps/documentation/javascript/tutorial.
The way you are referencing through an iframe only allows one marker(one location).
Well there are other ways how to get multiple markers on the map that do not involve any programming.. You can use http://www.copypastemap.com or google fussion tables. Sorry, can’t help you if you insist on programming solution.
I found this awesome solution multiple locations, php, mysql, custom marker, fullscreen option, NO Google API key needed. Take a look
ยป SachingShare.com Blog Article