Home › Forums › Calendar Products › Events Calendar PRO › Language for google maps
- This topic has 14 replies, 4 voices, and was last updated 9 years, 4 months ago by
Daan.
-
AuthorPosts
-
November 14, 2016 at 5:11 am #1191771
Daan
ParticipantHi there,
I would like to change the google maps language, but changing it in the main.php breaks the plugin.
How should i go about replacing the function (with a filter maybe?) that does that from the functions.phpWhat i want to change:
public function googleMapLink( $post_id = null ) { if ( $post_id === null || ! is_numeric( $post_id ) ) { global $post; $post_id = $post->ID; } $locationMetaSuffixes = array( 'address', 'city', 'region', 'zip', 'country' ); $to_encode = ''; $url = ''; foreach ( $locationMetaSuffixes as $val ) { $metaVal = call_user_func( 'tribe_get_' . $val, $post_id ); if ( $metaVal ) { $to_encode .= $metaVal . ' '; } } if ( $to_encode ) { $url = 'http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=' . urlencode( trim( $to_encode ) ); }With hl=en i would like to change the language or the links.
I couldn’t yet find how to change it for the maps themselves. Any help?Much obliged,
DaanNovember 14, 2016 at 5:19 am #1191772Daan
ParticipantAh, must be something in the src/functions/template-tags/google-map.php
/** * Google Map Embed * * Returns an embedded google maps for an event * * @category Events * * @param string $post_id * @param int $width * @param int $height * @param bool $force_load If true, then load the map even if an address is not provided. * * @return string An iframe pulling http://maps.google.com/ for this event */ function tribe_get_embedded_map( $post_id = null, $width = null, $height = null, $force_load = false ) { return Tribe__Events__Embedded_Maps::instance()->get_map( $post_id, $width, $height, $force_load ); }How would I fit in the string: &language=nl
https://developers.google.com/maps/documentation/javascript/examples/map-languageThanks!
November 15, 2016 at 5:47 am #1192363Josh
ParticipantHey Daan,
Thanks for reaching out to us!
Sure thing! You can modify the map language using the modified URL using the “tribe_events_google_map_link” filter.
I’m not sure if this would be 100% exactly what you’re looking for here but this would be an example of how to extend that link here:
https://gist.github.com/BeardedGinger/36200f93c33dfe9848a8294319f72e63
Let me know if this helps.
Thanks!
November 16, 2016 at 1:24 pm #1193448Daan
ParticipantHi Josh,
That works great for the link to googlemaps! Thanks.
At least when i replace ‘&language=nl’ with ‘&hl=nl’. 🙂But… not so much for the embedded map.
I guess (but not sure) the string ‘&language=nl’ should be added to the Tribe__Events__Embedded_Maps::instance().
But i don’t quite get how i should get that to work.
Maybe you could shed some light into my darkness? Owhhhh! (My best wolf imitation.)Regards,
DaanNovember 18, 2016 at 5:35 am #1194403Josh
ParticipantHey Daan,
Thanks for following up!
Looking at our source code, I’m not seeing a straightforward way to filter or modify the language for the embedded map there. I’ll need to do a little more research there to see what I can find for you.
Thanks!
November 18, 2016 at 5:46 am #1194406Daan
ParticipantHi Josh!
Thanks for letting me know you’re on to it!
Exactly my thoughts up to ‘a little more research’ where i gave up and asked. 🙂Hope to hear for you soon!
DaanNovember 21, 2016 at 6:17 am #1195277Josh
ParticipantHey Daan,
I’ve got an internal support ticket open for you here and will let you know what I hear back.
Thanks!
November 24, 2016 at 4:27 am #1196949Daan
ParticipantThanks Josh!
That’s good news.
DaanDecember 2, 2016 at 6:53 am #1200805Josh
ParticipantHey Daan,
I apologize for the delay here and appreciate your patience.
It looks like we may have a filter that will work for you here! You can use the “tribe_events_google_maps_api”. With that, you should be able to add a query argument for the URL used and pass it for the embedded map.
You could try something like:
add_filter( 'tribe_events_google_maps_api', 'language_filter_embedded_map' ); function language_filter_embedded_map( $js_maps_api_url ) { $js_maps_api_url = add_query_arg( 'hl', 'nl', $js_maps_api_url ); return $js_maps_api_url ; }Let me know if this helps.
Thanks!
December 14, 2016 at 7:52 am #1205829Daan
ParticipantAlmost there Josh,
It’s like this:
// gmap in nl :-3 add_filter( 'tribe_events_google_maps_api', 'language_filter_embedded_map' ); function language_filter_embedded_map( $js_maps_api_url ) { $js_maps_api_url = add_query_arg( '&language', 'nl', $js_maps_api_url ); return $js_maps_api_url; }But then the main map is still in English.
Hhmm, someone didn’t follow protocol.
Could you check that out?Thanks & regards,
Daan-
This reply was modified 9 years, 5 months ago by
Daan. Reason: typo
December 15, 2016 at 8:36 pm #1206895Josh
ParticipantHey Daan,
Thanks for following up here! I tested out the snippet and it appears to be working for me on the embedded maps https://cloudup.com/cqFyR1EKn97.
Where are you currently adding that snippet?
Thanks!
December 16, 2016 at 3:48 am #1207004Daan
ParticipantHi Josh,
We also needed to add:
add_filter( 'tribe_events_pro_google_maps_api', 'language_filter_embedded_map' );
Else the main map remains without the language string.So the full code now is:
// gmap in set language add_filter( 'tribe_events_google_maps_api', 'language_filter_embedded_map' ); add_filter( 'tribe_events_pro_google_maps_api', 'language_filter_embedded_map' ); function language_filter_embedded_map( $js_maps_api_url ) { $js_maps_api_url = add_query_arg( '&language', 'nl', $js_maps_api_url ); return $js_maps_api_url; }But just now i saw that the single-events map doesn’t work on my mobile device.
Could you look into that? Or should i open another ticket.Hhmm, would be great to have the static map on mobile or under a certain screen width.
https://developers.google.com/maps/documentation/static-maps/Regards,
DaanDecember 19, 2016 at 7:46 am #1207679Josh
ParticipantHey Daan,
Awesome! I’m glad you were able to get the map working with the different language!
Might be best to open a new thread for that particular issue. In that thread, be sure to give full detail on the issue you’re experiencing along with verifying the Testing for Conflicts procedures so we can help you get to the root of that one more quickly.
Thanks!
January 10, 2017 at 8:35 am #1215840Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
This reply was modified 9 years, 5 months ago by
-
AuthorPosts
- The topic ‘Language for google maps’ is closed to new replies.
