<?php if ( $location = bp_get_profile_field_data( 'field=Location&user_id=' . bp_displayed_user_id() ) ) : ?>
<div class="widget">
<h3 class="widgettitle">Location <?php if ( bp_is_my_profile() ) : ?>ยท <a href="<?php echo bp_loggedin_user_domain() .'profile/edit/' ?>">Edit</a><?php endif; ?></h3>
<script src="http://maps.google.com/maps?file=api&v=2.x&key=[YOUR API KEY]" type="text/javascript"></script>
<script type="text/javascript">
var map = null;
var geocoder = null;
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(0, 0), 35);
geocoder = new GClientGeocoder();
}
}
function showAddress(address) {
if (geocoder) {
geocoder.getLatLng(
address,
function(point) {
if (point) {
map.setCenter(point, 11);
var marker = new GMarker(point);
map.addOverlay(marker);
map.addControl(new GSmallMapControl());
}
}
);
}
}
jQuery(document).ready( function() { initialize(); showAddress('<?php echo $location ?>'); } );
</script>
<div id="map_canvas" style="width: 100%; height: 150px; border: 1px solid #eee; overflow: hidden"></div>
</div>
<?php endif; ?>