Post edited 1:51 pm – May 16, 2010 by spblinux
Added support for zoomlevel and satellite view.
Example:
php file: wp-google-maps.php (changes as diff below)
— bak/wp-google-maps.php 2010-01-05 18:22:00.000000000 +0100
+++ wp-google-maps.php 2010-05-16 21:14:22.000000000 +0200
@@ -232,6 +232,8 @@
$mapInfo = (object)shortcode_atts(array('name' => '',
'mousewheel' => 'true',
+ 'zoomlevel' => '15',
+ 'satellite' => 'false',
'zoompancontrol' => 'true',
'typecontrol' => 'true',
'directions_to' => 'true',
@@ -311,11 +313,20 @@
</td>
</tr>
<tr valign="top">
+ <th scope="row"><label for="wpGoogleMaps_zoomlevel"><?php _e('Zoom Level (0..15..19):')?></label></th>
+ <td>
+ <input type="text" size="4" name="wpGoogleMaps[zoomlevel]" id="wpGoogleMaps_zoomlevel" />
+ </td>
+ </tr>
+ <tr valign="top">
<th scope="row"><label for="wpGoogleMaps_description"><?php _e('Options:')?></label></th>
<td>
<input type="hidden" name="wpGoogleMaps[mousewheel]" id="wpGoogleMaps_mousewheel_" value="false" />
<input type="checkbox" name="wpGoogleMaps[mousewheel]" id="wpGoogleMaps_mousewheel" value="" checked="checked" />
<label for="wpGoogleMaps_mousewheel">Enable Mouse Wheel Zoom</label><br />
+ <input type="hidden" name="wpGoogleMaps[satellite]" id="wpGoogleMaps_satellite_" value="" />
+ <input type="checkbox" name="wpGoogleMaps[satellite]" id="wpGoogleMaps_satellite" value="true" />
+ <label for="wpGoogleMaps_satellite">Enable satellite view</label><br />
<input type="hidden" name="wpGoogleMaps[zoompancontrol]" id="wpGoogleMaps_zoompancontrol_" value="false" />
<input type="checkbox" name="wpGoogleMaps[zoompancontrol]" id="wpGoogleMaps_zoompancontrol" value="" checked="checked" />
<label for="wpGoogleMaps_zoompancontrol">Enable Zoom/Pan Controls</label><br />
js file: wp-google-maps.js (changes as diff below)
— bak/wp-google-maps.js 2010-05-15 22:14:14.000000000 +0200
+++ wp-google-maps.js 2010-05-16 21:54:26.000000000 +0200
@@ -61,6 +61,7 @@
},
wpNewMap : function(mapNum, mapInfo)
{
+ var zoomlevel = 15;
if (this.geocoder) {
if (!this.map[mapNum]) {
this.map[mapNum] = {};
@@ -83,6 +84,12 @@
if (this.map[mapNum]['mapInfo'].get('mousewheel')) {
this.map[mapNum]['map'].enableScrollWheelZoom();
}
+ if (this.map[mapNum]['mapInfo'].get('satellite')) {
+ this.map[mapNum]['map'].setMapType(G_SATELLITE_MAP);
+ }
+ if (this.map[mapNum]['mapInfo'].get('zoomlevel')) {
+ zoomlevel = Number(this.map[mapNum]['mapInfo'].get('zoomlevel'));
+ }
this.map[mapNum]['gdir'] = new GDirections(this.map[mapNum]['map'], $('dir_' + mapNum));
this.geocoder.getLatLng(
@@ -93,6 +100,7 @@
} else {
wpGMaps.map[mapNum]['mapInfo'].set('point', point);
wpGMaps.map[mapNum]['map'].setCenter(point, 13);
+ wpGMaps.map[mapNum]['map'].setZoom(zoomlevel);
wpGMaps.map[mapNum]['marker'] = new GMarker(point);
GEvent.addListener(wpGMaps.map[mapNum]['marker'], "click", function() {
if (wpGMaps.map[mapNum]['map'].getInfoWindow().isHidden()) {
————————————————————–