Version Description
[2012-01-26] = * fix directions bugs in JavaScript for Opera, IE
Download this release
Release Info
Developer | webaware |
Plugin | Flexible Map |
Version | 1.0.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.0.1
- class.FlxMapPlugin.php +1 -1
- flexible-map.js +226 -208
- flexible-map.min.js +2 -2
- flexible-map.php +1 -1
- readme.txt +35 -4
class.FlxMapPlugin.php
CHANGED
@@ -73,7 +73,7 @@ class FlxMapPlugin {
|
|
73 |
public function actionFooter() {
|
74 |
if ($this->loadScripts) {
|
75 |
// load required scripts
|
76 |
-
$url = parse_url("{$this->urlBase}/flexible-map.min.js", PHP_URL_PATH);
|
77 |
|
78 |
echo <<<HTML
|
79 |
<script src="$url"></script>
|
73 |
public function actionFooter() {
|
74 |
if ($this->loadScripts) {
|
75 |
// load required scripts
|
76 |
+
$url = parse_url("{$this->urlBase}/flexible-map.min.js", PHP_URL_PATH) . '?v=2';
|
77 |
|
78 |
echo <<<HTML
|
79 |
<script src="$url"></script>
|
flexible-map.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/*!
|
2 |
JavaScript for the WordPress plugin wp-flexible-map
|
3 |
-
|
4 |
*/
|
5 |
|
6 |
function FlexibleMap() {
|
@@ -22,231 +22,249 @@ function FlexibleMap() {
|
|
22 |
this.region = false;
|
23 |
}
|
24 |
|
25 |
-
FlexibleMap.prototype = {
|
26 |
-
constructor: FlexibleMap,
|
27 |
-
|
28 |
-
/**
|
29 |
-
* show a map based on a KML file
|
30 |
-
* @param {String} divID the ID of the div that will contain the map
|
31 |
-
* @param {String} kmlFile path to the KML file to load
|
32 |
-
* @param {Number} zoom [optional] zoom level
|
33 |
-
*/
|
34 |
-
showKML: function(divID, kmlFile, zoom) {
|
35 |
-
var map = this.showMap(divID, [0, 0]),
|
36 |
-
kmlLayer = new google.maps.KmlLayer(kmlFile);
|
37 |
-
|
38 |
-
kmlLayer.setMap(map);
|
39 |
-
|
40 |
-
if (typeof zoom != "undefined") {
|
41 |
-
// listen for KML loaded, and reset zoom
|
42 |
-
google.maps.event.addListenerOnce(map, 'tilesloaded', function() {
|
43 |
-
map.setZoom(zoom);
|
44 |
-
});
|
45 |
-
}
|
46 |
|
47 |
-
|
48 |
-
google.maps.event.addListener(kmlLayer, 'click', function(kmlEvent) {
|
49 |
-
kmlEvent.featureData.description = kmlEvent.featureData.description.replace(/ target="_blank"/ig, "");
|
50 |
-
});
|
51 |
-
},
|
52 |
-
|
53 |
-
/**
|
54 |
-
* show a map centred at latitude / longitude and with marker at latitude / longitude
|
55 |
-
* @param {String} divID the ID of the div that will contain the map
|
56 |
-
* @param {Array} centre an array of two integers: [ latitude, longitude ]
|
57 |
-
* @param {Array} marker an array of two integers: [ latitude, longitude ]
|
58 |
-
* @param {String} title the title for the marker
|
59 |
-
*/
|
60 |
-
showMarker: function(divID, centre, marker) {
|
61 |
-
var map = this.showMap(divID, centre),
|
62 |
-
point = new google.maps.Marker({
|
63 |
-
map: map,
|
64 |
-
position: new google.maps.LatLng(marker[0], marker[1])
|
65 |
-
});
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
-
|
75 |
-
element = document.createElement("DIV");
|
76 |
-
element.style.fontWeight = "bold";
|
77 |
-
element.style.fontSize = "medium";
|
78 |
-
element.appendChild(document.createTextNode(this.markerTitle));
|
79 |
-
container.appendChild(element);
|
80 |
|
81 |
-
|
82 |
-
if (this.markerDescription || this.markerLink) {
|
83 |
element = document.createElement("DIV");
|
84 |
-
element.style.
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
element.appendChild(document.createElement("BR"));
|
90 |
-
element.appendChild(document.createTextNode(lines[i]));
|
91 |
}
|
92 |
-
if (this.markerLink)
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
94 |
}
|
95 |
-
|
|
|
|
|
|
|
|
|
96 |
a = document.createElement("A");
|
97 |
-
a.href =
|
98 |
-
a.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
element.appendChild(a);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
}
|
101 |
-
container.appendChild(element);
|
102 |
-
}
|
103 |
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
element.style.fontSize = "small";
|
108 |
-
a = document.createElement("A");
|
109 |
-
a.href = " ";
|
110 |
-
a.dataLatitude = marker[0];
|
111 |
-
a.dataLongitude = marker[1];
|
112 |
-
a.dataTitle = this.markerTitle;
|
113 |
-
a.onclick = function(event) {
|
114 |
-
if (event.preventDefault)
|
115 |
-
event.preventDefault();
|
116 |
-
else
|
117 |
-
event.returnValue = false;
|
118 |
-
|
119 |
-
self.showDirections(this.dataLatitude, this.dataLongitude, this.dataTitle);
|
120 |
-
};
|
121 |
-
a.appendChild(document.createTextNode("Directions"));
|
122 |
-
element.appendChild(a);
|
123 |
-
container.appendChild(element);
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
}
|
135 |
|
136 |
-
|
137 |
-
|
138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
|
140 |
-
google.maps.event.addListener(point, "click", function() {
|
141 |
-
infowin.open(map, point);
|
142 |
});
|
|
|
143 |
}
|
144 |
-
},
|
145 |
-
|
146 |
-
/**
|
147 |
-
* show a map at specified centre latitude / longitude
|
148 |
-
* @param {String} divID the ID of the div that will contain the map
|
149 |
-
* @param {Array} centre an array of two integers: [ latitude, longitude ]
|
150 |
-
* @return {google.maps.Map} the Google Maps map created
|
151 |
-
*/
|
152 |
-
showMap: function(divID, centre) {
|
153 |
-
return new google.maps.Map(document.getElementById(divID), {
|
154 |
-
mapTypeId: this.mapTypeId,
|
155 |
-
mapTypeControl: this.mapTypeControl,
|
156 |
-
scaleControl: this.scaleControl,
|
157 |
-
scrollwheel: this.scrollwheel,
|
158 |
-
streetViewControl: this.streetViewControl,
|
159 |
-
navigationControlOptions: this.navigationControlOptions,
|
160 |
-
center: new google.maps.LatLng(centre[0], centre[1]),
|
161 |
-
zoom: this.zoom
|
162 |
-
});
|
163 |
-
},
|
164 |
-
|
165 |
-
/**
|
166 |
-
* show directions for specified latitude / longitude and title
|
167 |
-
* @param {Number} latitude
|
168 |
-
* @param {Number} longitude
|
169 |
-
* @param {String} title
|
170 |
-
*/
|
171 |
-
showDirections: function(latitude, longitude, title) {
|
172 |
-
var panel = document.getElementById(this.markerDirections),
|
173 |
-
form = document.createElement("form"),
|
174 |
-
self = this,
|
175 |
-
region = this.region || '',
|
176 |
-
input, p;
|
177 |
-
|
178 |
-
// remove all from panel
|
179 |
-
while (p = panel.lastChild)
|
180 |
-
panel.removeChild(p);
|
181 |
-
|
182 |
-
// create form and add to panel
|
183 |
-
p = document.createElement("p");
|
184 |
-
p.appendChild(document.createTextNode("From: "));
|
185 |
-
input = document.createElement("input");
|
186 |
-
input.type = "text";
|
187 |
-
input.name = "from";
|
188 |
-
p.appendChild(input);
|
189 |
-
input = document.createElement("input");
|
190 |
-
input.type = "submit";
|
191 |
-
input.value = "Get directions";
|
192 |
-
p.appendChild(input);
|
193 |
-
form.appendChild(p);
|
194 |
-
panel.appendChild(form);
|
195 |
-
form.elements.from.focus();
|
196 |
-
|
197 |
-
// handle the form submit
|
198 |
-
form.onsubmit = function(event) {
|
199 |
-
if (event.preventDefault)
|
200 |
-
event.preventDefault();
|
201 |
-
else
|
202 |
-
event.returnValue = false;
|
203 |
-
|
204 |
-
var from = this.elements.from.value;
|
205 |
-
|
206 |
-
// only process if something was entered to search on
|
207 |
-
if (/\S/.test(from)) {
|
208 |
-
var request = {
|
209 |
-
origin: from,
|
210 |
-
region: region,
|
211 |
-
destination: new google.maps.LatLng(latitude, longitude),
|
212 |
-
travelMode: google.maps.DirectionsTravelMode.DRIVING
|
213 |
-
};
|
214 |
-
self.dirService.route(request, function(response, status) {
|
215 |
-
var DirectionsStatus = google.maps.DirectionsStatus;
|
216 |
-
|
217 |
-
switch (status) {
|
218 |
-
case DirectionsStatus.OK:
|
219 |
-
self.dirPanel.setDirections(response);
|
220 |
-
break;
|
221 |
-
|
222 |
-
case DirectionsStatus.ZERO_RESULTS:
|
223 |
-
alert("No route could be found between the origin and destination.");
|
224 |
-
break;
|
225 |
-
|
226 |
-
case DirectionsStatus.OVER_QUERY_LIMIT:
|
227 |
-
alert("The webpage has gone over the requests limit in too short a period of time.");
|
228 |
-
break;
|
229 |
-
|
230 |
-
case DirectionsStatus.REQUEST_DENIED:
|
231 |
-
alert("The webpage is not allowed to use the directions service.");
|
232 |
-
break;
|
233 |
-
|
234 |
-
case DirectionsStatus.INVALID_REQUEST:
|
235 |
-
alert("Invalid directions request.");
|
236 |
-
break;
|
237 |
-
|
238 |
-
case DirectionsStatus.NOT_FOUND:
|
239 |
-
alert("Origin or destination was not found.");
|
240 |
-
break;
|
241 |
-
|
242 |
-
default:
|
243 |
-
alert("A directions request could not be processed due to a server error. The request may succeed if you try again.");
|
244 |
-
break;
|
245 |
-
}
|
246 |
-
});
|
247 |
-
}
|
248 |
-
};
|
249 |
|
250 |
-
}
|
251 |
|
252 |
-
};
|
1 |
/*!
|
2 |
JavaScript for the WordPress plugin wp-flexible-map
|
3 |
+
copyright (c) 2011-2012 WebAware Pty Ltd, released under LGPL v2.1
|
4 |
*/
|
5 |
|
6 |
function FlexibleMap() {
|
22 |
this.region = false;
|
23 |
}
|
24 |
|
25 |
+
FlexibleMap.prototype = (function() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
+
var addEventListener, stopEvent;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
+
// detect standard event model
|
30 |
+
if (document.addEventListener) {
|
31 |
+
addEventListener = function(element, eventName, hook) { element.addEventListener(eventName, hook, false); };
|
32 |
+
stopEvent = function(event) { event.stopPropagation(); event.preventDefault(); };
|
33 |
+
}
|
34 |
+
else
|
35 |
+
// detect IE event model
|
36 |
+
if (document.attachEvent) {
|
37 |
+
addEventListener = function(element, event, hook) { element.attachEvent("on" + event, function() { hook.call(element, window.event); }); };
|
38 |
+
stopEvent = function(event) { event.cancelBubble = true; event.returnValue = 0; };
|
39 |
+
}
|
40 |
+
|
41 |
+
return {
|
42 |
+
constructor: FlexibleMap,
|
43 |
+
|
44 |
+
/**
|
45 |
+
* show a map based on a KML file
|
46 |
+
* @param {String} divID the ID of the div that will contain the map
|
47 |
+
* @param {String} kmlFile path to the KML file to load
|
48 |
+
* @param {Number} zoom [optional] zoom level
|
49 |
+
*/
|
50 |
+
showKML: function(divID, kmlFile, zoom) {
|
51 |
+
var map = this.showMap(divID, [0, 0]),
|
52 |
+
kmlLayer = new google.maps.KmlLayer(kmlFile);
|
53 |
+
|
54 |
+
kmlLayer.setMap(map);
|
55 |
+
|
56 |
+
if (typeof zoom != "undefined") {
|
57 |
+
// listen for KML loaded, and reset zoom
|
58 |
+
google.maps.event.addListenerOnce(map, 'tilesloaded', function() {
|
59 |
+
map.setZoom(zoom);
|
60 |
+
});
|
61 |
+
}
|
62 |
|
63 |
+
// stop links opening in a new window (thanks, Stack Overflow!)
|
64 |
+
google.maps.event.addListener(kmlLayer, 'click', function(kmlEvent) {
|
65 |
+
kmlEvent.featureData.description = kmlEvent.featureData.description.replace(/ target="_blank"/ig, "");
|
66 |
+
});
|
67 |
+
},
|
68 |
+
|
69 |
+
/**
|
70 |
+
* show a map centred at latitude / longitude and with marker at latitude / longitude
|
71 |
+
* @param {String} divID the ID of the div that will contain the map
|
72 |
+
* @param {Array} centre an array of two integers: [ latitude, longitude ]
|
73 |
+
* @param {Array} marker an array of two integers: [ latitude, longitude ]
|
74 |
+
* @param {String} title the title for the marker
|
75 |
+
*/
|
76 |
+
showMarker: function(divID, centre, marker) {
|
77 |
+
var map = this.showMap(divID, centre),
|
78 |
+
point = new google.maps.Marker({
|
79 |
+
map: map,
|
80 |
+
position: new google.maps.LatLng(marker[0], marker[1])
|
81 |
+
});
|
82 |
+
|
83 |
+
if (this.markerTitle) {
|
84 |
+
var i, len, lines, infowin, element, a,
|
85 |
+
self = this,
|
86 |
+
container = document.createElement("DIV");
|
87 |
|
88 |
+
container.style.fontFamily = "Arial,Helvetica,sans-serif";
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
+
// heading for info window
|
|
|
91 |
element = document.createElement("DIV");
|
92 |
+
element.style.fontWeight = "bold";
|
93 |
+
element.style.fontSize = "medium";
|
94 |
+
element.appendChild(document.createTextNode(this.markerTitle));
|
95 |
+
container.appendChild(element);
|
96 |
+
|
97 |
+
// body of info window, with link
|
98 |
+
if (this.markerDescription || this.markerLink) {
|
99 |
+
element = document.createElement("DIV");
|
100 |
+
element.style.fontSize = "small";
|
101 |
+
if (this.markerDescription) {
|
102 |
+
lines = this.markerDescription.split("\n");
|
103 |
+
for (i = 0, len = lines.length; i < len; i++) {
|
104 |
+
if (i > 0)
|
105 |
+
element.appendChild(document.createElement("BR"));
|
106 |
+
element.appendChild(document.createTextNode(lines[i]));
|
107 |
+
}
|
108 |
+
if (this.markerLink)
|
109 |
element.appendChild(document.createElement("BR"));
|
|
|
110 |
}
|
111 |
+
if (this.markerLink) {
|
112 |
+
a = document.createElement("A");
|
113 |
+
a.href = this.markerLink;
|
114 |
+
a.appendChild(document.createTextNode("Click for details"));
|
115 |
+
element.appendChild(a);
|
116 |
+
}
|
117 |
+
container.appendChild(element);
|
118 |
}
|
119 |
+
|
120 |
+
// add a link for directions if wanted
|
121 |
+
if (this.markerDirections) {
|
122 |
+
element = document.createElement("DIV");
|
123 |
+
element.style.fontSize = "small";
|
124 |
a = document.createElement("A");
|
125 |
+
a.href = "#";
|
126 |
+
a.dataLatitude = marker[0];
|
127 |
+
a.dataLongitude = marker[1];
|
128 |
+
a.dataTitle = this.markerTitle;
|
129 |
+
addEventListener(a, "click", function(event) {
|
130 |
+
stopEvent(event);
|
131 |
+
self.showDirections(this.dataLatitude, this.dataLongitude, this.dataTitle);
|
132 |
+
});
|
133 |
+
a.appendChild(document.createTextNode("Directions"));
|
134 |
element.appendChild(a);
|
135 |
+
container.appendChild(element);
|
136 |
+
|
137 |
+
// make sure we have a directions service
|
138 |
+
if (!this.dirService)
|
139 |
+
this.dirService = new google.maps.DirectionsService();
|
140 |
+
if (!this.dirPanel) {
|
141 |
+
this.dirPanel = new google.maps.DirectionsRenderer({
|
142 |
+
map: map,
|
143 |
+
panel: document.getElementById(this.markerDirections)
|
144 |
+
});
|
145 |
+
}
|
146 |
}
|
|
|
|
|
147 |
|
148 |
+
infowin = new google.maps.InfoWindow({content: container});
|
149 |
+
if (this.markerShowInfo)
|
150 |
+
infowin.open(map, point);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
+
google.maps.event.addListener(point, "click", function() {
|
153 |
+
infowin.open(map, point);
|
154 |
+
});
|
155 |
+
}
|
156 |
+
},
|
157 |
+
|
158 |
+
/**
|
159 |
+
* show a map at specified centre latitude / longitude
|
160 |
+
* @param {String} divID the ID of the div that will contain the map
|
161 |
+
* @param {Array} centre an array of two integers: [ latitude, longitude ]
|
162 |
+
* @return {google.maps.Map} the Google Maps map created
|
163 |
+
*/
|
164 |
+
showMap: function(divID, centre) {
|
165 |
+
return new google.maps.Map(document.getElementById(divID), {
|
166 |
+
mapTypeId: this.mapTypeId,
|
167 |
+
mapTypeControl: this.mapTypeControl,
|
168 |
+
scaleControl: this.scaleControl,
|
169 |
+
scrollwheel: this.scrollwheel,
|
170 |
+
streetViewControl: this.streetViewControl,
|
171 |
+
navigationControlOptions: this.navigationControlOptions,
|
172 |
+
center: new google.maps.LatLng(centre[0], centre[1]),
|
173 |
+
zoom: this.zoom
|
174 |
+
});
|
175 |
+
},
|
176 |
+
|
177 |
+
/**
|
178 |
+
* show directions for specified latitude / longitude and title
|
179 |
+
* @param {Number} latitude
|
180 |
+
* @param {Number} longitude
|
181 |
+
* @param {String} title
|
182 |
+
*/
|
183 |
+
showDirections: function(latitude, longitude, title) {
|
184 |
+
var panel = document.getElementById(this.markerDirections),
|
185 |
+
form = document.createElement("form"),
|
186 |
+
self = this,
|
187 |
+
region = this.region || '',
|
188 |
+
input, p, from;
|
189 |
+
|
190 |
+
// remove all from panel
|
191 |
+
while (!!(p = panel.lastChild))
|
192 |
+
panel.removeChild(p);
|
193 |
+
|
194 |
+
// populate form and add to panel
|
195 |
+
p = document.createElement("p");
|
196 |
+
p.appendChild(document.createTextNode("From: "));
|
197 |
+
from = document.createElement("input");
|
198 |
+
from.type = "text";
|
199 |
+
from.name = "from";
|
200 |
+
p.appendChild(from);
|
201 |
+
input = document.createElement("input");
|
202 |
+
input.type = "submit";
|
203 |
+
input.value = "Get directions";
|
204 |
+
p.appendChild(input);
|
205 |
+
form.appendChild(p);
|
206 |
+
panel.appendChild(form);
|
207 |
+
from.focus();
|
208 |
+
|
209 |
+
// hack to fix IE<=7 name weirdness for dynamically created form elements;
|
210 |
+
// see http://msdn.microsoft.com/en-us/library/ms534184.aspx but have a hanky ready
|
211 |
+
if (typeof form.elements.from == "undefined") {
|
212 |
+
form.elements.from = from;
|
213 |
}
|
214 |
|
215 |
+
// handle the form submit
|
216 |
+
addEventListener(form, "submit", function(event) {
|
217 |
+
stopEvent(event);
|
218 |
+
|
219 |
+
var from = this.elements.from.value;
|
220 |
+
|
221 |
+
// only process if something was entered to search on
|
222 |
+
if (/\S/.test(from)) {
|
223 |
+
var request = {
|
224 |
+
origin: from,
|
225 |
+
region: region,
|
226 |
+
destination: new google.maps.LatLng(latitude, longitude),
|
227 |
+
travelMode: google.maps.DirectionsTravelMode.DRIVING
|
228 |
+
};
|
229 |
+
self.dirService.route(request, function(response, status) {
|
230 |
+
var DirectionsStatus = google.maps.DirectionsStatus;
|
231 |
+
|
232 |
+
switch (status) {
|
233 |
+
case DirectionsStatus.OK:
|
234 |
+
self.dirPanel.setDirections(response);
|
235 |
+
break;
|
236 |
+
|
237 |
+
case DirectionsStatus.ZERO_RESULTS:
|
238 |
+
alert("No route could be found between the origin and destination.");
|
239 |
+
break;
|
240 |
+
|
241 |
+
case DirectionsStatus.OVER_QUERY_LIMIT:
|
242 |
+
alert("The webpage has gone over the requests limit in too short a period of time.");
|
243 |
+
break;
|
244 |
+
|
245 |
+
case DirectionsStatus.REQUEST_DENIED:
|
246 |
+
alert("The webpage is not allowed to use the directions service.");
|
247 |
+
break;
|
248 |
+
|
249 |
+
case DirectionsStatus.INVALID_REQUEST:
|
250 |
+
alert("Invalid directions request.");
|
251 |
+
break;
|
252 |
+
|
253 |
+
case DirectionsStatus.NOT_FOUND:
|
254 |
+
alert("Origin or destination was not found.");
|
255 |
+
break;
|
256 |
+
|
257 |
+
default:
|
258 |
+
alert("A directions request could not be processed due to a server error. The request may succeed if you try again.");
|
259 |
+
break;
|
260 |
+
}
|
261 |
+
});
|
262 |
+
}
|
263 |
|
|
|
|
|
264 |
});
|
265 |
+
|
266 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
|
268 |
+
};
|
269 |
|
270 |
+
})();
|
flexible-map.min.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/*!
|
2 |
JavaScript for the WordPress plugin wp-flexible-map
|
3 |
-
|
4 |
*/
|
5 |
-
function FlexibleMap(){this.mapTypeId=google.maps.MapTypeId.ROADMAP;this.mapTypeControl=false;this.scaleControl=false;this.streetViewControl=false;this.scrollwheel=false;this.zoom=16;this.markerTitle="";this.markerDescription="";this.markerLink="";this.markerShowInfo=true;this.markerDirections=false;this.navigationControlOptions={style:google.maps.NavigationControlStyle.SMALL};this.dirService=false;this.dirPanel=false;this.region=false}FlexibleMap.prototype={constructor:FlexibleMap,showKML:function(
|
1 |
/*!
|
2 |
JavaScript for the WordPress plugin wp-flexible-map
|
3 |
+
copyright (c) 2011-2012 WebAware Pty Ltd, released under LGPL v2.1
|
4 |
*/
|
5 |
+
function FlexibleMap(){this.mapTypeId=google.maps.MapTypeId.ROADMAP;this.mapTypeControl=false;this.scaleControl=false;this.streetViewControl=false;this.scrollwheel=false;this.zoom=16;this.markerTitle="";this.markerDescription="";this.markerLink="";this.markerShowInfo=true;this.markerDirections=false;this.navigationControlOptions={style:google.maps.NavigationControlStyle.SMALL};this.dirService=false;this.dirPanel=false;this.region=false}FlexibleMap.prototype=(function(){var b,a;if(document.addEventListener){b=function(d,c,e){d.addEventListener(c,e,false)};a=function(c){c.stopPropagation();c.preventDefault()}}else{if(document.attachEvent){b=function(c,d,e){c.attachEvent("on"+d,function(){e.call(c,window.event)})};a=function(c){c.cancelBubble=true;c.returnValue=0}}}return{constructor:FlexibleMap,showKML:function(c,g,d){var f=this.showMap(c,[0,0]),e=new google.maps.KmlLayer(g);e.setMap(f);if(typeof d!="undefined"){google.maps.event.addListenerOnce(f,"tilesloaded",function(){f.setZoom(d)})}google.maps.event.addListener(e,"click",function(h){h.featureData.description=h.featureData.description.replace(/ target="_blank"/ig,"")})},showMarker:function(f,e,k){var d=this.showMap(f,e),n=new google.maps.Marker({map:d,position:new google.maps.LatLng(k[0],k[1])});if(this.markerTitle){var j,l,p,g,h,m,o=this,c=document.createElement("DIV");c.style.fontFamily="Arial,Helvetica,sans-serif";h=document.createElement("DIV");h.style.fontWeight="bold";h.style.fontSize="medium";h.appendChild(document.createTextNode(this.markerTitle));c.appendChild(h);if(this.markerDescription||this.markerLink){h=document.createElement("DIV");h.style.fontSize="small";if(this.markerDescription){p=this.markerDescription.split("\n");for(j=0,l=p.length;j<l;j++){if(j>0){h.appendChild(document.createElement("BR"))}h.appendChild(document.createTextNode(p[j]))}if(this.markerLink){h.appendChild(document.createElement("BR"))}}if(this.markerLink){m=document.createElement("A");m.href=this.markerLink;m.appendChild(document.createTextNode("Click for details"));h.appendChild(m)}c.appendChild(h)}if(this.markerDirections){h=document.createElement("DIV");h.style.fontSize="small";m=document.createElement("A");m.href="#";m.dataLatitude=k[0];m.dataLongitude=k[1];m.dataTitle=this.markerTitle;b(m,"click",function(i){a(i);o.showDirections(this.dataLatitude,this.dataLongitude,this.dataTitle)});m.appendChild(document.createTextNode("Directions"));h.appendChild(m);c.appendChild(h);if(!this.dirService){this.dirService=new google.maps.DirectionsService()}if(!this.dirPanel){this.dirPanel=new google.maps.DirectionsRenderer({map:d,panel:document.getElementById(this.markerDirections)})}}g=new google.maps.InfoWindow({content:c});if(this.markerShowInfo){g.open(d,n)}google.maps.event.addListener(n,"click",function(){g.open(d,n)})}},showMap:function(c,d){return new google.maps.Map(document.getElementById(c),{mapTypeId:this.mapTypeId,mapTypeControl:this.mapTypeControl,scaleControl:this.scaleControl,scrollwheel:this.scrollwheel,streetViewControl:this.streetViewControl,navigationControlOptions:this.navigationControlOptions,center:new google.maps.LatLng(d[0],d[1]),zoom:this.zoom})},showDirections:function(g,c,i){var d=document.getElementById(this.markerDirections),f=document.createElement("form"),l=this,h=this.region||"",j,e,k;while(!!(e=d.lastChild)){d.removeChild(e)}e=document.createElement("p");e.appendChild(document.createTextNode("From: "));k=document.createElement("input");k.type="text";k.name="from";e.appendChild(k);j=document.createElement("input");j.type="submit";j.value="Get directions";e.appendChild(j);f.appendChild(e);d.appendChild(f);k.focus();if(typeof f.elements.from=="undefined"){f.elements.from=k}b(f,"submit",function(n){a(n);var o=this.elements.from.value;if(/\S/.test(o)){var m={origin:o,region:h,destination:new google.maps.LatLng(g,c),travelMode:google.maps.DirectionsTravelMode.DRIVING};l.dirService.route(m,function(r,p){var q=google.maps.DirectionsStatus;switch(p){case q.OK:l.dirPanel.setDirections(r);break;case q.ZERO_RESULTS:alert("No route could be found between the origin and destination.");break;case q.OVER_QUERY_LIMIT:alert("The webpage has gone over the requests limit in too short a period of time.");break;case q.REQUEST_DENIED:alert("The webpage is not allowed to use the directions service.");break;case q.INVALID_REQUEST:alert("Invalid directions request.");break;case q.NOT_FOUND:alert("Origin or destination was not found.");break;default:alert("A directions request could not be processed due to a server error. The request may succeed if you try again.");break}})}})}}})();
|
flexible-map.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Flexible Map
|
4 |
Plugin URI: http://snippets.webaware.com.au/wordpress-plugins/wp-flexible-map/
|
5 |
Description: Flexible map using Google Maps, for displaying a map specified by centre coodinates or by Google Earth KML file.
|
6 |
-
Version: 1.0.
|
7 |
Author: WebAware Pty Ltd
|
8 |
Author URI: http://www.webaware.com.au/
|
9 |
*/
|
3 |
Plugin Name: Flexible Map
|
4 |
Plugin URI: http://snippets.webaware.com.au/wordpress-plugins/wp-flexible-map/
|
5 |
Description: Flexible map using Google Maps, for displaying a map specified by centre coodinates or by Google Earth KML file.
|
6 |
+
Version: 1.0.1
|
7 |
Author: WebAware Pty Ltd
|
8 |
Author URI: http://www.webaware.com.au/
|
9 |
*/
|
readme.txt
CHANGED
@@ -6,17 +6,30 @@ Author URI: http://www.webaware.com.au/
|
|
6 |
Tags: google, maps, shortcode, kml
|
7 |
Requires at least: 3.0.1
|
8 |
Tested up to: 3.3.1
|
9 |
-
Stable tag: 1.0.
|
10 |
|
11 |
Flexible map using Google Maps, for displaying a map specified by centre coodinates or by Google Earth KML file.
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
Flexible
|
|
|
|
|
16 |
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
|
|
|
|
|
20 |
|
21 |
**Parameters for centre coordinates map:**
|
22 |
|
@@ -66,7 +79,25 @@ To add a Flexible Map to a post or a page, add a shortcode [flexiblemap] and giv
|
|
66 |
*Sample*:
|
67 |
`[flexiblemap src="http://code.google.com/apis/kml/documentation/KML_Samples.kml" width="500" height="400"]`
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
== Changelog ==
|
70 |
|
|
|
|
|
|
|
71 |
= 1.0.0 [2012-01-08] =
|
72 |
* final cleanup for public release
|
6 |
Tags: google, maps, shortcode, kml
|
7 |
Requires at least: 3.0.1
|
8 |
Tested up to: 3.3.1
|
9 |
+
Stable tag: 1.0.1
|
10 |
|
11 |
Flexible map using Google Maps, for displaying a map specified by centre coodinates or by Google Earth KML file.
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
Flexible Map allows you to add Google Maps to your WordPress website.
|
16 |
+
|
17 |
+
**Features:**
|
18 |
|
19 |
+
* specify map by centre coordinates
|
20 |
+
* load map from Google Earth KML file
|
21 |
+
* no special Google Maps key is required -- uses the latest stable Google Maps API
|
22 |
+
* simple shortcode for adding maps to pages/posts
|
23 |
+
* PHP function `flexmap_show_map()` for theme and plugin developers
|
24 |
+
* supports multiple maps on a page/post
|
25 |
+
* map marker doesn't have to be the centre of the map
|
26 |
+
* optional description for info window
|
27 |
+
* optional directions link for info window
|
28 |
+
* directions can be dropped into any div element with an ID
|
29 |
|
30 |
+
== Installation ==
|
31 |
+
|
32 |
+
To add a Flexible Map to a post or a page, add a shortcode [flexiblemap] and give it some useful parameters. A map can either be specified using centre coordinates, or by loading a KML file.
|
33 |
|
34 |
**Parameters for centre coordinates map:**
|
35 |
|
79 |
*Sample*:
|
80 |
`[flexiblemap src="http://code.google.com/apis/kml/documentation/KML_Samples.kml" width="500" height="400"]`
|
81 |
|
82 |
+
**Calling from templates or plugins**
|
83 |
+
|
84 |
+
There is a PHP function `flexmap_show_map()` for theme and plugin developers. All of the same parameters for the shortcode can be passed to the function in an associative array.
|
85 |
+
|
86 |
+
*Sample*:
|
87 |
+
`flexmap_show_map(array(
|
88 |
+
'center' => '-34.916721,138.828878',
|
89 |
+
'width' => 500,
|
90 |
+
'height' => 400,
|
91 |
+
'zoom' => 12,
|
92 |
+
'title' => 'Adelaide Hills',
|
93 |
+
'description' => 'The Adelaide Hills are repleat with wineries.',
|
94 |
+
'directions' => 'my-dir-div',
|
95 |
+
));`
|
96 |
+
|
97 |
== Changelog ==
|
98 |
|
99 |
+
= 1.0.1 [2012-01-26] =
|
100 |
+
* fix directions bugs in JavaScript for Opera, IE
|
101 |
+
|
102 |
= 1.0.0 [2012-01-08] =
|
103 |
* final cleanup for public release
|