Home › Forums › Calendar Products › Events Calendar PRO › Filter Google Map Embed
- This topic has 10 replies, 3 voices, and was last updated 11 years, 4 months ago by Will.
-
AuthorPosts
-
December 5, 2012 at 7:42 am #28972WillParticipant
Hello,
I need a way to filter the google map embed without altering the plugin’s admin/event-map.php file. I basically need to add my own style variable to recolor the map. I can transform the map object once it’s loaded via javascript, but my users see the visual transform from default map to new styles.Is there a way I can write a function that will catch the event-map.php before it fires? Or overwrite it without altering the default file so that I don’t lose changes when an update occurs?
Thanks,
will lanni
December 5, 2012 at 11:08 am #28995JonahParticipantHi Will,
I’m not sure how to do this myself but have passed it on to one of our developers to take a look. Stay tuned.
Regards,
– JonahDecember 5, 2012 at 2:48 pm #29007WillParticipantThanks Jonah!! If I can come up with a decent javascript solution I’ll post it back here for future use.
December 5, 2012 at 6:34 pm #29016WillParticipantHey folks,
Here’s how I would handle this moving forward if I wanted to extend out the ability to customize a map in the calendar:
In the Event control in the dashboard, I’d add a text area input after the google map width/height controls to allow people to add generated JSON from the style wizard on googlecode.com: http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html and store it in a variable named something like $embedGoogleMapsStyle; or whatever makes sense to you guys, and add an apply_filters() to it:
$embedGoogleMapsStyle = apply_filters( ‘tribe_google_maps_style’, ‘[contents of the text field, however that shows up here]’);In the-events-calendar/admin-views/event-map.php, after the mapTypeID entry (line 20), I’d add a comma, line break, then:
styles: myStylesAnd before the var myOptions() on line 16, I’d add a new variable with the ability to apply filters, something like this (I’ve never actually written a filter before so please excuse the horrific syntax and erroneous code):
var myStyles = {
}
December 5, 2012 at 6:37 pm #29018WillParticipantFor anyone who is looking for a temporary fix, please note that this will get wiped out whenever the plugin gets updated, but it’s pretty easy to add back in:
Open
the-events-calendar/admin-views/event-map.php
Line 19, add a comma after ROADMAP:
mapTypeId: google.maps.MapTypeId.ROADMAP,
Add:
styles:
And then paste the JSON from the wizard link in my post above into that area (it should be wrapped in [] brackets, for example:
[
{
“elementType”: “geometry.fill”,
“stylers”: [
{ “visibility”: “on” },
{ “color”: “#ffffff” }
]
}
]December 7, 2012 at 4:39 pm #29144LeahMemberThanks for posting your code, Will!
December 7, 2012 at 5:28 pm #29152WillParticipantYou’re welcome! I wish I could post code in a pre tag… shoot… maybe I can?
testing 1 2 3 4
December 8, 2012 at 9:18 am #29162JonahParticipantDecember 8, 2012 at 9:18 am #29163JonahParticipantDecember 8, 2012 at 3:29 pm #29167WillParticipantYou know, with the amount of code I look at on github, you’d think I’d use it more. 😛
December 8, 2012 at 3:41 pm #29168WillParticipantOK, here’s a better code post than my earlier one, my apologies for the rookie code post. Thanks Jonah for the link to Snippi–wish I could get their facebook login to work…
1) Create a Google Map style here: http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html
2) Copy the JSON code provided.
3) Open /wp-content/plugins/the-events-calendar/admin-views/event-map.php
4) Add styles: method to var myOptions (starts line 16), and format it to match my example on snippi.com. (My example will change your google map to a black and white map).
-
AuthorPosts
- The topic ‘Filter Google Map Embed’ is closed to new replies.