Le Blog d’Altairis

Le blog d'Altairis

WordPress / JetPack : change map scale on contact infos widget

WordPress / JetPack : change map scale on contact infos widget

Hey everybody !

Today i prefer to write in English, because i think this article might concern a larger audience than my other posts, although (and also because) it’s a little technical trick to solve an irritating problem.

So, you should have noticed (shouldn’t you ?) that the scale of the map at the bottom of our homepage have changed !

Before it looked like that : oldmap

And now like this :

A quick search on the web gave me no result,newmap so i have to find myself how to do it; and i post this article to explain the (easy) method in case someone else search for it in the future.

So, back to the code ! You have to modify the contact-info-map.js in the wp-content/plugins/jetpack/modules/widgets/contact-info/ folder and change the zoom mapOption from 16 to the value you like (4 in my case).

Note that this fix may be overridden by next jetpack update…

Here is my updated script:

/* global google */
/* jshint unused:false */
if (jQuery) {
	jQuery().ready(function() {
			// get lat and lon from hidden input values
			var lat = jQuery(this).find('.contact-info-map-lat').val(),
				lon = jQuery(this).find('.contact-info-map-lon').val(),
				lat_lon = new google.maps.LatLng( lat, lon ),
				mapOptions = {
					zoom: 4,
					center: lat_lon,
					mapTypeId: google.maps.MapTypeId.ROADMAP
				map = new google.maps.Map(jQuery(this).find('.contact-info-map-canvas')[0], mapOptions),
				marker = new google.maps.Marker({
					map: map,
					position: lat_lon