problem api
-
Hi i love your plugin but i have this error in the buddypress activity and profile:
You have included the Google Maps API multiple times on this page. This may cause unexpected errors.
Can you help me?
-
Hi,
that is normally caused by the theme or another plugin including the Google Maps API too.
Most theme and plugins have options to remove it. Our doesn’t because it totally relies on it.
Let us know if you can’t find the culprit and we will investigate. we’ll need access to your website to do so, so we suggest to register on our forum and submit your request on it, were you can also send us private replies to keep URL and credentials confidentials.
Thanks
Hi. I do it, the plugin that create the error is bp checkins. I need absolute to use it because give me the possibility to autodetect the user position and post in buddypress activity. I see that this function miss in your plugin and I search a lot a plugin for this function and I found only this. Please can you help me for solve the conflict? I see plugin have no option for disable, I found the PHP that call the scripts, I try to delete but of course do not work. I am not skill in PHP but the problem it is in about 20 code line, I need your help please
Here the code:
function bp_checkins_load_gmap3() {
if( bp_checkins_is_activity_or_friends() || bp_checkins_is_directory() || bp_checkins_is_group_checkins_area() ) {
wp_enqueue_script( ‘google-maps’, ‘http://maps.google.com/maps/api/js?sensor=false’ );
wp_enqueue_script( ‘gmap3’, BP_CHECKINS_PLUGIN_URL_JS . ‘/gmap3.min.js’, array(‘jquery’) );wp_enqueue_style( ‘bpcistyle’, BP_CHECKINS_PLUGIN_URL_CSS . ‘/bpcinstyle.css’);
if( !empty( $_GET[‘map’] ) && $_GET[‘map’] == 1 ) {
global $bpci_lat, $bpci_lng;
$bpci_lat = bp_activity_get_meta( bp_current_action(), ‘bpci_activity_lat’ );
$bpci_lng = bp_activity_get_meta( bp_current_action(), ‘bpci_activity_lng’ );if( !empty( $bpci_lat ) && !empty( $bpci_lng ) ) {
add_action(‘wp_head’, ‘bp_checkins_item_map’);
}
} elseif( bp_checkins_show_friends_checkins() ){
wp_enqueue_script( ‘bp-ckeckins-friends’, BP_CHECKINS_PLUGIN_URL_JS . ‘/bp-checkins-friends.js’ );
} else {if( bp_checkins_is_directory() || bp_checkins_is_group_checkins_area() ) {
wp_enqueue_script( ‘bp-ckeckins-dir’, BP_CHECKINS_PLUGIN_URL_JS . ‘/bp-checkins-dir.js’ );
bp_checkins_localize_script(‘dir’);
} else {
wp_enqueue_script( ‘bp-ckeckins’, BP_CHECKINS_PLUGIN_URL_JS . ‘/bp-checkins.js’ );
bp_checkins_localize_script(‘activity’);
}}
if( bp_is_single_activity() ){
add_action(‘wp_footer’, ‘bp_checkins_img_trick’);
}
}if( bp_displayed_user_id() && bp_is_settings_component() && bp_is_current_action( ‘checkins-settings’) ){
wp_enqueue_style( ‘bpcistyle’, BP_CHECKINS_PLUGIN_URL_CSS . ‘/bpcinstyle.css’);
}
}add_action(‘bp_actions’, ‘bp_checkins_load_gmap3’);
function bp_checkins_item_map() {
global $bpci_lat, $bpci_lng;
?>
<script type=”text/javascript”>
jQuery(document).ready(function($){
var bpciPosition = new google.maps.LatLng(<?php echo $bpci_lat;?>,<?php echo $bpci_lng;?>);adresse = $(“.update-checkin”).html();
$(“.activity-checkin”).append(‘<div id=”bpci-map”></div>’);
$(“.activity-checkin”).css(‘width’,’100%’);$(“#bpci-map”).gmap3({
action: ‘addMarker’,
latLng:bpciPosition,
map:{
center: true,
zoom: 16
}
},
{
action : ‘clear’,
name: ‘marker’
},
{ action:’addOverlay’,
latLng: bpciPosition,
options:{
content: ‘<div class=”bpci-avatar”><s></s><i></i><span>’ + $(“.activity-avatar”).html() + ‘</span></div>’,
offset:{
y:-40,
x:10
}
}
});
});</script>
<?php
}function bp_checkins_record_group_geoloc_meta( $content, $user_id, $group_id, $activity_id ) {
bp_checkins_record_geoloc_meta( $content, $user_id, $activity_id );
}function bp_checkins_record_geoloc_meta( $content, $user_id, $activity_id ){
/* javascript disabled */
if( isset( $_POST[‘bpci-lat’] ) ) {
$lat = $_POST[‘bpci-lat’];
$lng = $_POST[‘bpci-lng’];
$address = $_POST[‘bpci-address’];
}
else{
if ( !empty( $_POST[‘cookie’] ) )
$_BP_COOKIE = wp_parse_args( str_replace( ‘; ‘, ‘&’, urldecode( $_POST[‘cookie’] ) ) );
else
$_BP_COOKIE = &$_COOKIE;if( $_BP_COOKIE[‘bp-ci-data-delete’] == “delete”)
return false;if( strlen( $_BP_COOKIE[‘bp-ci-data’] ) < 2 )
return false;$geotable = explode(‘|’, $_BP_COOKIE[‘bp-ci-data’] );
$lat = $geotable[0];
$lng = $geotable[1];
$address = $geotable[2];
}if( !empty($lat) && !empty($lng) && !empty($address) ) {
// let’s add some meta to activity
bp_activity_update_meta( $activity_id, ‘bpci_activity_lat’, $lat );
bp_activity_update_meta( $activity_id, ‘bpci_activity_lng’, $lng );
bp_activity_update_meta( $activity_id, ‘bpci_activity_address’, $address );$check_activity_array = bp_activity_get_specific( array( ‘activity_ids’ => $activity_id ) );
$check_activity = $check_activity_array[‘activities’][0];
/* if the activity is new_place or solo comment place, we should not update the user’s last position */
if( !in_array( $check_activity->type, array(‘new_place’, ‘place_comment’) ) ) {
// let’s update latest user’s position for ‘show my friends on map’ feature
bp_update_user_meta( $user_id, ‘bpci_latest_lat’, $lat );
bp_update_user_meta( $user_id, ‘bpci_latest_lng’, $lng );
bp_update_user_meta( $user_id, ‘bpci_latest_address’, $address );
}/* as we have the activity, let’s rename the type of the activity to activity_checkin if it’s a regular activity_update */
if( $check_activity->type == “activity_update” && (int)bp_get_option( ‘bp-checkins-activate-component’ ) ) {
bp_checkins_update_to_checkin_type( $activity_id, $check_activity );}
}
}
?>Hello,
Please try adding this to your child theme functions.php file
function my_dequeue_script() { wp_dequeue_script( 'google-maps' ); } add_action( 'wp_print_scripts', 'my_dequeue_script', 100 );Thanks,
Stiofan
Hi, i rty and now the error in consolle change, i have this:
Uncaught ReferenceError: google is not defined
bp-checkins.js:24 Uncaught TypeError: $(…).gmap3 is not a functionThis is the line of the error:
$(‘#bpci-position-inputs’).gmap3({
action : ‘geoLatLng’,
callback : function(latLng){
if(latLng){
position = latLng;
$(this).gmap3({
action:’getAddress’,
latLng:latLng,
callback:function(results){
adresse = results && results[1] ? results && results[1].formatted_address : ‘no address’;
$.cookie(“bp-ci-data”, latLng.lat()+”|”+latLng.lng()+”|”+adresse, { path: ‘/’ });
$.cookie(“bp-ci-data-delete”, ”, { path: ‘/’ });
$(“#bpci-position-inputs”).html(‘<input type=”hidden” name=”bpci-lat” id=”bpci-lat” value=”‘+latLng.lat()+'”><input type=”hidden” name=”bpci-lng” id=”bpci-lng” value=”‘+latLng.lng()+'”><input type=”text” readonly value=”‘+adresse+'” id=”bpci-address” name=”bpci-address” placeholder=”‘+bp_checkins_vars.addressPlaceholder+'”><span>’+buttonTitle+'</span><span>’+bp_checkins_vars.modCheckinTitle+'</span><span>’+bp_checkins_vars.resetCheckinTitle+'</span><div id=”bpci-map” class=”map-hide”></div>’);
}
});
} else {
buttonAction = ‘search’;
buttonTitle = bp_checkins_vars.addMapSrcTitle;
$(“#bpci-position-inputs”).html(‘<input type=”hidden” name=”bpci-lat” id=”bpci-lat”><input type=”hidden” name=”bpci-lng” id=”bpci-lng”><input type=”text” id=”bpci-address” name=”bpci-address” placeholder=”‘+bp_checkins_vars.addressPlaceholder+'”><span>’+buttonTitle+'</span><span>’+bp_checkins_vars.modCheckinTitle+'</span><span>’+bp_checkins_vars.resetCheckinTitle+'</span><div id=”bpci-map” class=”map-hide”></div>’);
alert(bp_checkins_vars.html5LocalisationError);
$(“#bpci-address”).focus();
}
}
});}
return false;
});thanks for your big help
ok, i don’t think this is something that will be solved though back and fourth messages like this, can you please start a new support topic on our support forum where you will then be able to send us login details in private so we can take a look ourselves?
https://wpgeodirectory.com/support/forum/geodirectory-core-plugin-forum/plugin-support/Thanks,
Stiofan
Hi, finally i found the solution after long time. The author of bp check-in plugin post the small code to add to the theme function but Was for another plugin that load the script:
i simply added these lines to the functions.php of my active theme and it seems to fix the problem :
function imath_avoid_conflict_error_gtm_events_manager(){
/*
If map is required and gtm is hooking wp_print_scripts then, i remove this hook.
*/
if( isset( $_GET[‘map’] ) && has_action( ‘wp_print_scripts’, ‘bp_gtm_js_groups_all’ ) ) {
remove_action(‘wp_print_scripts’, ‘bp_gtm_js_groups_all’);
}
}add_action(‘bp_actions’, ‘imath_avoid_conflict_error_gtm_events_manager’);
Please can you help me to adapt the script relative to your plugin?
Thank you so muchHi,
as Stiofan asked, please register in our forum where you can share link and credentials in private with forum moderator…
It will take much less time for us to figure out how to fix your problem if we can do our debugging directly.
Thank you
The topic ‘problem api’ is closed to new replies.