Up to 50 percent off

Custom Field Google Maps

This topic contains 11 reply and 3 voices, and was last updated by Sekander Badsha 10 years, 1 month ago
Viewing 11 Posts - 1 through 11 (of 11 total)
Author Posts
September 9, 2014 at 9:06 pm 26549
Sekander Badsha Hey there! I'm using the Custom Field Google Maps and I want to display the Coordinates and the map on my post front-end. The problem is that the following code snippet is only displaying the Coordinates. ID, 'map_location', true ); ?> Result: 32.6669328,-16.924055400000043 Any help on how can I display the map? Thank you.
September 11, 2014 at 12:17 pm 26640
Sekander Badsha Sekander Badsha

Hello Bruno,
I need to be clear about your issue. Are you trying to show the map and the coordinates both? and the map is not working or the coordinates are not displaying the way you want?

September 16, 2014 at 4:55 am 26855
Bruno Bruno

Dear Sekander,

yes I’m trying to show the map and the coordinates.
Hope to hear from you soon.

Thank you.

September 17, 2014 at 5:40 pm 26938
Francisco Francisco

I am interested also in show map and coordinates.

Regards
Frank

September 18, 2014 at 8:32 pm 26989
Bruno Bruno

Hi guys!
I’ve been able to worked out.
Hope this solution helps any others.

The solution: and echoing the get_post_meta var you’ve defined on the wp front-end.

Using Google Maps API V3
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>

The Script in your single.php (or ohter)

<script>
function initialize() {
var myLatlng = new google.maps.LatLng(<strong><?php echo get_post_meta( $post->ID, 'map_location', true ); ?></strong>);
var mapOptions = {
zoom: 10,
center: myLatlng
}
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
										
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: 'We are here!'
});
}
										
										google.maps.event.addDomListener(window, 'load', initialize);
										
									</script>
									<div id="map-canvas"></div>

Important!
Don’t forget to define a min-height for #map-canvas in your CSS.

September 19, 2014 at 2:14 am 27002
Francisco Francisco

Hello Bruno, For me your solution doesn’t work 🙁 . Can you take a look please?

I put this on my single.php


Still waiting for Wedevs support. It have no sense that they put a feature that we can’t show in a simple way 🙁

September 19, 2014 at 3:59 am 27004
Bruno Bruno

Francisco,
from my code above change this line to:

var myLatlng = new google.maps.LatLng(<?php echo get_post_meta( $post->ID, 'map_location', true ); ?>);

Let me know if it is working now.

September 19, 2014 at 4:13 am 27006
Francisco Francisco

Hello Bruno,

Thanks for reply so fast :).

Y also try removing “ before reply you but doesn’t work.” Of course I have #map-canvas with min-height, z-index… and I see only a block of white. No map showed.

This is the ouput with the chrome Developer Tools:

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
<script src="https://maps.gstatic.com/maps-api-v3/api/js/18/4/intl/es_ALL/main.js" type="text/javascript"></script>

<script> function initialize() { var myLatlng = new google.maps.LatLng(41.7916553,0.8098476999999775); var mapOptions = { zoom: 10, center: myLatlng } var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); var marker = new google.maps.Marker({ position: myLatlng, map: map, title: 'We are here!' }); } google.maps.event.addDomListener(window, 'load', initialize); </script>
<div id="map-canvas"></div>

Regards
Frank

September 26, 2014 at 4:38 pm 27584
Francisco Francisco

Please, this is not resolved. In my case doesn’t work.

Some support please?

Regards
Frank

September 27, 2014 at 6:10 pm 27625
Sekander Badsha Sekander Badsha

Hello Frank,
Can you please describe what you are trying to and not working?

September 28, 2014 at 6:03 pm 27666
Francisco Francisco

Hello Sekander,

Finally I resolve my problem with less code than Bruno and works ok.

I put this on my single.php:

<?php echo wpuf_shortcode_map_post( ‘my_metakey_map’, $post_id ); ?>

and works fine. I see in documentation about WP geo, but this is more simple and works nice so I think put in documentation is a good idea

Thanks
Frank

September 29, 2014 at 2:06 pm 27709
Sekander Badsha Sekander Badsha

Hi Frank,
I would be glad if you can write a blog post regarding this issue. That would let your friends and other people know about this issue and how you bravely solved it.
And I will include this also in our documentation.

Thank you so much for being awesome!! 😀

Viewing 11 Posts - 1 through 11 (of 11 total)