Support » Plugin: API KEY for Google Maps » MAP URL in China

  • Resolved alexlii

    (@alexlii)


    Hello,

    Our server is in China for local service, unfortunately, any global resource like google, twitter, Facebook…are blocked by China government Firewall name Great Firewall.

    Fornately, we can access google map at http://www.google.cn/maps, but we can not access maps.google.com.

    So, it would much great if you would like to help me with a short code snippet to switch the url, So that I can use the plugin of Code Snippets to input that code.

    Thanks in advance, and have a nice day.。

    Alex.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Stiofan

    (@stiofansisland)

    Hi Alex,

    I have not tested this but it should work:

    add_filter( 'clean_url', '_my_change_google_api_url', 105, 3 );
    function _my_change_google_api_url( $url, $original_url, $_context ) {
    	
    	if ( strstr( $url, "maps.google.com/maps/api/js" ) !== false || strstr( $url, "maps.googleapis.com/maps/api/js" ) !== false ) {// it's a Google maps url
    
    		$url = str_replace( ".com/maps", ".cn/maps", $url ); // change to cn url
    	}
    
    	return $url;
    }

    Let me know if it works for you 🙂

    Thanks,

    Stiofan

    Hello Stiofan,

    does it also support wpgeodirectory? if not, it would be great thanks if you can send another one piece of code. Great thanks.

    Alex

    Plugin Author Stiofan

    (@stiofansisland)

    that snippet should change the google api for anything that adds the google maps api the right way (but i have not tested)

    If using GD it should work and if not you can change the API to use Open Street Maps in the settings.

    Stiofan

    Sometimes, google map will show up, sometimes not, it seems not so stable, any reason?

    Thanks

    Alex

    Plugin Author Stiofan

    (@stiofansisland)

    I can’t think of a reason. If it is GD related please try posting on our own forums: https://wpgeodirectory.com/support/

    Thanks,

    Stiofan

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘MAP URL in China’ is closed to new replies.