Skip Navigation

[Resolved] Google Maps China Specific Problem

This thread is resolved. Here is a description of the problem and solution.

Problem:
VR China requires a specific server for showing the Google map
How can I implement this for my website, using Toolset Maps?

Solution:
1. You need toolset maps 1.1 at least
2. You apply this filters in your functions.php:

add_filter( 'toolset_filter_toolset_maps_api_js_url', 'prefix_serve_maps_js_from_china' );
 
function prefix_serve_maps_js_from_china( $url ) {
    $url = 'http://maps.google.cn/maps/api/js';
    return $url;
}
 
add_filter( 'toolset_filter_toolset_maps_api_geocode_url', 'prefix_serve_maps_geocode_from_china' );
 
function prefix_serve_maps_geocode_from_china( $url ) {
    $url = 'http://maps.google.cn/maps/api/geocode/json';
    return $url;
}

Relevant Documentation:
https://toolset.com/documentation/user-guides/display-on-google-maps/

This support ticket is created 8 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 1.17 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 9 replies, has 2 voices.

Last updated by George 8 years ago.

Assisted by: Beda.

Author
Posts
#378911

Hello again team,

2 Questions which are both about using Google Maps Integration while in China.

1. How can I add a function to change all API calls from the default to google.cn/maps ? I found another request for this here: https://toolset.com/forums/topic/can-i-use-google-maps-china/
but the function did not work. It just led to an undefined error (even after I changed it to the correct URL)

2. When using a VPN with the website on my localhost (so API loads correctly), it seems like
a. the integration is not saving detailed address data - I keep saving the detailed address, but it reverts back to the general location of the district the place is located in, and

b. the view is calling a location different from the one that is saved (so instead of the district address that it keeps reverting to, the map is showing some place in the ocean, far away from the correct address).

Is something in the plugin blocking addresses in China from being saved/displayed because of Chinese characters?

Thanks!

#379105

This Filter should work with Views maps 1.1:

add_filter( 'toolset_filter_toolset_maps_api_url', 'prefix_serve_maps_from_china' );

function prefix_serve_maps_from_china( $url ) {
	$url = '<em><u>hidden link</u></em>';
	return $url;
}

Please note that this filter is being applied at init time with priority 10, so any hook to modify its output must be added either on an earlier hook or on a higher priority (like 9, for example).

From the other thread I gather, the issue is not solved with above Code and i requested some feedback in it from our DEV.

If this does not work for you, please update me and expect infos ASAP.

Thank you

#379140
pic 3.jpg
pic 2.jpg
pic 1.jpg

Thanks for your reply Beda. I have tried the code again and it still leads to Google Maps - Undefined.

For now, I have replaced the two calls in the 'toolset-common-functions.php' file and the map shows up.

Unfortunately, the problem I explained in #2 still remains. When I save an address in the Google Maps address field (and I did check that it is searchable on Google Maps first, so it is a real address), it gets replaced with another address.

See the attached pictures to see what I'm experiencing.

Thanks!

#379158

For the second issue pleas open a separate Thread.
I apologize having forgotten to inform you about this previously and about the inconvenience.
But I am bound to our Company Support Policy here:
https://toolset.com/forums/ > Support Policy

Anyway I suspect that issue you mention (second issue) is a issue I reported and for which we have a fix in development.

But please open a new Ticket in regard to be sure about it.

I am waiting for feedback about the China Firewall Issue and will get back at you here ASAP.

Thank you

#379177
#379340

I have a new filter submitted by DEV:

add_filter( 'toolset_filter_toolset_maps_api_js_url', 'prefix_serve_maps_js_from_china' );

function prefix_serve_maps_js_from_china( $url ) {
    $url = '<em><u>hidden link</u></em>';
    return $url;
}

add_filter( 'toolset_filter_toolset_maps_api_geocode_url', 'prefix_serve_maps_geocode_from_china' );

function prefix_serve_maps_geocode_from_china( $url ) {
    $url = '<em><u>hidden link</u></em>';
    return $url;
}

Note that neither the previous nor this new filter will work with the Current Maps version.

I will need to ship you a DEV/Beta version to test this on your end.

If you agree to this please acknowledge and provide:

1. It's on your own responsibility to use this Plugin (Beta Policy)
2. Perform Backups, deploy on DEV sites before you go live with it, and please bare with us if it presents misbehavior, it's not yet through QA.
3. I would need to request temporary access (WP-Admin and/or FTP) to your site
- preferably to a test site -
in order to upload the Plugin.

I will need to rename this new Plugin and you will then activate it + apply the above filters.

Your next answer will be private which means only you and I have access to it.

❌ Please backup your database and website ❌

Please could you provide me the additional Infos, and as well permit me to perform the required steps?

Thank you for your patience.

#381834

I renamed the existing Toolset Maps on your Website to Toolset Maps-old and uploaded the Alpha version of Toolset Maps.

It is not yet activated.

Still the OLD Toolset Maps is active on your site.

You need now to deactivate first the old one, and then activate the new version.

Be careful, they both have the same version number.

If you are not sure which you activated, head to FTP and rename one of both Plugin Folders to any thing else.

The modified Plugin will then automatically get deactivated in the Plugin area.

Thank you

#381956

Thanks Beda,

I have activated the new plugin and added in the filter to my functions.php . Unfortunately, it seems like the plugin is still loading from maps.google.com, and the map view is also pointing to somewhere in the ocean again.

#382337

Meanwhile we released Toolset Maps 1.1

This must include the fix according our DEV Team

Please apologize the inconveniences and waste to time, but can you remove your current Plugins and update the whole Toolset Suite?

You will find all Plugins under your Downloads Section in your toolset Account:
https://toolset.com/account/downloads/

After, ensure this filter is correctly applied:
https://toolset.com/forums/topic/google-maps-china-specific-problem/#post-379340

Please don't hesitate to inform me in case the issue persists

Thank you for your patience.

#383667

Beda,

Works perfectly! Thank you and the team so much.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.