• Version 0.1.1 of Geolocation conflicts with other plugins using jQuery. To fix this we removed the “noConflict” lines and changed the $j to jQuery – noConflict is implicite if you just use jQuery instead of a $ variable. Key was not to search and replace because some variables in his PHP were called $json and got changed to $jQueryson. The script from lines 156 to 325 should be this:

    <script type="text/javascript">
    			jQuery(function() {
    				jQuery(document).ready(function() {
    				    var hasLocation = false;
    					var center = new google.maps.LatLng(0.0,0.0);
    					var postLatitude =  '<?php echo esc_js(get_post_meta($post_id, 'geo_latitude', true)); ?>';
    					var postLongitude =  '<?php echo esc_js(get_post_meta($post_id, 'geo_longitude', true)); ?>';
    					var public = '<?php echo get_post_meta($post_id, 'geo_public', true); ?>';
    					var on = '<?php echo get_post_meta($post_id, 'geo_enabled', true); ?>';
    
    					if(public == '0')
    						jQuery("#geolocation-public").attr('checked', false);
    					else
    						jQuery("#geolocation-public").attr('checked', true);
    
    					if(on == '0')
    						disableGeo();
    					else
    						enableGeo();
    
    					if((postLatitude != '') && (postLongitude != '')) {
    						center = new google.maps.LatLng(postLatitude, postLongitude);
    						hasLocation = true;
    						jQuery("#geolocation-latitude").val(center.lat());
    						jQuery("#geolocation-longitude").val(center.lng());
    						reverseGeocode(center);
    					}
    
    				 	var myOptions = {
    				      'zoom': <?php echo $zoom; ?>,
    				      'center': center,
    				      'mapTypeId': google.maps.MapTypeId.ROADMAP
    				    };
    				    var image = '<?php echo esc_js(esc_url(plugins_url('img/wp_pin.png', __FILE__ ))); ?>';
    				    var shadow = new google.maps.MarkerImage('<?php echo esc_js(esc_url(plugins_url('img/wp_pin_shadow.png', __FILE__ ))); ?>',
    						new google.maps.Size(39, 23),
    						new google.maps.Point(0, 0),
    						new google.maps.Point(12, 25));
    
    				    var map = new google.maps.Map(document.getElementById('geolocation-map'), myOptions);
    					var marker = new google.maps.Marker({
    						position: center,
    						map: map,
    						title:'Post Location'<?php if(get_option('geolocation_wp_pin')) { ?>,
    						icon: image,
    						shadow: shadow
    					<?php } ?>
    					});
    
    					if((!hasLocation) && (google.loader.ClientLocation)) {
    				      center = new google.maps.LatLng(google.loader.ClientLocation.latitude, google.loader.ClientLocation.longitude);
    				      reverseGeocode(center);
    				    }
    				    else if(!hasLocation) {
    				    	map.setZoom(1);
    				    }
    
    					google.maps.event.addListener(map, 'click', function(event) {
    						placeMarker(event.latLng);
    					});
    
    					var currentAddress;
    					var customAddress = false;
    					jQuery("#geolocation-address").click(function(){
    						currentAddress = jQuery(this).val();
    						if(currentAddress != '')
    							jQuery("#geolocation-address").val('');
    					});
    
    					jQuery("#geolocation-load").click(function(){
    						if(jQuery("#geolocation-address").val() != '') {
    							customAddress = true;
    							currentAddress = jQuery("#geolocation-address").val();
    							geocode(currentAddress);
    						}
    					});
    
    					jQuery("#geolocation-address").keyup(function(e) {
    						if(e.keyCode == 13)
    							jQuery("#geolocation-load").click();
    					});
    
    					jQuery("#geolocation-enabled").click(function(){
    						enableGeo();
    					});
    
    					jQuery("#geolocation-disabled").click(function(){
    						disableGeo();
    					});
    
    					function placeMarker(location) {
    						marker.setPosition(location);
    						map.setCenter(location);
    						if((location.lat() != '') && (location.lng() != '')) {
    							jQuery("#geolocation-latitude").val(location.lat());
    							jQuery("#geolocation-longitude").val(location.lng());
    						}
    
    						if(!customAddress)
    							reverseGeocode(location);
    					}
    
    					function geocode(address) {
    						var geocoder = new google.maps.Geocoder();
    					    if (geocoder) {
    							geocoder.geocode({"address": address}, function(results, status) {
    								if (status == google.maps.GeocoderStatus.OK) {
    									placeMarker(results[0].geometry.location);
    									if(!hasLocation) {
    								    	map.setZoom(16);
    								    	hasLocation = true;
    									}
    								}
    							});
    						}
    						jQuery("#geodata").html(latitude + ', ' + longitude);
    					}
    
    					function reverseGeocode(location) {
    						var geocoder = new google.maps.Geocoder();
    					    if (geocoder) {
    							geocoder.geocode({"latLng": location}, function(results, status) {
    							if (status == google.maps.GeocoderStatus.OK) {
    							  if(results[1]) {
    							  	var address = results[1].formatted_address;
    							  	if(address == "")
    							  		address = results[7].formatted_address;
    							  	else {
    									jQuery("#geolocation-address").val(address);
    									placeMarker(location);
    							  	}
    							  }
    							}
    							});
    						}
    					}
    
    					function enableGeo() {
    						jQuery("#geolocation-address").removeAttr('disabled');
    						jQuery("#geolocation-load").removeAttr('disabled');
    						jQuery("#geolocation-map").css('filter', '');
    						jQuery("#geolocation-map").css('opacity', '');
    						jQuery("#geolocation-map").css('-moz-opacity', '');
    						jQuery("#geolocation-public").removeAttr('disabled');
    						jQuery("#geolocation-map").removeAttr('readonly');
    						jQuery("#geolocation-disabled").removeAttr('checked');
    						jQuery("#geolocation-enabled").attr('checked', 'checked');
    
    						if(public == '1')
    							jQuery("#geolocation-public").attr('checked', 'checked');
    					}
    
    					function disableGeo() {
    						jQuery("#geolocation-address").attr('disabled', 'disabled');
    						jQuery("#geolocation-load").attr('disabled', 'disabled');
    						jQuery("#geolocation-map").css('filter', 'alpha(opacity=50)');
    						jQuery("#geolocation-map").css('opacity', '0.5');
    						jQuery("#geolocation-map").css('-moz-opacity', '0.5');
    						jQuery("#geolocation-map").attr('readonly', 'readonly');
    						jQuery("#geolocation-public").attr('disabled', 'disabled');
    
    						jQuery("#geolocation-enabled").removeAttr('checked');
    						jQuery("#geolocation-disabled").attr('checked', 'checked');
    
    						if(public == '1')
    							jQuery("#geolocation-public").attr('checked', 'checked');
    					}
    				});
    			});
    		</script>

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Geolocation] jQuery Fix’ is closed to new replies.