Simple Map - Version 2.7.0

Version Description

  • UPdate gmaps.js to 0.4.21
  • Add tests on travis

https://github.com/miya0001/simple-map/compare/2.6.0...2.7.0

Download this release

Release Info

Developer miyauchi
Plugin Icon wp plugin Simple Map
Version 2.7.0
Comparing to
See all releases

Version 2.7.0

Files changed (5) hide show
  1. .svnignore +18 -0
  2. js/simple-map.js +104 -0
  3. js/simple-map.min.js +14 -0
  4. readme.txt +215 -0
  5. simple-map.php +168 -0
.svnignore ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .DS_Store
2
+ .git
3
+ .gitignore
4
+ .travis.yml
5
+ Gruntfile.js
6
+ LINGUAS
7
+ Makefile
8
+ README.md
9
+ _site
10
+ bin
11
+ composer.json
12
+ composer.lock
13
+ node_modules
14
+ npm-debug.log
15
+ package.json
16
+ phpunit.xml
17
+ tests
18
+ vendor
js/simple-map.js ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function($){
2
+
3
+ var SimpleMap = function(element, pos, zoom, infoCont) {
4
+ this.base_url = 'https://maps.google.com/maps?';
5
+ this.display(element, pos, zoom, infoCont);
6
+ }
7
+
8
+ SimpleMap.prototype.display = function(element, pos, zoom, infoCont) {
9
+ $(element).show();
10
+ var breakpoint = $(element).data('breakpoint');
11
+ if (breakpoint > 640) {
12
+ breakpoint = 640;
13
+ }
14
+ if ($('html').width() > breakpoint) {
15
+ var map = new GMaps({
16
+ div: element,
17
+ lat: pos.lat(),
18
+ lng: pos.lng(),
19
+ mapTypeControl: false,
20
+ zoom: parseFloat(zoom),
21
+ streetViewControl: false,
22
+ scrollwheel: false,
23
+ mapTypeId: google.maps.MapTypeId.ROADMAP
24
+ });
25
+ if (infoCont.length) {
26
+ var marker = map.addMarker({
27
+ lat: pos.lat(),
28
+ lng: pos.lng(),
29
+ infoWindow: {
30
+ content: infoCont
31
+ }
32
+ });
33
+ if ($(element).data('infowindow') == 'open') {
34
+ marker.infoWindow.open(marker.map, marker);
35
+ }
36
+ } else {
37
+ map.addMarker({
38
+ lat: pos.lat(),
39
+ lng: pos.lng()
40
+ });
41
+ }
42
+ } else {
43
+ var url = GMaps.staticMapURL({
44
+ center: pos.lat()+','+pos.lng(),
45
+ zoom: zoom,
46
+ size: breakpoint+'x'+$(element).height(),
47
+ markers: [
48
+ {lat: pos.lat(), lng: pos.lng()}
49
+ ],
50
+ sensor: 'false'
51
+ });
52
+ var img = $('<img />');
53
+ $(img).attr('src', url);
54
+ $(img).attr('alt', $(element).text());
55
+ var a = $('<a />');
56
+ $(a).attr(
57
+ 'href',
58
+ this.base_url+'q='+pos.lat()+','+pos.lng()+'&z='+zoom
59
+ );
60
+ $(a).html(img);
61
+ $(element).html(a);
62
+ $(element).addClass('staticmap');
63
+ }
64
+ }
65
+
66
+ $('.simplemap').each(function(){
67
+ var element = $('div', this).get(0);
68
+ var zoom = 16;
69
+ if (parseFloat($(element).data('zoom'))) {
70
+ zoom = $(element).data('zoom');
71
+ }
72
+ if ($(element).data('lat') && $(element).data('lng')) {
73
+ var lat = $(element).data('lat');
74
+ var lng = $(element).data('lng');
75
+ var infoCont = $(element).html();
76
+ var pos = new google.maps.LatLng(
77
+ lat,
78
+ lng
79
+ );
80
+ new SimpleMap(element, pos, zoom, infoCont);
81
+ } else if ($(element).data('addr')) {
82
+ GMaps.geocode({
83
+ address: $(element).data('addr'),
84
+ callback: function(results, status) {
85
+ if (status == 'OK') {
86
+ var pos = results[0].geometry.location;
87
+ new SimpleMap(element, pos, zoom, $(element).html());
88
+ }
89
+ }
90
+ });
91
+ } else if ($(element).text().length) {
92
+ GMaps.geocode({
93
+ address: $(element).text(),
94
+ callback: function(results, status) {
95
+ if (status == 'OK') {
96
+ var pos = results[0].geometry.location;
97
+ new SimpleMap(element, pos, zoom, $(element).text());
98
+ }
99
+ }
100
+ });
101
+ }
102
+ });
103
+
104
+ })(jQuery);
js/simple-map.min.js ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Simple Map - v2.7.0
3
+ *
4
+ * http://wordpress.org/plugins/simple-map/
5
+ * https://github.com/miya0001/simple-map
6
+ *
7
+ * Special thanks!
8
+ * http://hpneo.github.io/gmaps/
9
+ *
10
+ * Copyright 2015, Takayuki Miyauchi (http://wpist.me/)
11
+ * Released under the GPLv2
12
+ */
13
+ "use strict";!function(a,b){"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define(["jquery","googlemaps!"],b):a.GMaps=b()}(this,function(){var a=function(a,b){var c;if(a===b)return a;for(c in b)a[c]=b[c];return a},b=function(a,b){var c,d=Array.prototype.slice.call(arguments,2),e=[],f=a.length;if(Array.prototype.map&&a.map===Array.prototype.map)e=Array.prototype.map.call(a,function(a){var c=d.slice(0);return c.splice(0,0,a),b.apply(this,c)});else for(c=0;f>c;c++)callback_params=d,callback_params.splice(0,0,a[c]),e.push(b.apply(this,callback_params));return e},c=function(a){var b,c=[];for(b=0;b<a.length;b++)c=c.concat(a[b]);return c},d=function(a,b){var c=a[0],d=a[1];return b&&(c=a[1],d=a[0]),new google.maps.LatLng(c,d)},f=function(a,b){var c;for(c=0;c<a.length;c++)a[c]instanceof google.maps.LatLng||(a[c].length>0&&"object"==typeof a[c][0]?a[c]=f(a[c],b):a[c]=d(a[c],b));return a},g=function(a,b){var c,d=a.replace(".","");return c="jQuery"in this&&b?$("."+d,b)[0]:document.getElementsByClassName(d)[0]},h=function(a,b){var c,a=a.replace("#","");return c="jQuery"in window&&b?$("#"+a,b)[0]:document.getElementById(a)},i=function(a){var b=0,c=0;if(a.offsetParent)do b+=a.offsetLeft,c+=a.offsetTop;while(a=a.offsetParent);return[b,c]},j=function(b){if("object"!=typeof window.google||!window.google.maps)return"object"==typeof window.console&&window.console.error,function(){};var c=document,d=function(b){if(!this)return new d(b);b.zoom=b.zoom||15,b.mapType=b.mapType||"roadmap";var e,f=function(a,b){return void 0===a?b:a},j=this,k=["bounds_changed","center_changed","click","dblclick","drag","dragend","dragstart","idle","maptypeid_changed","projection_changed","resize","tilesloaded","zoom_changed"],l=["mousemove","mouseout","mouseover"],m=["el","lat","lng","mapType","width","height","markerClusterer","enableNewStyle"],n=b.el||b.div,o=b.markerClusterer,p=google.maps.MapTypeId[b.mapType.toUpperCase()],q=new google.maps.LatLng(b.lat,b.lng),r=f(b.zoomControl,!0),s=b.zoomControlOpt||{style:"DEFAULT",position:"TOP_LEFT"},t=s.style||"DEFAULT",u=s.position||"TOP_LEFT",v=f(b.panControl,!0),w=f(b.mapTypeControl,!0),x=f(b.scaleControl,!0),y=f(b.streetViewControl,!0),z=f(z,!0),A={},B={zoom:this.zoom,center:q,mapTypeId:p},C={panControl:v,zoomControl:r,zoomControlOptions:{style:google.maps.ZoomControlStyle[t],position:google.maps.ControlPosition[u]},mapTypeControl:w,scaleControl:x,streetViewControl:y,overviewMapControl:z};if("string"==typeof b.el||"string"==typeof b.div?n.indexOf("#")>-1?this.el=h(n,b.context):this.el=g.apply(this,[n,b.context]):this.el=n,"undefined"==typeof this.el||null===this.el)throw"No element defined.";for(window.context_menu=window.context_menu||{},window.context_menu[j.el.id]={},this.controls=[],this.overlays=[],this.layers=[],this.singleLayers={},this.markers=[],this.polylines=[],this.routes=[],this.polygons=[],this.infoWindow=null,this.overlay_el=null,this.zoom=b.zoom,this.registered_events={},this.el.style.width=b.width||this.el.scrollWidth||this.el.offsetWidth,this.el.style.height=b.height||this.el.scrollHeight||this.el.offsetHeight,google.maps.visualRefresh=b.enableNewStyle,e=0;e<m.length;e++)delete b[m[e]];for(1!=b.disableDefaultUI&&(B=a(B,C)),A=a(B,b),e=0;e<k.length;e++)delete A[k[e]];for(e=0;e<l.length;e++)delete A[l[e]];this.map=new google.maps.Map(this.el,A),o&&(this.markerClusterer=o.apply(this,[this.map]));var D=function(a,b){var c="",d=window.context_menu[j.el.id][a];for(var e in d)if(d.hasOwnProperty(e)){var f=d[e];c+='<li><a id="'+a+"_"+e+'" href="#">'+f.title+"</a></li>"}if(h("gmaps_context_menu")){var g=h("gmaps_context_menu");g.innerHTML=c;var e,k=g.getElementsByTagName("a"),l=k.length;for(e=0;l>e;e++){var m=k[e],n=function(c){c.preventDefault(),d[this.id.replace(a+"_","")].action.apply(j,[b]),j.hideContextMenu()};google.maps.event.clearListeners(m,"click"),google.maps.event.addDomListenerOnce(m,"click",n,!1)}var o=i.apply(this,[j.el]),p=o[0]+b.pixel.x-15,q=o[1]+b.pixel.y-15;g.style.left=p+"px",g.style.top=q+"px"}};this.buildContextMenu=function(a,b){if("marker"===a){b.pixel={};var c=new google.maps.OverlayView;c.setMap(j.map),c.draw=function(){var d=c.getProjection(),e=b.marker.getPosition();b.pixel=d.fromLatLngToContainerPixel(e),D(a,b)}}else D(a,b);var d=h("gmaps_context_menu");setTimeout(function(){d.style.display="block"},0)},this.setContextMenu=function(a){window.context_menu[j.el.id][a.control]={};var b,d=c.createElement("ul");for(b in a.options)if(a.options.hasOwnProperty(b)){var e=a.options[b];window.context_menu[j.el.id][a.control][e.name]={title:e.title,action:e.action}}d.id="gmaps_context_menu",d.style.display="none",d.style.position="absolute",d.style.minWidth="100px",d.style.background="white",d.style.listStyle="none",d.style.padding="8px",d.style.boxShadow="2px 2px 6px #ccc",h("gmaps_context_menu")||c.body.appendChild(d);var f=h("gmaps_context_menu");google.maps.event.addDomListener(f,"mouseout",function(a){a.relatedTarget&&this.contains(a.relatedTarget)||window.setTimeout(function(){f.style.display="none"},400)},!1)},this.hideContextMenu=function(){var a=h("gmaps_context_menu");a&&(a.style.display="none")};var E=function(a,c){google.maps.event.addListener(a,c,function(a){void 0==a&&(a=this),b[c].apply(this,[a]),j.hideContextMenu()})};google.maps.event.addListener(this.map,"zoom_changed",this.hideContextMenu);for(var F=0;F<k.length;F++){var G=k[F];G in b&&E(this.map,G)}for(var F=0;F<l.length;F++){var G=l[F];G in b&&E(this.map,G)}google.maps.event.addListener(this.map,"rightclick",function(a){b.rightclick&&b.rightclick.apply(this,[a]),void 0!=window.context_menu[j.el.id].map&&j.buildContextMenu("map",a)}),this.refresh=function(){google.maps.event.trigger(this.map,"resize")},this.fitZoom=function(){var a,b=[],c=this.markers.length;for(a=0;c>a;a++)"boolean"==typeof this.markers[a].visible&&this.markers[a].visible&&b.push(this.markers[a].getPosition());this.fitLatLngBounds(b)},this.fitLatLngBounds=function(a){var b,c=a.length,d=new google.maps.LatLngBounds;for(b=0;c>b;b++)d.extend(a[b]);this.map.fitBounds(d)},this.setCenter=function(a,b,c){this.map.panTo(new google.maps.LatLng(a,b)),c&&c()},this.getElement=function(){return this.el},this.zoomIn=function(a){a=a||1,this.zoom=this.map.getZoom()+a,this.map.setZoom(this.zoom)},this.zoomOut=function(a){a=a||1,this.zoom=this.map.getZoom()-a,this.map.setZoom(this.zoom)};var H,I=[];for(H in this.map)"function"!=typeof this.map[H]||this[H]||I.push(H);for(e=0;e<I.length;e++)!function(a,b,c){a[c]=function(){return b[c].apply(b,arguments)}}(this,this.map,I[e])};return d}(this);j.prototype.createControl=function(a){var b=document.createElement("div");b.style.cursor="pointer",a.disableDefaultStyles!==!0&&(b.style.fontFamily="Roboto, Arial, sans-serif",b.style.fontSize="11px",b.style.boxShadow="rgba(0, 0, 0, 0.298039) 0px 1px 4px -1px");for(var c in a.style)b.style[c]=a.style[c];a.id&&(b.id=a.id),a.title&&(b.title=a.title),a.classes&&(b.className=a.classes),a.content&&("string"==typeof a.content?b.innerHTML=a.content:a.content instanceof HTMLElement&&b.appendChild(a.content)),a.position&&(b.position=google.maps.ControlPosition[a.position.toUpperCase()]);for(var d in a.events)!function(b,c){google.maps.event.addDomListener(b,c,function(){a.events[c].apply(this,[this])})}(b,d);return b.index=1,b},j.prototype.addControl=function(a){var b=this.createControl(a);return this.controls.push(b),this.map.controls[b.position].push(b),b},j.prototype.removeControl=function(a){var b,c=null;for(b=0;b<this.controls.length;b++)this.controls[b]==a&&(c=this.controls[b].position,this.controls.splice(b,1));if(c)for(b=0;b<this.map.controls.length;b++){var d=this.map.controls[a.position];if(d.getAt(b)==a){d.removeAt(b);break}}return a},j.prototype.createMarker=function(b){if(void 0==b.lat&&void 0==b.lng&&void 0==b.position)throw"No latitude or longitude defined.";var c=this,d=b.details,e=b.fences,f=b.outside,g={position:new google.maps.LatLng(b.lat,b.lng),map:null},h=a(g,b);delete h.lat,delete h.lng,delete h.fences,delete h.outside;var i=new google.maps.Marker(h);if(i.fences=e,b.infoWindow){i.infoWindow=new google.maps.InfoWindow(b.infoWindow);for(var j=["closeclick","content_changed","domready","position_changed","zindex_changed"],k=0;k<j.length;k++)!function(a,c){b.infoWindow[c]&&google.maps.event.addListener(a,c,function(a){b.infoWindow[c].apply(this,[a])})}(i.infoWindow,j[k])}for(var l=["animation_changed","clickable_changed","cursor_changed","draggable_changed","flat_changed","icon_changed","position_changed","shadow_changed","shape_changed","title_changed","visible_changed","zindex_changed"],m=["dblclick","drag","dragend","dragstart","mousedown","mouseout","mouseover","mouseup"],k=0;k<l.length;k++)!function(a,c){b[c]&&google.maps.event.addListener(a,c,function(){b[c].apply(this,[this])})}(i,l[k]);for(var k=0;k<m.length;k++)!function(a,c,d){b[d]&&google.maps.event.addListener(c,d,function(c){c.pixel||(c.pixel=a.getProjection().fromLatLngToPoint(c.latLng)),b[d].apply(this,[c])})}(this.map,i,m[k]);return google.maps.event.addListener(i,"click",function(){this.details=d,b.click&&b.click.apply(this,[this]),i.infoWindow&&(c.hideInfoWindows(),i.infoWindow.open(c.map,i))}),google.maps.event.addListener(i,"rightclick",function(a){a.marker=this,b.rightclick&&b.rightclick.apply(this,[a]),void 0!=window.context_menu[c.el.id].marker&&c.buildContextMenu("marker",a)}),i.fences&&google.maps.event.addListener(i,"dragend",function(){c.checkMarkerGeofence(i,function(a,b){f(a,b)})}),i},j.prototype.addMarker=function(a){var b;if(a.hasOwnProperty("gm_accessors_"))b=a;else{if(!(a.hasOwnProperty("lat")&&a.hasOwnProperty("lng")||a.position))throw"No latitude or longitude defined.";b=this.createMarker(a)}return b.setMap(this.map),this.markerClusterer&&this.markerClusterer.addMarker(b),this.markers.push(b),j.fire("marker_added",b,this),b},j.prototype.addMarkers=function(a){for(var b,c=0;b=a[c];c++)this.addMarker(b);return this.markers},j.prototype.hideInfoWindows=function(){for(var a,b=0;a=this.markers[b];b++)a.infoWindow&&a.infoWindow.close()},j.prototype.removeMarker=function(a){for(var b=0;b<this.markers.length;b++)if(this.markers[b]===a){this.markers[b].setMap(null),this.markers.splice(b,1),this.markerClusterer&&this.markerClusterer.removeMarker(a),j.fire("marker_removed",a,this);break}return a},j.prototype.removeMarkers=function(a){var b=[];if("undefined"==typeof a){for(var c=0;c<this.markers.length;c++){var d=this.markers[c];d.setMap(null),this.markerClusterer&&this.markerClusterer.removeMarker(d),j.fire("marker_removed",d,this)}this.markers=b}else{for(var c=0;c<a.length;c++){var e=this.markers.indexOf(a[c]);if(e>-1){var d=this.markers[e];d.setMap(null),this.markerClusterer&&this.markerClusterer.removeMarker(d),j.fire("marker_removed",d,this)}}for(var c=0;c<this.markers.length;c++){var d=this.markers[c];null!=d.getMap()&&b.push(d)}this.markers=b}},j.prototype.drawOverlay=function(a){var b=new google.maps.OverlayView,c=!0;return b.setMap(this.map),null!=a.auto_show&&(c=a.auto_show),b.onAdd=function(){var c=document.createElement("div");c.style.borderStyle="none",c.style.borderWidth="0px",c.style.position="absolute",c.style.zIndex=100,c.innerHTML=a.content,b.el=c,a.layer||(a.layer="overlayLayer");var d=this.getPanes(),e=d[a.layer],f=["contextmenu","DOMMouseScroll","dblclick","mousedown"];e.appendChild(c);for(var g=0;g<f.length;g++)!function(a,b){google.maps.event.addDomListener(a,b,function(a){-1!=navigator.userAgent.toLowerCase().indexOf("msie")&&document.all?(a.cancelBubble=!0,a.returnValue=!1):a.stopPropagation()})}(c,f[g]);a.click&&(d.overlayMouseTarget.appendChild(b.el),google.maps.event.addDomListener(b.el,"click",function(){a.click.apply(b,[b])})),google.maps.event.trigger(this,"ready")},b.draw=function(){var d=this.getProjection(),e=d.fromLatLngToDivPixel(new google.maps.LatLng(a.lat,a.lng));a.horizontalOffset=a.horizontalOffset||0,a.verticalOffset=a.verticalOffset||0;var f=b.el,g=f.children[0],h=g.clientHeight,i=g.clientWidth;switch(a.verticalAlign){case"top":f.style.top=e.y-h+a.verticalOffset+"px";break;default:case"middle":f.style.top=e.y-h/2+a.verticalOffset+"px";break;case"bottom":f.style.top=e.y+a.verticalOffset+"px"}switch(a.horizontalAlign){case"left":f.style.left=e.x-i+a.horizontalOffset+"px";break;default:case"center":f.style.left=e.x-i/2+a.horizontalOffset+"px";break;case"right":f.style.left=e.x+a.horizontalOffset+"px"}f.style.display=c?"block":"none",c||a.show.apply(this,[f])},b.onRemove=function(){var c=b.el;a.remove?a.remove.apply(this,[c]):(b.el.parentNode.removeChild(b.el),b.el=null)},this.overlays.push(b),b},j.prototype.removeOverlay=function(a){for(var b=0;b<this.overlays.length;b++)if(this.overlays[b]===a){this.overlays[b].setMap(null),this.overlays.splice(b,1);break}},j.prototype.removeOverlays=function(){for(var a,b=0;a=this.overlays[b];b++)a.setMap(null);this.overlays=[]},j.prototype.drawPolyline=function(a){var b=[],c=a.path;if(c.length)if(void 0===c[0][0])b=c;else for(var d,e=0;d=c[e];e++)b.push(new google.maps.LatLng(d[0],d[1]));var f={map:this.map,path:b,strokeColor:a.strokeColor,strokeOpacity:a.strokeOpacity,strokeWeight:a.strokeWeight,geodesic:a.geodesic,clickable:!0,editable:!1,visible:!0};a.hasOwnProperty("clickable")&&(f.clickable=a.clickable),a.hasOwnProperty("editable")&&(f.editable=a.editable),a.hasOwnProperty("icons")&&(f.icons=a.icons),a.hasOwnProperty("zIndex")&&(f.zIndex=a.zIndex);for(var g=new google.maps.Polyline(f),h=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","rightclick"],i=0;i<h.length;i++)!function(b,c){a[c]&&google.maps.event.addListener(b,c,function(b){a[c].apply(this,[b])})}(g,h[i]);return this.polylines.push(g),j.fire("polyline_added",g,this),g},j.prototype.removePolyline=function(a){for(var b=0;b<this.polylines.length;b++)if(this.polylines[b]===a){this.polylines[b].setMap(null),this.polylines.splice(b,1),j.fire("polyline_removed",a,this);break}},j.prototype.removePolylines=function(){for(var a,b=0;a=this.polylines[b];b++)a.setMap(null);this.polylines=[]},j.prototype.drawCircle=function(b){b=a({map:this.map,center:new google.maps.LatLng(b.lat,b.lng)},b),delete b.lat,delete b.lng;for(var c=new google.maps.Circle(b),d=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","rightclick"],e=0;e<d.length;e++)!function(a,c){b[c]&&google.maps.event.addListener(a,c,function(a){b[c].apply(this,[a])})}(c,d[e]);return this.polygons.push(c),c},j.prototype.drawRectangle=function(b){b=a({map:this.map},b);var c=new google.maps.LatLngBounds(new google.maps.LatLng(b.bounds[0][0],b.bounds[0][1]),new google.maps.LatLng(b.bounds[1][0],b.bounds[1][1]));b.bounds=c;for(var d=new google.maps.Rectangle(b),e=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","rightclick"],f=0;f<e.length;f++)!function(a,c){b[c]&&google.maps.event.addListener(a,c,function(a){b[c].apply(this,[a])})}(d,e[f]);return this.polygons.push(d),d},j.prototype.drawPolygon=function(d){var e=!1;d.hasOwnProperty("useGeoJSON")&&(e=d.useGeoJSON),delete d.useGeoJSON,d=a({map:this.map},d),0==e&&(d.paths=[d.paths.slice(0)]),d.paths.length>0&&d.paths[0].length>0&&(d.paths=c(b(d.paths,f,e)));for(var g=new google.maps.Polygon(d),h=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","rightclick"],i=0;i<h.length;i++)!function(a,b){d[b]&&google.maps.event.addListener(a,b,function(a){d[b].apply(this,[a])})}(g,h[i]);return this.polygons.push(g),j.fire("polygon_added",g,this),g},j.prototype.removePolygon=function(a){for(var b=0;b<this.polygons.length;b++)if(this.polygons[b]===a){this.polygons[b].setMap(null),this.polygons.splice(b,1),j.fire("polygon_removed",a,this);break}},j.prototype.removePolygons=function(){for(var a,b=0;a=this.polygons[b];b++)a.setMap(null);this.polygons=[]},j.prototype.getFromFusionTables=function(a){var b=a.events;delete a.events;var c=a,d=new google.maps.FusionTablesLayer(c);for(var e in b)!function(a,c){google.maps.event.addListener(a,c,function(a){b[c].apply(this,[a])})}(d,e);return this.layers.push(d),d},j.prototype.loadFromFusionTables=function(a){var b=this.getFromFusionTables(a);return b.setMap(this.map),b},j.prototype.getFromKML=function(a){var b=a.url,c=a.events;delete a.url,delete a.events;var d=a,e=new google.maps.KmlLayer(b,d);for(var f in c)!function(a,b){google.maps.event.addListener(a,b,function(a){c[b].apply(this,[a])})}(e,f);return this.layers.push(e),e},j.prototype.loadFromKML=function(a){var b=this.getFromKML(a);return b.setMap(this.map),b},j.prototype.addLayer=function(a,b){b=b||{};var c;switch(a){case"weather":this.singleLayers.weather=c=new google.maps.weather.WeatherLayer;break;case"clouds":this.singleLayers.clouds=c=new google.maps.weather.CloudLayer;break;case"traffic":this.singleLayers.traffic=c=new google.maps.TrafficLayer;break;case"transit":this.singleLayers.transit=c=new google.maps.TransitLayer;break;case"bicycling":this.singleLayers.bicycling=c=new google.maps.BicyclingLayer;break;case"panoramio":this.singleLayers.panoramio=c=new google.maps.panoramio.PanoramioLayer,c.setTag(b.filter),delete b.filter,b.click&&google.maps.event.addListener(c,"click",function(a){b.click(a),delete b.click});break;case"places":if(this.singleLayers.places=c=new google.maps.places.PlacesService(this.map),b.search||b.nearbySearch||b.radarSearch){var d={bounds:b.bounds||null,keyword:b.keyword||null,location:b.location||null,name:b.name||null,radius:b.radius||null,rankBy:b.rankBy||null,types:b.types||null};b.radarSearch&&c.radarSearch(d,b.radarSearch),b.search&&c.search(d,b.search),b.nearbySearch&&c.nearbySearch(d,b.nearbySearch)}if(b.textSearch){var e={bounds:b.bounds||null,location:b.location||null,query:b.query||null,radius:b.radius||null};c.textSearch(e,b.textSearch)}}return void 0!==c?("function"==typeof c.setOptions&&c.setOptions(b),"function"==typeof c.setMap&&c.setMap(this.map),c):void 0},j.prototype.removeLayer=function(a){if("string"==typeof a&&void 0!==this.singleLayers[a])this.singleLayers[a].setMap(null),delete this.singleLayers[a];else for(var b=0;b<this.layers.length;b++)if(this.layers[b]===a){this.layers[b].setMap(null),this.layers.splice(b,1);break}};var k,l;return j.prototype.getRoutes=function(b){switch(b.travelMode){case"bicycling":k=google.maps.TravelMode.BICYCLING;break;case"transit":k=google.maps.TravelMode.TRANSIT;break;case"driving":k=google.maps.TravelMode.DRIVING;break;default:k=google.maps.TravelMode.WALKING}l="imperial"===b.unitSystem?google.maps.UnitSystem.IMPERIAL:google.maps.UnitSystem.METRIC;var c={avoidHighways:!1,avoidTolls:!1,optimizeWaypoints:!1,waypoints:[]},d=a(c,b);d.origin=/string/.test(typeof b.origin)?b.origin:new google.maps.LatLng(b.origin[0],b.origin[1]),d.destination=/string/.test(typeof b.destination)?b.destination:new google.maps.LatLng(b.destination[0],b.destination[1]),d.travelMode=k,d.unitSystem=l,delete d.callback,delete d.error;var e=this,f=new google.maps.DirectionsService;f.route(d,function(a,c){if(c===google.maps.DirectionsStatus.OK){for(var d in a.routes)a.routes.hasOwnProperty(d)&&e.routes.push(a.routes[d]);b.callback&&b.callback(e.routes)}else b.error&&b.error(a,c)})},j.prototype.removeRoutes=function(){this.routes=[]},j.prototype.getElevations=function(d){d=a({locations:[],path:!1,samples:256},d),d.locations.length>0&&d.locations[0].length>0&&(d.locations=c(b([d.locations],f,!1)));var e=d.callback;delete d.callback;var g=new google.maps.ElevationService;if(d.path){var h={path:d.locations,samples:d.samples};g.getElevationAlongPath(h,function(a,b){e&&"function"==typeof e&&e(a,b)})}else delete d.path,delete d.samples,g.getElevationForLocations(d,function(a,b){e&&"function"==typeof e&&e(a,b)})},j.prototype.cleanRoute=j.prototype.removePolylines,j.prototype.drawRoute=function(a){var b=this;this.getRoutes({origin:a.origin,destination:a.destination,travelMode:a.travelMode,waypoints:a.waypoints,unitSystem:a.unitSystem,error:a.error,callback:function(c){if(c.length>0){var d={path:c[c.length-1].overview_path,strokeColor:a.strokeColor,strokeOpacity:a.strokeOpacity,strokeWeight:a.strokeWeight};a.hasOwnProperty("icons")&&(d.icons=a.icons),b.drawPolyline(d),a.callback&&a.callback(c[c.length-1])}}})},j.prototype.travelRoute=function(a){if(a.origin&&a.destination)this.getRoutes({origin:a.origin,destination:a.destination,travelMode:a.travelMode,waypoints:a.waypoints,unitSystem:a.unitSystem,error:a.error,callback:function(b){if(b.length>0&&a.start&&a.start(b[b.length-1]),b.length>0&&a.step){var c=b[b.length-1];if(c.legs.length>0)for(var d,e=c.legs[0].steps,f=0;d=e[f];f++)d.step_number=f,a.step(d,c.legs[0].steps.length-1)}b.length>0&&a.end&&a.end(b[b.length-1])}});else if(a.route&&a.route.legs.length>0)for(var b,c=a.route.legs[0].steps,d=0;b=c[d];d++)b.step_number=d,a.step(b)},j.prototype.drawSteppedRoute=function(a){var b=this;if(a.origin&&a.destination)this.getRoutes({origin:a.origin,destination:a.destination,travelMode:a.travelMode,waypoints:a.waypoints,error:a.error,callback:function(c){if(c.length>0&&a.start&&a.start(c[c.length-1]),c.length>0&&a.step){var d=c[c.length-1];if(d.legs.length>0)for(var e,f=d.legs[0].steps,g=0;e=f[g];g++){e.step_number=g;var h={path:e.path,strokeColor:a.strokeColor,strokeOpacity:a.strokeOpacity,strokeWeight:a.strokeWeight};a.hasOwnProperty("icons")&&(h.icons=a.icons),b.drawPolyline(h),a.step(e,d.legs[0].steps.length-1)}}c.length>0&&a.end&&a.end(c[c.length-1])}});else if(a.route&&a.route.legs.length>0)for(var c,d=a.route.legs[0].steps,e=0;c=d[e];e++){c.step_number=e;var f={path:c.path,strokeColor:a.strokeColor,strokeOpacity:a.strokeOpacity,strokeWeight:a.strokeWeight};a.hasOwnProperty("icons")&&(f.icons=a.icons),b.drawPolyline(f),a.step(c)}},j.Route=function(a){this.origin=a.origin,this.destination=a.destination,this.waypoints=a.waypoints,this.map=a.map,this.route=a.route,this.step_count=0,this.steps=this.route.legs[0].steps,this.steps_length=this.steps.length;var b={path:new google.maps.MVCArray,strokeColor:a.strokeColor,strokeOpacity:a.strokeOpacity,strokeWeight:a.strokeWeight};a.hasOwnProperty("icons")&&(b.icons=a.icons),this.polyline=this.map.drawPolyline(b).getPath()},j.Route.prototype.getRoute=function(a){var b=this;this.map.getRoutes({origin:this.origin,destination:this.destination,travelMode:a.travelMode,waypoints:this.waypoints||[],error:a.error,callback:function(){b.route=e[0],a.callback&&a.callback.call(b)}})},j.Route.prototype.back=function(){if(this.step_count>0){this.step_count--;var a=this.route.legs[0].steps[this.step_count].path;for(var b in a)a.hasOwnProperty(b)&&this.polyline.pop()}},j.Route.prototype.forward=function(){if(this.step_count<this.steps_length){var a=this.route.legs[0].steps[this.step_count].path;for(var b in a)a.hasOwnProperty(b)&&this.polyline.push(a[b]);this.step_count++}},j.prototype.checkGeofence=function(a,b,c){return c.containsLatLng(new google.maps.LatLng(a,b))},j.prototype.checkMarkerGeofence=function(a,b){if(a.fences)for(var c,d=0;c=a.fences[d];d++){var e=a.getPosition();this.checkGeofence(e.lat(),e.lng(),c)||b(a,c)}},j.prototype.toImage=function(a){var a=a||{},b={};if(b.size=a.size||[this.el.clientWidth,this.el.clientHeight],b.lat=this.getCenter().lat(),b.lng=this.getCenter().lng(),this.markers.length>0){b.markers=[];for(var c=0;c<this.markers.length;c++)b.markers.push({lat:this.markers[c].getPosition().lat(),lng:this.markers[c].getPosition().lng()})}if(this.polylines.length>0){var d=this.polylines[0];b.polyline={},b.polyline.path=google.maps.geometry.encoding.encodePath(d.getPath()),b.polyline.strokeColor=d.strokeColor,b.polyline.strokeOpacity=d.strokeOpacity,b.polyline.strokeWeight=d.strokeWeight}return j.staticMapURL(b)},j.staticMapURL=function(a){function b(a,b){if("#"===a[0]&&(a=a.replace("#","0x"),b)){if(b=parseFloat(b),b=Math.min(1,Math.max(b,0)),0===b)return"0x00000000";b=(255*b).toString(16),1===b.length&&(b+=b),a=a.slice(0,8)+b}return a}var c,d=[],e=("file:"===location.protocol?"http:":location.protocol)+"//maps.googleapis.com/maps/api/staticmap";a.url&&(e=a.url,delete a.url),e+="?";var f=a.markers;delete a.markers,!f&&a.marker&&(f=[a.marker],delete a.marker);var g=a.styles;delete a.styles;var h=a.polyline;if(delete a.polyline,a.center)d.push("center="+a.center),delete a.center;else if(a.address)d.push("center="+a.address),delete a.address;else if(a.lat)d.push(["center=",a.lat,",",a.lng].join("")),delete a.lat,delete a.lng;else if(a.visible){var i=encodeURI(a.visible.join("|"));d.push("visible="+i)}var j=a.size;j?(j.join&&(j=j.join("x")),delete a.size):j="630x300",d.push("size="+j),a.zoom||a.zoom===!1||(a.zoom=15);var k=a.hasOwnProperty("sensor")?!!a.sensor:!0;delete a.sensor,d.push("sensor="+k);for(var l in a)a.hasOwnProperty(l)&&d.push(l+"="+a[l]);if(f)for(var m,n,o=0;c=f[o];o++){m=[],c.size&&"normal"!==c.size?(m.push("size:"+c.size),delete c.size):c.icon&&(m.push("icon:"+encodeURI(c.icon)),delete c.icon),c.color&&(m.push("color:"+c.color.replace("#","0x")),delete c.color),c.label&&(m.push("label:"+c.label[0].toUpperCase()),delete c.label),n=c.address?c.address:c.lat+","+c.lng,delete c.address,delete c.lat,delete c.lng;for(var l in c)c.hasOwnProperty(l)&&m.push(l+":"+c[l]);m.length||0===o?(m.push(n),m=m.join("|"),d.push("markers="+encodeURI(m))):(m=d.pop()+encodeURI("|"+n),d.push(m))}if(g)for(var o=0;o<g.length;o++){var p=[];g[o].featureType&&p.push("feature:"+g[o].featureType.toLowerCase()),g[o].elementType&&p.push("element:"+g[o].elementType.toLowerCase());for(var q=0;q<g[o].stylers.length;q++)for(var r in g[o].stylers[q]){var s=g[o].stylers[q][r];("hue"==r||"color"==r)&&(s="0x"+s.substring(1)),p.push(r+":"+s)}var t=p.join("|");""!=t&&d.push("style="+t)}if(h){if(c=h,h=[],c.strokeWeight&&h.push("weight:"+parseInt(c.strokeWeight,10)),c.strokeColor){var u=b(c.strokeColor,c.strokeOpacity);h.push("color:"+u)}if(c.fillColor){var v=b(c.fillColor,c.fillOpacity);h.push("fillcolor:"+v)}var w=c.path;if(w.join)for(var x,q=0;x=w[q];q++)h.push(x.join(","));else h.push("enc:"+w);h=h.join("|"),d.push("path="+encodeURI(h))}var y=window.devicePixelRatio||1;return d.push("scale="+y),d=d.join("&"),e+d},j.prototype.addMapType=function(a,b){if(!b.hasOwnProperty("getTileUrl")||"function"!=typeof b.getTileUrl)throw"'getTileUrl' function required.";b.tileSize=b.tileSize||new google.maps.Size(256,256);var c=new google.maps.ImageMapType(b);this.map.mapTypes.set(a,c)},j.prototype.addOverlayMapType=function(a){if(!a.hasOwnProperty("getTile")||"function"!=typeof a.getTile)throw"'getTile' function required.";var b=a.index;delete a.index,this.map.overlayMapTypes.insertAt(b,a)},j.prototype.removeOverlayMapType=function(a){this.map.overlayMapTypes.removeAt(a)},j.prototype.addStyle=function(a){var b=new google.maps.StyledMapType(a.styles,{name:a.styledMapName});this.map.mapTypes.set(a.mapTypeId,b)},j.prototype.setStyle=function(a){this.map.setMapTypeId(a)},j.prototype.createPanorama=function(a){return a.hasOwnProperty("lat")&&a.hasOwnProperty("lng")||(a.lat=this.getCenter().lat(),a.lng=this.getCenter().lng()),this.panorama=j.createPanorama(a),this.map.setStreetView(this.panorama),this.panorama},j.createPanorama=function(b){var c=h(b.el,b.context);b.position=new google.maps.LatLng(b.lat,b.lng),delete b.el,delete b.context,delete b.lat,delete b.lng;for(var d=["closeclick","links_changed","pano_changed","position_changed","pov_changed","resize","visible_changed"],e=a({visible:!0},b),f=0;f<d.length;f++)delete e[d[f]];for(var g=new google.maps.StreetViewPanorama(c,e),f=0;f<d.length;f++)!function(a,c){b[c]&&google.maps.event.addListener(a,c,function(){b[c].apply(this)})}(g,d[f]);return g},j.prototype.on=function(a,b){return j.on(a,this,b)},j.prototype.off=function(a){j.off(a,this)},j.custom_events=["marker_added","marker_removed","polyline_added","polyline_removed","polygon_added","polygon_removed","geolocated","geolocation_failed"],j.on=function(a,b,c){if(-1==j.custom_events.indexOf(a))return b instanceof j&&(b=b.map),google.maps.event.addListener(b,a,c);var d={handler:c,eventName:a};return b.registered_events[a]=b.registered_events[a]||[],b.registered_events[a].push(d),d},j.off=function(a,b){-1==j.custom_events.indexOf(a)?(b instanceof j&&(b=b.map),google.maps.event.clearListeners(b,a)):b.registered_events[a]=[]},j.fire=function(a,b,c){if(-1==j.custom_events.indexOf(a))google.maps.event.trigger(b,a,Array.prototype.slice.apply(arguments).slice(2));else if(a in c.registered_events)for(var d=c.registered_events[a],e=0;e<d.length;e++)!function(a,b,c){a.apply(b,[c])}(d[e].handler,c,b)},j.geolocate=function(a){var b=a.always||a.complete;navigator.geolocation?navigator.geolocation.getCurrentPosition(function(c){a.success(c),b&&b()},function(c){a.error(c),b&&b()},a.options):(a.not_supported(),b&&b())},j.geocode=function(a){this.geocoder=new google.maps.Geocoder;var b=a.callback;a.hasOwnProperty("lat")&&a.hasOwnProperty("lng")&&(a.latLng=new google.maps.LatLng(a.lat,a.lng)),delete a.lat,delete a.lng,delete a.callback,this.geocoder.geocode(a,function(a,c){b(a,c)})},"object"==typeof window.google&&window.google.maps&&(google.maps.Polygon.prototype.getBounds||(google.maps.Polygon.prototype.getBounds=function(a){for(var b,c=new google.maps.LatLngBounds,d=this.getPaths(),e=0;e<d.getLength();e++){b=d.getAt(e);for(var f=0;f<b.getLength();f++)c.extend(b.getAt(f))}return c}),google.maps.Polygon.prototype.containsLatLng||(google.maps.Polygon.prototype.containsLatLng=function(a){var b=this.getBounds();if(null!==b&&!b.contains(a))return!1;for(var c=!1,d=this.getPaths().getLength(),e=0;d>e;e++)for(var f=this.getPaths().getAt(e),g=f.getLength(),h=g-1,i=0;g>i;i++){var j=f.getAt(i),k=f.getAt(h);(j.lng()<a.lng()&&k.lng()>=a.lng()||k.lng()<a.lng()&&j.lng()>=a.lng())&&j.lat()+(a.lng()-j.lng())/(k.lng()-j.lng())*(k.lat()-j.lat())<a.lat()&&(c=!c),h=i}return c}),google.maps.Circle.prototype.containsLatLng||(google.maps.Circle.prototype.containsLatLng=function(a){return google.maps.geometry?google.maps.geometry.spherical.computeDistanceBetween(this.getCenter(),a)<=this.getRadius():!0}),google.maps.LatLngBounds.prototype.containsLatLng=function(a){return this.contains(a)},google.maps.Marker.prototype.setFences=function(a){this.fences=a},google.maps.Marker.prototype.addFence=function(a){this.fences.push(a)},google.maps.Marker.prototype.getId=function(){return this.__gm_id}),Array.prototype.indexOf||(Array.prototype.indexOf=function(a){if(null==this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>1&&(d=Number(arguments[1]),d!=d?d=0:0!=d&&d!=1/0&&d!=-(1/0)&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1}),j}),function(a){var b=function(a,b,c,d){this.base_url="https://maps.google.com/maps?",this.display(a,b,c,d)};b.prototype.display=function(b,c,d,e){a(b).show();var f=a(b).data("breakpoint");if(f>640&&(f=640),a("html").width()>f){var g=new GMaps({div:b,lat:c.lat(),lng:c.lng(),mapTypeControl:!1,zoom:parseFloat(d),streetViewControl:!1,scrollwheel:!1,mapTypeId:google.maps.MapTypeId.ROADMAP});if(e.length){var h=g.addMarker({lat:c.lat(),lng:c.lng(),infoWindow:{content:e}});"open"==a(b).data("infowindow")&&h.infoWindow.open(h.map,h)}else g.addMarker({lat:c.lat(),lng:c.lng()})}else{var i=GMaps.staticMapURL({center:c.lat()+","+c.lng(),zoom:d,size:f+"x"+a(b).height(),markers:[{lat:c.lat(),lng:c.lng()}],sensor:"false"}),j=a("<img />");a(j).attr("src",i),a(j).attr("alt",a(b).text());var k=a("<a />");a(k).attr("href",this.base_url+"q="+c.lat()+","+c.lng()+"&z="+d),a(k).html(j),a(b).html(k),a(b).addClass("staticmap")}},a(".simplemap").each(function(){var c=a("div",this).get(0),d=16;if(parseFloat(a(c).data("zoom"))&&(d=a(c).data("zoom")),a(c).data("lat")&&a(c).data("lng")){var e=a(c).data("lat"),f=a(c).data("lng"),g=a(c).html(),h=new google.maps.LatLng(e,f);new b(c,h,d,g)}else a(c).data("addr")?GMaps.geocode({address:a(c).data("addr"),callback:function(e,f){if("OK"==f){var g=e[0].geometry.location;new b(c,g,d,a(c).html())}}}):a(c).text().length&&GMaps.geocode({
14
+ address:a(c).text(),callback:function(e,f){if("OK"==f){var g=e[0].geometry.location;new b(c,g,d,a(c).text())}}})})}(jQuery);
readme.txt ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Simple Map ===
2
+ Contributors: miyauchi
3
+ Donate link: http://wpist.me/
4
+ Tags: google maps, map, shortcode, address
5
+ Requires at least: 3.6
6
+ Tested up to: 4.3
7
+ Stable tag: 2.7.0
8
+
9
+ Easy way to embed google map(s).
10
+
11
+ == Description ==
12
+
13
+ Easy way to embed google map(s) using [gmaps.js](http://hpneo.github.com/gmaps/).
14
+
15
+ This plugin allows you to convert address into google maps like below:
16
+
17
+ `[map]San Francisco, California[/map]`
18
+
19
+ Another way, you can embed Google Map with url only like oEmbed.
20
+
21
+
22
+ You can also use coordinates, set width, height and zoom:
23
+
24
+ `[map lat="37.77493" lng="-122.41942"]
25
+ Text you would
26
+ like to appear
27
+ as a tooltip
28
+ goes here
29
+ [/map]`
30
+
31
+ In this case there will be a marker on the map with a tooltip appearing on click on the said marker.
32
+ You can use simple html as the tooltip content.
33
+
34
+
35
+ [This plugin is maintained on GitHub.](https://github.com/miya0001/simple-map)
36
+
37
+ = Some features: =
38
+
39
+ * Allows you to embed google map based on shortcode.
40
+ * Markers can be added using address or lat/long.
41
+ * Displays static map for iPhone automatically.
42
+ * oEmbed Support.
43
+
44
+ = Arguments =
45
+
46
+ * width: Width of the map. Default value is "100%".
47
+ * height: Height of the map. Default value is "200px".
48
+ * zoom: Zoom of the map. Default value is "16".
49
+ * breakpoint: If display is narrower than this value, this plugin will display static map. Default value is "480".
50
+ * addr: Address of the map you want to place.
51
+ * lat: Lat of the map you want to place.
52
+ * lng: Lng of the map you want to place.
53
+ * infowindow: If you want to open infoWindow by Default, please set "open".
54
+
55
+ If you will set lat/lng and address, this plugin gives priority to lat/lng.
56
+
57
+ = Filter Hooks =
58
+
59
+ This plugin has some filter hooks for customize default.
60
+
61
+ * simplemap_default_width
62
+ * simplemap_default_height
63
+ * simplemap_default_zoom
64
+ * simplemap_default_breakpoint
65
+ * simplemap_default_infowindow
66
+
67
+ `add_filter( 'simplemap_default_zoom', function(){
68
+ return 10; // Default zoom is 10
69
+ } );`
70
+
71
+ = Translators =
72
+
73
+ * Japanese(ja) - [Takayuki Miyauchi](http://firegoby.jp/)
74
+
75
+ Please contact me.
76
+
77
+ * https://github.com/miya0001/simple-map/issues
78
+
79
+ = Contributors =
80
+
81
+ * [Takayuki Miyauchi](http://firegoby.jp/)
82
+ * [Zoltán Balogh](http://birdcreation.com/)
83
+ * [Takanobu Watanabe](https://github.com/tknv)
84
+ * [Shinichi Nishikawa](http://th-daily.shinichi.me/)
85
+
86
+ == Installation ==
87
+
88
+ * Download the zip, extract it and upload the extracted folder to your-wp-directory/wp-content/plugins/
89
+ * Go to the plugins administration screen in your WordPress admin and activate the plugin.
90
+
91
+ OR
92
+
93
+ * Download the zip, go to the plugins administration screen in your WordPress admin, click on Add New then on upload, browse to the downloaded zip, upload the plugin and activate it.
94
+
95
+ OR
96
+
97
+ * Go to the plugins administration screen in your WordPress admin, click on Add New, search for Simple Map and click on Install Now.
98
+
99
+ *Usage*
100
+
101
+ This plugin allows you to convert address into google maps like below:
102
+
103
+ `[map]San Francisco, California[/map]`
104
+
105
+ Another way, you can embed Google Map with url only like oEmbed.
106
+
107
+ You can also use coordinates, set width, height and zoom:
108
+
109
+ `[map lat="37.77493" lng="-122.41942" width="100%" height="400px" zoom="15"]
110
+ Text you would
111
+ like to appear
112
+ as a tooltip
113
+ goes here
114
+ [/map]`
115
+
116
+ In this case there will be a marker on the map with a tooltip appearing on click on the said marker.
117
+ You can use simple html as the tooltip content.
118
+
119
+ == Screenshots ==
120
+
121
+ 1. Very easy.
122
+ 2. Info Window.
123
+ 3. Mobile Support. (Google static map)
124
+
125
+ == Changelog ==
126
+
127
+ = 2.7.0 =
128
+
129
+ * UPdate gmaps.js to 0.4.21
130
+ * Add tests on travis
131
+
132
+ https://github.com/miya0001/simple-map/compare/2.6.0...2.7.0
133
+
134
+ = 2.6.0 =
135
+
136
+ * Update gmaps.js from 0.4.18 to 0.4.19
137
+ * Add front end test
138
+
139
+ https://github.com/miya0001/simple-map/compare/2.5.0...2.6.0
140
+
141
+ = 2.5.0 =
142
+ * Update gmaps.js 0.4.17 to 0.4.18
143
+ * Tested on WordPress 4.3
144
+
145
+ = 2.4.0 =
146
+ * Update gmaps.js 0.4.16 to 0.4.17
147
+
148
+ = 2.3.0 =
149
+ * Tested on the WordPress 4.1.
150
+ * Up to minimum required to WordPress 3.6.
151
+
152
+ = 2.2.0 =
153
+ * update gmaps.js 0.4.15 to 0.4.16
154
+
155
+ = 2.1.0 =
156
+ * update gmaps.js 0.4.14 to 0.4.15
157
+
158
+ = 2.0.0 =
159
+ * Add argument infowindow
160
+ * little fix
161
+
162
+ = 1.9.0 =
163
+ * update gmaps.js 0.4.13 to 0.4.14
164
+
165
+ = 1.8.0 =
166
+ * update gmaps.js 0.4.12 to 0.4.13
167
+
168
+ = 1.7.0 =
169
+ * update gmaps.js 0.4.11 to 0.4.12
170
+
171
+ = 1.6.0 =
172
+ * update gmaps.js 0.4.9 to 0.4.11
173
+
174
+ = 1.5.0 =
175
+ * enable ssl source of google map api js
176
+
177
+ = 1.4.0 =
178
+ * change URL match pattern.
179
+
180
+ = 1.3.0 =
181
+ * Update gmaps.js to 0.4.9.
182
+
183
+ = 1.2.0 =
184
+ * Tested on the WordPress 3.8.
185
+ * Add Grunt.
186
+
187
+ = 1.1.0 =
188
+ * Added support for gmaps.js tooltip on markers
189
+
190
+ = 1.0.0 =
191
+ * Delete hl=ja param from static map link uri.
192
+
193
+ = 0.9.0 =
194
+ * hook changed to the init.
195
+
196
+ = 0.8.0 =
197
+ * shortcode atts and address priority changed.
198
+
199
+ = 0.7.0 =
200
+ * gmaps.js updated 0.4.4 to 0.4.5
201
+
202
+ = 0.6.0 =
203
+ * oEmbed Support
204
+
205
+ = 0.1.0 =
206
+ * The first release.
207
+
208
+ == Credits ==
209
+
210
+ This plugin is not guaranteed though the user of WordPress can freely use this plugin free of charge regardless of the purpose.
211
+ The author must acknowledge the thing that the operation guarantee and the support in this plugin use are not done at all beforehand.
212
+
213
+ == Contact ==
214
+
215
+ twitter @miya0001
simple-map.php ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Simple Map
4
+ Author: Takayuki Miyauchi
5
+ Plugin URI: https://github.com/miya0001/simple-map
6
+ Description: Insert google map convert from address.
7
+ Version: 2.7.0
8
+ Author URI: http://wpist.me/
9
+ Domain Path: /languages
10
+ Text Domain: simplemap
11
+ */
12
+
13
+ $simplemap = new Simple_Map();
14
+
15
+ class Simple_Map {
16
+
17
+ private $shortcode_tag = 'map';
18
+ private $class_name = 'simplemap';
19
+ private $width = '100%';
20
+ private $height = '200px';
21
+ private $zoom = 16;
22
+ private $breakpoint = 480;
23
+ private $max_breakpoint = 640;
24
+
25
+ function __construct()
26
+ {
27
+ add_action( 'init', array( $this, 'init' ) );
28
+ }
29
+
30
+ public function init()
31
+ {
32
+ add_action( 'wp_head', array( $this, 'wp_head' ) );
33
+ add_shortcode( $this->get_shortcode_tag(), array( $this, 'shortcode' ) );
34
+
35
+ wp_embed_register_handler(
36
+ 'google-map',
37
+ '#( https://( www|maps ).google.[a-z]{2,3}\.?[a-z]{0,3}/maps( /ms )?\?.+ )#i',
38
+ array( &$this, 'oembed_handler' )
39
+ );
40
+ }
41
+
42
+ public function oembed_handler( $match )
43
+ {
44
+ return sprintf(
45
+ '[%s url="%s"]',
46
+ $this->get_shortcode_tag(),
47
+ esc_url( $match[0] )
48
+ );
49
+ }
50
+
51
+ public function wp_head()
52
+ {
53
+ echo "<style>.simplemap img{max-width:none !important;padding:0 !important;margin:0 !important;}.staticmap,.staticmap img{max-width:100% !important;height:auto !important;}.simplemap .simplemap-content{display:none;}</style>\n";
54
+ }
55
+
56
+ public function wp_enqueue_scripts()
57
+ {
58
+ wp_register_script(
59
+ 'google-maps-api',
60
+ '//maps.google.com/maps/api/js?sensor=false',
61
+ false,
62
+ null,
63
+ true
64
+ );
65
+
66
+ wp_register_script(
67
+ 'simplemap',
68
+ apply_filters(
69
+ 'simplemap_script',
70
+ plugins_url( 'js/simple-map.min.js' , __FILE__ )
71
+ ),
72
+ array( 'jquery', 'google-maps-api' ),
73
+ filemtime( dirname( __FILE__ ).'/js/simple-map.min.js' ),
74
+ true
75
+ );
76
+ wp_enqueue_script( 'simplemap' );
77
+ }
78
+
79
+ public function shortcode( $p, $content = null )
80
+ {
81
+ add_action( 'wp_footer', array( &$this, 'wp_enqueue_scripts' ) );
82
+
83
+ if ( isset( $p['width'] ) && preg_match( '/^[0-9]+(%|px)$/', $p['width'] ) ) {
84
+ $w = $p['width'];
85
+ } else {
86
+ $w = apply_filters( 'simplemap_default_width', $this->width );
87
+ }
88
+ if ( isset( $p['height'] ) && preg_match( '/^[0-9]+(%|px)$/', $p['height'] ) ) {
89
+ $h = $p['height'];
90
+ } else {
91
+ $h = apply_filters( 'simplemap_default_height', $this->height );
92
+ }
93
+ if ( isset( $p['zoom'] ) && intval( $p['zoom'] ) ) {
94
+ $zoom = $p['zoom'];
95
+ } else {
96
+ $zoom = apply_filters( 'simplemap_default_zoom', $this->zoom );
97
+ }
98
+ if ( isset( $p['breakpoint'] ) && intval( $p['breakpoint'] ) ) {
99
+ if ( intval( $p['breakpoint'] ) > $this->max_breakpoint ) {
100
+ $breakpoint = $this->max_breakpoint;
101
+ } else {
102
+ $breakpoint = intval( $p['breakpoint'] );
103
+ }
104
+ } else {
105
+ $breakpoint = apply_filters(
106
+ 'simplemap_default_breakpoint',
107
+ $this->breakpoint
108
+ );
109
+ }
110
+ if ( $content ) {
111
+ $content = do_shortcode( $content );
112
+ }
113
+ if ( isset( $p['infowindow'] ) && $p['infowindow'] ) {
114
+ $infowindow = $p['infowindow'];
115
+ } else {
116
+ $infowindow = apply_filters( 'simplemap_default_infowindow', 'close' );
117
+ }
118
+
119
+ $addr = '';
120
+ $lat = '';
121
+ $lng = '';
122
+
123
+ if ( isset( $p['url'] ) && $p['url'] ) {
124
+ $iframe = '<iframe width="%s" height="%s" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="%s"></iframe>';
125
+
126
+ return sprintf(
127
+ $iframe,
128
+ $w,
129
+ $h,
130
+ esc_url( $p['url'].'&output=embed' )
131
+ );
132
+ } elseif ( isset( $p['lat'] ) && preg_match( '/^\-?[0-9\.]+$/', $p['lat'] )
133
+ && isset( $p['lng'] ) && preg_match( '/^\-?[0-9\.]+$/', $p['lng'] ) ){
134
+ $lat = $p['lat'];
135
+ $lng = $p['lng'];
136
+ } elseif ( isset( $p['addr'] ) && $p['addr'] ) {
137
+ if ( $content ) {
138
+ $addr = esc_html( $p['addr'] );
139
+ } else {
140
+ $content = esc_html( $p['addr'] );
141
+ }
142
+ } elseif ( ! $content ) {
143
+ return;
144
+ }
145
+ return sprintf(
146
+ '<div class="%1$s"><div class="%1$s-content" data-breakpoint="%2$s" data-lat="%3$s" data-lng="%4$s" data-zoom="%5$s" data-addr="%6$s" data-infowindow="%7$s" style="width:%8$s;height:%9$s;">%10$s</div></div>',
147
+ apply_filters( 'simplemap_class_name', $this->class_name ),
148
+ $breakpoint,
149
+ $lat,
150
+ $lng,
151
+ $zoom,
152
+ $addr,
153
+ $infowindow,
154
+ $w,
155
+ $h,
156
+ trim( $content )
157
+ );
158
+ }
159
+
160
+ private function get_shortcode_tag()
161
+ {
162
+ return apply_filters( 'simplemap_shortcode_tag', $this->shortcode_tag );
163
+ }
164
+
165
+ } // end class
166
+
167
+
168
+ // EOF