Simple Google Map - Version 1.0

Version Description

Download this release

Release Info

Developer taylor_CNP
Plugin Icon wp plugin Simple Google Map
Version 1.0
Comparing to
See all releases

Version 1.0

Files changed (2) hide show
  1. SimpleGoogleMap.php +92 -0
  2. readme.txt +35 -0
SimpleGoogleMap.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?
2
+ /*
3
+ Plugin Name: Simple Google Map
4
+ Plugin URI: http://clarknikdelpowell.com/wordpress/simple-google-map/
5
+ Description: This plugin will embed a google map using shortcode.
6
+ Author: Taylor Gorman
7
+ Author URI: http://clarknikdelpowell.com
8
+ Version: 1.0
9
+
10
+ Copyright 2009 Clark Nikdel Powell (email : taylor@cnpstudio.com)
11
+
12
+ This program is free software; you can redistribute it and/or modify
13
+ it under the terms of the GNU General Public License as published by
14
+ the Free Software Foundation; either version 2 of the License, or
15
+ (at your option) any later version.
16
+
17
+ This program is distributed in the hope that it will be useful,
18
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ GNU General Public License for more details.
21
+
22
+ You should have received a copy of the GNU General Public License
23
+ along with this program; if not, write to the Free Software
24
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
+ */
26
+
27
+
28
+
29
+ // make shortcode work
30
+ add_shortcode('SGM', 'googleMap');
31
+
32
+ /*
33
+ ===============================================================================
34
+
35
+ NAME : googleMap()
36
+ PURPOSE : prints the google map
37
+
38
+ ===============================================================================
39
+ */
40
+
41
+ function googleMap($atts) {
42
+
43
+ if ($atts['lat']) {$lat = $atts['lat'];} else {$lat = '0';}
44
+ if ($atts['lng']) {$lng = $atts['lng'];} else {$lng = '0';}
45
+ if ($atts['zoom']) {$zoom = $atts['zoom'];} else {$zoom = '12';}
46
+ $directionsto = $atts['directionsto'];
47
+
48
+ $content = $atts['content'];
49
+ $content = str_replace('&lt;', '<', $content);
50
+ $content = str_replace('&gt;', '>', $content);
51
+
52
+ $return = "
53
+ <script type='text/javascript' src='http://maps.google.com/maps/api/js?sensor=false'></script>
54
+ <script type='text/javascript'>
55
+ function makeMap() {
56
+ var latlng = new google.maps.LatLng(".$lat.", ".$lng.")
57
+
58
+ var myOptions = {
59
+ zoom: ".$zoom.",
60
+ center: latlng,
61
+ mapTypeId: google.maps.MapTypeId.ROADMAP
62
+ };
63
+ var map = new google.maps.Map(document.getElementById('SGM'), myOptions);
64
+
65
+ var contentString = '<div class=\"infoWindow\">".$content."<form method=\"get\" action=\"http://maps.google.com/maps\"><input type=\"text\" class=\"text\" name=\"saddr\" /><input type=\"hidden\" name=\"daddr\" value=\"".$directionsto."\" /><input type=\"submit\" class=\"submit\" value=\"Get directions\" /></form></div>';
66
+ var infowindow = new google.maps.InfoWindow({
67
+ content: contentString
68
+ });
69
+
70
+ var marker = new google.maps.Marker({
71
+ position: latlng,
72
+ map: map,
73
+ title: ''
74
+ });
75
+
76
+ google.maps.event.addListener(marker, 'click', function() {
77
+ infowindow.open(map,marker);
78
+ });
79
+ }
80
+ window.onload = makeMap;
81
+ </script>
82
+
83
+ <div id='SGM'></div>
84
+ ";
85
+
86
+ return $return;
87
+
88
+ }
89
+
90
+
91
+
92
+ ?>
readme.txt ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Simple Google Map ===
2
+ Contributors: taylor_CNP
3
+ Donate link:
4
+ Tags: google, google map, google maps, simple google map, no api key
5
+ Requires at least: 2.8
6
+ Tested up to: 2.8.4
7
+ Stable tag: trunk
8
+
9
+ This plugin will embed a google map using shortcode.
10
+
11
+ == Description ==
12
+
13
+ # Simple Google Map
14
+
15
+ We just needed a little embedded google map on the contact page. Every other google maps plugin either was depreciated or just plain didn’t work. So we made our own. And we thought we’d share it with you.
16
+
17
+ ## How it works
18
+
19
+ Google recently released version 3 of their Maps API. The short story is they made it smaller and faster, but with less features. The biggest advantage is that it doesn’t require an API key. So all you have to do is install this plugin and set a few options! Lucky you.
20
+
21
+ For an example and more visit [the plugin's homepage](http://clarknikdelpowell.com/wordpress/simple-google-map/ "Simple Google Map by Clark Nikdel Powell").
22
+
23
+ == Installation ==
24
+
25
+ 1. Upload `SimpleGoogleMap.php` to the `/wp-content/plugins/` directory
26
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
27
+ 3. Insert the shortcode into your posts or pages.
28
+
29
+ The shortcode name is SGM and here are the options..
30
+
31
+ * lat [int] – the latitude of the marker and the center of the map.
32
+ * lng [int] – the longitude of the marker and the center of the map.
33
+ * zoom [int] – the zoom level (0-19).
34
+ * directionsto [string] – the destination address for getting directions. obviously you want this to be the address of your latitude longitude coordinates.
35
+ * content – what goes inside the infoWindow (speech bubble) that appears when the marker is clicked.