Version Description
Download this release
Release Info
Developer | miyauchi |
Plugin | Simple Map |
Version | 4.9.0 |
Comparing to | |
See all releases |
Code changes from version 4.7.0 to 4.9.0
- .svnignore +1 -0
- js/simple-map.min.js +3 -3
- readme.txt +2 -2
- simple-map.php +33 -29
.svnignore
CHANGED
@@ -13,6 +13,7 @@ composer.lock
|
|
13 |
node_modules
|
14 |
npm-debug.log
|
15 |
package.json
|
|
|
16 |
phpunit.xml
|
17 |
tests
|
18 |
vendor
|
13 |
node_modules
|
14 |
npm-debug.log
|
15 |
package.json
|
16 |
+
package-lock.json
|
17 |
phpunit.xml
|
18 |
tests
|
19 |
vendor
|
js/simple-map.min.js
CHANGED
@@ -7,8 +7,8 @@
|
|
7 |
* Special thanks!
|
8 |
* http://hpneo.github.io/gmaps/
|
9 |
*
|
10 |
-
* Copyright
|
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)void 0!==b[c]&&(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;c<f;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){var c=document,d=function(b){if("object"!=typeof window.google||!window.google.maps)return"object"==typeof window.console&&window.console.error,function(){};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;e<l;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;a<c;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;b<c;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),j.fire("marker_removed",d,this)}this.markerClusterer&&this.markerClusterer.clearMarkers&&this.markerClusterer.clearMarkers(),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){navigator.userAgent.toLowerCase().indexOf("msie")!=-1&&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)}}if(void 0!==c)return"function"==typeof c.setOptions&&c.setOptions(b),"function"==typeof c.setMap&&c.setMap(this.map),c},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=[],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.push(a.routes[d]);b.callback&&b.callback(e,a,c)}else b.error&&b.error(a,c)})},j.prototype.removeRoutes=function(){this.routes.length=0},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.renderRoute=function(b,c){var d,e="string"==typeof c.panel?document.getElementById(c.panel.replace("#","")):c.panel;c.panel=e,c=a({map:this.map},c),d=new google.maps.DirectionsRenderer(c),this.getRoutes({origin:b.origin,destination:b.destination,travelMode:b.travelMode,waypoints:b.waypoints,unitSystem:b.unitSystem,error:b.error,avoidHighways:b.avoidHighways,avoidTolls:b.avoidTolls,optimizeWaypoints:b.optimizeWaypoints,callback:function(a,b,c){c===google.maps.DirectionsStatus.OK&&d.setDirections(b)}})},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,avoidHighways:a.avoidHighways,avoidTolls:a.avoidTolls,optimizeWaypoints:a.optimizeWaypoints,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;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.prototype.once=function(a,b){return j.once(a,this,b)},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(j.custom_events.indexOf(a)==-1)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){j.custom_events.indexOf(a)==-1?(b instanceof j&&(b=b.map),google.maps.event.clearListeners(b,a)):b.registered_events[a]=[]},j.once=function(a,b,c){if(j.custom_events.indexOf(a)==-1)return b instanceof j&&(b=b.map),google.maps.event.addListenerOnce(b,a,c)},j.fire=function(a,b,c){if(j.custom_events.indexOf(a)==-1)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;e<d;e++)for(var f=this.getPaths().getAt(e),g=f.getLength(),h=g-1,i=0;i<g;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()}),google.maps.Rectangle.prototype.containsLatLng=function(a){return this.getBounds().contains(a)},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);e<c;e++)if(e in b&&b[e]===a)return e;return-1}),j}),function(a){var b=function(b){this.base_url="https://maps.google.com/maps?";var c=this,d=16;if(parseFloat(a(b).data("zoom"))&&(d=a(b).data("zoom")),a(b).data("lat")&&a(b).data("lng")){var e=a(b).data("lat"),f=a(b).data("lng"),g=a(b).html(),h=new google.maps.LatLng(e,f);this.display(b,h,d,g)}else if(a(b).data("addr").length||a(b).text().length){var i=a(b).data("addr").length?a(b).data("addr"):a(b).text();
|
14 |
-
GMaps.geocode({address:i,callback:function(e,f){if("OK"==f){var g=e[0].geometry.location;c.display(b,g,d,a(b).html())}}})}};b.prototype.display=function(b,c,d,e){a(b).show();var f=a(b).data("breakpoint");if(a("html").width()>f){var g;g="true"==a(b).data("map-type-control");var h;h=a(b).data("map-type-id")?a(b).data("map-type-id"):"ROADMAP";var i=new GMaps({div:b,lat:c.lat(),lng:c.lng(),mapTypeControl:g,zoom:parseFloat(d),streetViewControl:!1,scrollwheel:!1,mapTypeId:google.maps.MapTypeId[h],width:b.style.width,height:b.style.height}),j=a(b).is(":visible");if(!j)var k=setInterval(function(){a(b).is(":visible")&&(clearInterval(k),i.refresh(),i.setCenter(c.lat(),c.lng()))},1e3);if(e.length){var l=i.addMarker({lat:c.lat(),lng:c.lng(),infoWindow:{content:e}});"open"==a(b).data("infowindow")&&l.infoWindow.open(l.map,l)}else i.addMarker({lat:c.lat(),lng:c.lng()})}else{var m=GMaps.staticMapURL({center:c.lat()+","+c.lng(),zoom:d,size:f+"x"+a(b).height(),markers:[{lat:c.lat(),lng:c.lng()}]}),n=a("<img />");a(n).attr("src",m+"&key="+google_map_api_key),a(n).attr("alt",a(b).text());var o=a("<a />");a(o).attr("href",this.base_url+"q="+c.lat()+","+c.lng()+"&z="+d),a(o).html(n),a(b).html(o),a(b).addClass("staticmap")}},a(".simplemap").each(function(){new b(a("div",this).get(0))})}(jQuery);
|
7 |
* Special thanks!
|
8 |
* http://hpneo.github.io/gmaps/
|
9 |
*
|
10 |
+
* Copyright 2018, Takayuki Miyauchi (http://wpist.me/)
|
11 |
* Released under the GPLv2
|
12 |
*/
|
13 |
+
|
14 |
+
"use strict";!function(e,t){"object"==typeof exports?module.exports=t():"function"==typeof define&&define.amd?define(["jquery","googlemaps!"],t):e.GMaps=t()}(this,function(){var T,z,t,o,S=function(e,t){var o;if(e===t)return e;for(o in t)void 0!==t[o]&&(e[o]=t[o]);return e},i=function(e,o){var t,n=Array.prototype.slice.call(arguments,2),r=[],i=e.length;if(Array.prototype.map&&e.map===Array.prototype.map)r=Array.prototype.map.call(e,function(e){var t=n.slice(0);return t.splice(0,0,e),o.apply(this,t)});else for(t=0;t<i;t++)callback_params=n,callback_params.splice(0,0,e[t]),r.push(o.apply(this,callback_params));return r},a=function(e){var t,o=[];for(t=0;t<e.length;t++)o=o.concat(e[t]);return o},s=function(e,t){var o,n,r,i,a;for(o=0;o<e.length;o++)e[o]instanceof google.maps.LatLng||(0<e[o].length&&"object"==typeof e[o][0]?e[o]=s(e[o],t):e[o]=(n=e[o],r=t,a=i=void 0,i=n[0],a=n[1],r&&(i=n[1],a=n[0]),new google.maps.LatLng(i,a)));return e},W=function(e,t){e=e.replace("#","");return"jQuery"in window&&t?$("#"+e,t)[0]:document.getElementById(e)},p=(T=document,z=function(o){if("object"!=typeof window.google||!window.google.maps)return"object"==typeof window.console&&window.console.error,function(){};if(!this)return new z(o);o.zoom=o.zoom||15,o.mapType=o.mapType||"roadmap";var e,t=function(e,t){return void 0===e?t:e},d=this,n=["bounds_changed","center_changed","click","dblclick","drag","dragend","dragstart","idle","maptypeid_changed","projection_changed","resize","tilesloaded","zoom_changed"],r=["mousemove","mouseout","mouseover"],i=["el","lat","lng","mapType","width","height","markerClusterer","enableNewStyle"],a=o.el||o.div,s=o.markerClusterer,l=google.maps.MapTypeId[o.mapType.toUpperCase()],p=new google.maps.LatLng(o.lat,o.lng),c=t(o.zoomControl,!0),g=o.zoomControlOpt||{style:"DEFAULT",position:"TOP_LEFT"},h=g.style||"DEFAULT",u=g.position||"TOP_LEFT",m=t(o.panControl,!0),f=t(o.mapTypeControl,!0),y=t(o.scaleControl,!0),v=t(o.streetViewControl,!0),k=t(k,!0),w={},L={zoom:this.zoom,center:p,mapTypeId:l},b={panControl:m,zoomControl:c,zoomControlOptions:{style:google.maps.ZoomControlStyle[h],position:google.maps.ControlPosition[u]},mapTypeControl:f,scaleControl:y,streetViewControl:v,overviewMapControl:k};if("string"==typeof o.el||"string"==typeof o.div?-1<a.indexOf("#")?this.el=W(a,o.context):this.el=function(e,t){var o=e.replace(".","");return"jQuery"in this&&t?$("."+o,t)[0]:document.getElementsByClassName(o)[0]}.apply(this,[a,o.context]):this.el=a,void 0===this.el||null===this.el)throw"No element defined.";for(window.context_menu=window.context_menu||{},window.context_menu[d.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=o.zoom,this.registered_events={},this.el.style.width=o.width||this.el.scrollWidth||this.el.offsetWidth,this.el.style.height=o.height||this.el.scrollHeight||this.el.offsetHeight,google.maps.visualRefresh=o.enableNewStyle,e=0;e<i.length;e++)delete o[i[e]];for(1!=o.disableDefaultUI&&(L=S(L,b)),w=S(L,o),e=0;e<n.length;e++)delete w[n[e]];for(e=0;e<r.length;e++)delete w[r[e]];this.map=new google.maps.Map(this.el,w),s&&(this.markerClusterer=s.apply(this,[this.map]));var _=function(t,o){var e="",n=window.context_menu[d.el.id][t];for(var r in n)if(n.hasOwnProperty(r)){var i=n[r];e+='<li><a id="'+t+"_"+r+'" href="#">'+i.title+"</a></li>"}if(W("gmaps_context_menu")){var a=W("gmaps_context_menu");a.innerHTML=e;var s=a.getElementsByTagName("a"),l=s.length;for(r=0;r<l;r++){var p=s[r];google.maps.event.clearListeners(p,"click"),google.maps.event.addDomListenerOnce(p,"click",function(e){e.preventDefault(),n[this.id.replace(t+"_","")].action.apply(d,[o]),d.hideContextMenu()},!1)}var c=function(e){var t=0,o=0;if(e.offsetParent)for(;t+=e.offsetLeft,o+=e.offsetTop,e=e.offsetParent;);return[t,o]}.apply(this,[d.el]),g=c[0]+o.pixel.x-15,h=c[1]+o.pixel.y-15;a.style.left=g+"px",a.style.top=h+"px"}};this.buildContextMenu=function(o,n){if("marker"===o){n.pixel={};var r=new google.maps.OverlayView;r.setMap(d.map),r.draw=function(){var e=r.getProjection(),t=n.marker.getPosition();n.pixel=e.fromLatLngToContainerPixel(t),_(o,n)}}else _(o,n);var e=W("gmaps_context_menu");setTimeout(function(){e.style.display="block"},0)},this.setContextMenu=function(e){window.context_menu[d.el.id][e.control]={};var t,o=T.createElement("ul");for(t in e.options)if(e.options.hasOwnProperty(t)){var n=e.options[t];window.context_menu[d.el.id][e.control][n.name]={title:n.title,action:n.action}}o.id="gmaps_context_menu",o.style.display="none",o.style.position="absolute",o.style.minWidth="100px",o.style.background="white",o.style.listStyle="none",o.style.padding="8px",o.style.boxShadow="2px 2px 6px #ccc",W("gmaps_context_menu")||T.body.appendChild(o);var r=W("gmaps_context_menu");google.maps.event.addDomListener(r,"mouseout",function(e){e.relatedTarget&&this.contains(e.relatedTarget)||window.setTimeout(function(){r.style.display="none"},400)},!1)},this.hideContextMenu=function(){var e=W("gmaps_context_menu");e&&(e.style.display="none")};var M=function(e,t){google.maps.event.addListener(e,t,function(e){null==e&&(e=this),o[t].apply(this,[e]),d.hideContextMenu()})};google.maps.event.addListener(this.map,"zoom_changed",this.hideContextMenu);for(var x=0;x<n.length;x++){(C=n[x])in o&&M(this.map,C)}for(x=0;x<r.length;x++){var C;(C=r[x])in o&&M(this.map,C)}google.maps.event.addListener(this.map,"rightclick",function(e){o.rightclick&&o.rightclick.apply(this,[e]),null!=window.context_menu[d.el.id].map&&d.buildContextMenu("map",e)}),this.refresh=function(){google.maps.event.trigger(this.map,"resize")},this.fitZoom=function(){var e,t=[],o=this.markers.length;for(e=0;e<o;e++)"boolean"==typeof this.markers[e].visible&&this.markers[e].visible&&t.push(this.markers[e].getPosition());this.fitLatLngBounds(t)},this.fitLatLngBounds=function(e){var t,o=e.length,n=new google.maps.LatLngBounds;for(t=0;t<o;t++)n.extend(e[t]);this.map.fitBounds(n)},this.setCenter=function(e,t,o){this.map.panTo(new google.maps.LatLng(e,t)),o&&o()},this.getElement=function(){return this.el},this.zoomIn=function(e){e=e||1,this.zoom=this.map.getZoom()+e,this.map.setZoom(this.zoom)},this.zoomOut=function(e){e=e||1,this.zoom=this.map.getZoom()-e,this.map.setZoom(this.zoom)};var O,P=[];for(O in this.map)"function"!=typeof this.map[O]||this[O]||P.push(O);for(e=0;e<P.length;e++)!function(e,t,o){e[o]=function(){return t[o].apply(t,arguments)}}(this,this.map,P[e])});return p.prototype.createControl=function(o){var e=document.createElement("div");for(var t in e.style.cursor="pointer",!0!==o.disableDefaultStyles&&(e.style.fontFamily="Roboto, Arial, sans-serif",e.style.fontSize="11px",e.style.boxShadow="rgba(0, 0, 0, 0.298039) 0px 1px 4px -1px"),o.style)e.style[t]=o.style[t];for(var n in o.id&&(e.id=o.id),o.title&&(e.title=o.title),o.classes&&(e.className=o.classes),o.content&&("string"==typeof o.content?e.innerHTML=o.content:o.content instanceof HTMLElement&&e.appendChild(o.content)),o.position&&(e.position=google.maps.ControlPosition[o.position.toUpperCase()]),o.events)!function(e,t){google.maps.event.addDomListener(e,t,function(){o.events[t].apply(this,[this])})}(e,n);return e.index=1,e},p.prototype.addControl=function(e){var t=this.createControl(e);return this.controls.push(t),this.map.controls[t.position].push(t),t},p.prototype.removeControl=function(e){var t,o=null;for(t=0;t<this.controls.length;t++)this.controls[t]==e&&(o=this.controls[t].position,this.controls.splice(t,1));if(o)for(t=0;t<this.map.controls.length;t++){var n=this.map.controls[e.position];if(n.getAt(t)==e){n.removeAt(t);break}}return e},p.prototype.createMarker=function(n){if(null==n.lat&&null==n.lng&&null==n.position)throw"No latitude or longitude defined.";var t=this,e=n.details,o=n.fences,r=n.outside,i={position:new google.maps.LatLng(n.lat,n.lng),map:null},a=S(i,n);delete a.lat,delete a.lng,delete a.fences,delete a.outside;var s=new google.maps.Marker(a);if(s.fences=o,n.infoWindow){s.infoWindow=new google.maps.InfoWindow(n.infoWindow);for(var l=["closeclick","content_changed","domready","position_changed","zindex_changed"],p=0;p<l.length;p++)!function(e,t){n.infoWindow[t]&&google.maps.event.addListener(e,t,function(e){n.infoWindow[t].apply(this,[e])})}(s.infoWindow,l[p])}var c=["animation_changed","clickable_changed","cursor_changed","draggable_changed","flat_changed","icon_changed","position_changed","shadow_changed","shape_changed","title_changed","visible_changed","zindex_changed"],g=["dblclick","drag","dragend","dragstart","mousedown","mouseout","mouseover","mouseup"];for(p=0;p<c.length;p++)!function(e,t){n[t]&&google.maps.event.addListener(e,t,function(){n[t].apply(this,[this])})}(s,c[p]);for(p=0;p<g.length;p++)!function(t,e,o){n[o]&&google.maps.event.addListener(e,o,function(e){e.pixel||(e.pixel=t.getProjection().fromLatLngToPoint(e.latLng)),n[o].apply(this,[e])})}(this.map,s,g[p]);return google.maps.event.addListener(s,"click",function(){this.details=e,n.click&&n.click.apply(this,[this]),s.infoWindow&&(t.hideInfoWindows(),s.infoWindow.open(t.map,s))}),google.maps.event.addListener(s,"rightclick",function(e){e.marker=this,n.rightclick&&n.rightclick.apply(this,[e]),null!=window.context_menu[t.el.id].marker&&t.buildContextMenu("marker",e)}),s.fences&&google.maps.event.addListener(s,"dragend",function(){t.checkMarkerGeofence(s,function(e,t){r(e,t)})}),s},p.prototype.addMarker=function(e){var t;if(e.hasOwnProperty("gm_accessors_"))t=e;else{if(!(e.hasOwnProperty("lat")&&e.hasOwnProperty("lng")||e.position))throw"No latitude or longitude defined.";t=this.createMarker(e)}return t.setMap(this.map),this.markerClusterer&&this.markerClusterer.addMarker(t),this.markers.push(t),p.fire("marker_added",t,this),t},p.prototype.addMarkers=function(e){for(var t,o=0;t=e[o];o++)this.addMarker(t);return this.markers},p.prototype.hideInfoWindows=function(){for(var e,t=0;e=this.markers[t];t++)e.infoWindow&&e.infoWindow.close()},p.prototype.removeMarker=function(e){for(var t=0;t<this.markers.length;t++)if(this.markers[t]===e){this.markers[t].setMap(null),this.markers.splice(t,1),this.markerClusterer&&this.markerClusterer.removeMarker(e),p.fire("marker_removed",e,this);break}return e},p.prototype.removeMarkers=function(e){var t=[];if(void 0===e){for(var o=0;o<this.markers.length;o++){(r=this.markers[o]).setMap(null),p.fire("marker_removed",r,this)}this.markerClusterer&&this.markerClusterer.clearMarkers&&this.markerClusterer.clearMarkers(),this.markers=t}else{for(o=0;o<e.length;o++){var n=this.markers.indexOf(e[o]);if(-1<n)(r=this.markers[n]).setMap(null),this.markerClusterer&&this.markerClusterer.removeMarker(r),p.fire("marker_removed",r,this)}for(o=0;o<this.markers.length;o++){var r;null!=(r=this.markers[o]).getMap()&&t.push(r)}this.markers=t}},p.prototype.drawOverlay=function(a){var s=new google.maps.OverlayView,i=!0;return s.setMap(this.map),null!=a.auto_show&&(i=a.auto_show),s.onAdd=function(){var e=document.createElement("div");e.style.borderStyle="none",e.style.borderWidth="0px",e.style.position="absolute",e.style.zIndex=100,e.innerHTML=a.content,s.el=e,a.layer||(a.layer="overlayLayer");var t,o,n=this.getPanes(),r=["contextmenu","DOMMouseScroll","dblclick","mousedown"];n[a.layer].appendChild(e);for(var i=0;i<r.length;i++)t=e,o=r[i],google.maps.event.addDomListener(t,o,function(e){-1!=navigator.userAgent.toLowerCase().indexOf("msie")&&document.all?(e.cancelBubble=!0,e.returnValue=!1):e.stopPropagation()});a.click&&(n.overlayMouseTarget.appendChild(s.el),google.maps.event.addDomListener(s.el,"click",function(){a.click.apply(s,[s])})),google.maps.event.trigger(this,"ready")},s.draw=function(){var e=this.getProjection().fromLatLngToDivPixel(new google.maps.LatLng(a.lat,a.lng));a.horizontalOffset=a.horizontalOffset||0,a.verticalOffset=a.verticalOffset||0;var t=s.el,o=t.children[0],n=o.clientHeight,r=o.clientWidth;switch(a.verticalAlign){case"top":t.style.top=e.y-n+a.verticalOffset+"px";break;default:case"middle":t.style.top=e.y-n/2+a.verticalOffset+"px";break;case"bottom":t.style.top=e.y+a.verticalOffset+"px"}switch(a.horizontalAlign){case"left":t.style.left=e.x-r+a.horizontalOffset+"px";break;default:case"center":t.style.left=e.x-r/2+a.horizontalOffset+"px";break;case"right":t.style.left=e.x+a.horizontalOffset+"px"}t.style.display=i?"block":"none",i||a.show.apply(this,[t])},s.onRemove=function(){var e=s.el;a.remove?a.remove.apply(this,[e]):(s.el.parentNode.removeChild(s.el),s.el=null)},this.overlays.push(s),s},p.prototype.removeOverlay=function(e){for(var t=0;t<this.overlays.length;t++)if(this.overlays[t]===e){this.overlays[t].setMap(null),this.overlays.splice(t,1);break}},p.prototype.removeOverlays=function(){for(var e,t=0;e=this.overlays[t];t++)e.setMap(null);this.overlays=[]},p.prototype.drawPolyline=function(o){var e=[],t=o.path;if(t.length)if(void 0===t[0][0])e=t;else for(var n,r=0;n=t[r];r++)e.push(new google.maps.LatLng(n[0],n[1]));var i={map:this.map,path:e,strokeColor:o.strokeColor,strokeOpacity:o.strokeOpacity,strokeWeight:o.strokeWeight,geodesic:o.geodesic,clickable:!0,editable:!1,visible:!0};o.hasOwnProperty("clickable")&&(i.clickable=o.clickable),o.hasOwnProperty("editable")&&(i.editable=o.editable),o.hasOwnProperty("icons")&&(i.icons=o.icons),o.hasOwnProperty("zIndex")&&(i.zIndex=o.zIndex);for(var a=new google.maps.Polyline(i),s=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","rightclick"],l=0;l<s.length;l++)!function(e,t){o[t]&&google.maps.event.addListener(e,t,function(e){o[t].apply(this,[e])})}(a,s[l]);return this.polylines.push(a),p.fire("polyline_added",a,this),a},p.prototype.removePolyline=function(e){for(var t=0;t<this.polylines.length;t++)if(this.polylines[t]===e){this.polylines[t].setMap(null),this.polylines.splice(t,1),p.fire("polyline_removed",e,this);break}},p.prototype.removePolylines=function(){for(var e,t=0;e=this.polylines[t];t++)e.setMap(null);this.polylines=[]},p.prototype.drawCircle=function(o){delete(o=S({map:this.map,center:new google.maps.LatLng(o.lat,o.lng)},o)).lat,delete o.lng;for(var e=new google.maps.Circle(o),t=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","rightclick"],n=0;n<t.length;n++)!function(e,t){o[t]&&google.maps.event.addListener(e,t,function(e){o[t].apply(this,[e])})}(e,t[n]);return this.polygons.push(e),e},p.prototype.drawRectangle=function(o){o=S({map:this.map},o);var e=new google.maps.LatLngBounds(new google.maps.LatLng(o.bounds[0][0],o.bounds[0][1]),new google.maps.LatLng(o.bounds[1][0],o.bounds[1][1]));o.bounds=e;for(var t=new google.maps.Rectangle(o),n=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","rightclick"],r=0;r<n.length;r++)!function(e,t){o[t]&&google.maps.event.addListener(e,t,function(e){o[t].apply(this,[e])})}(t,n[r]);return this.polygons.push(t),t},p.prototype.drawPolygon=function(o){var e=!1;o.hasOwnProperty("useGeoJSON")&&(e=o.useGeoJSON),delete o.useGeoJSON,o=S({map:this.map},o),0==e&&(o.paths=[o.paths.slice(0)]),0<o.paths.length&&0<o.paths[0].length&&(o.paths=a(i(o.paths,s,e)));for(var t=new google.maps.Polygon(o),n=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","rightclick"],r=0;r<n.length;r++)!function(e,t){o[t]&&google.maps.event.addListener(e,t,function(e){o[t].apply(this,[e])})}(t,n[r]);return this.polygons.push(t),p.fire("polygon_added",t,this),t},p.prototype.removePolygon=function(e){for(var t=0;t<this.polygons.length;t++)if(this.polygons[t]===e){this.polygons[t].setMap(null),this.polygons.splice(t,1),p.fire("polygon_removed",e,this);break}},p.prototype.removePolygons=function(){for(var e,t=0;e=this.polygons[t];t++)e.setMap(null);this.polygons=[]},p.prototype.getFromFusionTables=function(e){var o=e.events;delete e.events;var t=e,n=new google.maps.FusionTablesLayer(t);for(var r in o)!function(e,t){google.maps.event.addListener(e,t,function(e){o[t].apply(this,[e])})}(n,r);return this.layers.push(n),n},p.prototype.loadFromFusionTables=function(e){var t=this.getFromFusionTables(e);return t.setMap(this.map),t},p.prototype.getFromKML=function(e){var t=e.url,o=e.events;delete e.url,delete e.events;var n=e,r=new google.maps.KmlLayer(t,n);for(var i in o)!function(e,t){google.maps.event.addListener(e,t,function(e){o[t].apply(this,[e])})}(r,i);return this.layers.push(r),r},p.prototype.loadFromKML=function(e){var t=this.getFromKML(e);return t.setMap(this.map),t},p.prototype.addLayer=function(e,t){var o;switch(t=t||{},e){case"weather":this.singleLayers.weather=o=new google.maps.weather.WeatherLayer;break;case"clouds":this.singleLayers.clouds=o=new google.maps.weather.CloudLayer;break;case"traffic":this.singleLayers.traffic=o=new google.maps.TrafficLayer;break;case"transit":this.singleLayers.transit=o=new google.maps.TransitLayer;break;case"bicycling":this.singleLayers.bicycling=o=new google.maps.BicyclingLayer;break;case"panoramio":this.singleLayers.panoramio=o=new google.maps.panoramio.PanoramioLayer,o.setTag(t.filter),delete t.filter,t.click&&google.maps.event.addListener(o,"click",function(e){t.click(e),delete t.click});break;case"places":if(this.singleLayers.places=o=new google.maps.places.PlacesService(this.map),t.search||t.nearbySearch||t.radarSearch){var n={bounds:t.bounds||null,keyword:t.keyword||null,location:t.location||null,name:t.name||null,radius:t.radius||null,rankBy:t.rankBy||null,types:t.types||null};t.radarSearch&&o.radarSearch(n,t.radarSearch),t.search&&o.search(n,t.search),t.nearbySearch&&o.nearbySearch(n,t.nearbySearch)}if(t.textSearch){var r={bounds:t.bounds||null,location:t.location||null,query:t.query||null,radius:t.radius||null};o.textSearch(r,t.textSearch)}}if(void 0!==o)return"function"==typeof o.setOptions&&o.setOptions(t),"function"==typeof o.setMap&&o.setMap(this.map),o},p.prototype.removeLayer=function(e){if("string"==typeof e&&void 0!==this.singleLayers[e])this.singleLayers[e].setMap(null),delete this.singleLayers[e];else for(var t=0;t<this.layers.length;t++)if(this.layers[t]===e){this.layers[t].setMap(null),this.layers.splice(t,1);break}},p.prototype.getRoutes=function(n){switch(n.travelMode){case"bicycling":t=google.maps.TravelMode.BICYCLING;break;case"transit":t=google.maps.TravelMode.TRANSIT;break;case"driving":t=google.maps.TravelMode.DRIVING;break;default:t=google.maps.TravelMode.WALKING}o="imperial"===n.unitSystem?google.maps.UnitSystem.IMPERIAL:google.maps.UnitSystem.METRIC;var e=S({avoidHighways:!1,avoidTolls:!1,optimizeWaypoints:!1,waypoints:[]},n);e.origin=/string/.test(typeof n.origin)?n.origin:new google.maps.LatLng(n.origin[0],n.origin[1]),e.destination=/string/.test(typeof n.destination)?n.destination:new google.maps.LatLng(n.destination[0],n.destination[1]),e.travelMode=t,e.unitSystem=o,delete e.callback,delete e.error;var r=[];(new google.maps.DirectionsService).route(e,function(e,t){if(t===google.maps.DirectionsStatus.OK){for(var o in e.routes)e.routes.hasOwnProperty(o)&&r.push(e.routes[o]);n.callback&&n.callback(r,e,t)}else n.error&&n.error(e,t)})},p.prototype.removeRoutes=function(){this.routes.length=0},p.prototype.getElevations=function(e){0<(e=S({locations:[],path:!1,samples:256},e)).locations.length&&0<e.locations[0].length&&(e.locations=a(i([e.locations],s,!1)));var o=e.callback;delete e.callback;var t=new google.maps.ElevationService;if(e.path){var n={path:e.locations,samples:e.samples};t.getElevationAlongPath(n,function(e,t){o&&"function"==typeof o&&o(e,t)})}else delete e.path,delete e.samples,t.getElevationForLocations(e,function(e,t){o&&"function"==typeof o&&o(e,t)})},p.prototype.cleanRoute=p.prototype.removePolylines,p.prototype.renderRoute=function(e,t){var n,o="string"==typeof t.panel?document.getElementById(t.panel.replace("#","")):t.panel;t.panel=o,t=S({map:this.map},t),n=new google.maps.DirectionsRenderer(t),this.getRoutes({origin:e.origin,destination:e.destination,travelMode:e.travelMode,waypoints:e.waypoints,unitSystem:e.unitSystem,error:e.error,avoidHighways:e.avoidHighways,avoidTolls:e.avoidTolls,optimizeWaypoints:e.optimizeWaypoints,callback:function(e,t,o){o===google.maps.DirectionsStatus.OK&&n.setDirections(t)}})},p.prototype.drawRoute=function(o){var n=this;this.getRoutes({origin:o.origin,destination:o.destination,travelMode:o.travelMode,waypoints:o.waypoints,unitSystem:o.unitSystem,error:o.error,avoidHighways:o.avoidHighways,avoidTolls:o.avoidTolls,optimizeWaypoints:o.optimizeWaypoints,callback:function(e){if(0<e.length){var t={path:e[e.length-1].overview_path,strokeColor:o.strokeColor,strokeOpacity:o.strokeOpacity,strokeWeight:o.strokeWeight};o.hasOwnProperty("icons")&&(t.icons=o.icons),n.drawPolyline(t),o.callback&&o.callback(e[e.length-1])}}})},p.prototype.travelRoute=function(i){if(i.origin&&i.destination)this.getRoutes({origin:i.origin,destination:i.destination,travelMode:i.travelMode,waypoints:i.waypoints,unitSystem:i.unitSystem,error:i.error,callback:function(e){if(0<e.length&&i.start&&i.start(e[e.length-1]),0<e.length&&i.step){var t=e[e.length-1];if(0<t.legs.length)for(var o,n=t.legs[0].steps,r=0;o=n[r];r++)o.step_number=r,i.step(o,t.legs[0].steps.length-1)}0<e.length&&i.end&&i.end(e[e.length-1])}});else if(i.route&&0<i.route.legs.length)for(var e,t=i.route.legs[0].steps,o=0;e=t[o];o++)e.step_number=o,i.step(e)},p.prototype.drawSteppedRoute=function(a){var s=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(e){if(0<e.length&&a.start&&a.start(e[e.length-1]),0<e.length&&a.step){var t=e[e.length-1];if(0<t.legs.length)for(var o,n=t.legs[0].steps,r=0;o=n[r];r++){o.step_number=r;var i={path:o.path,strokeColor:a.strokeColor,strokeOpacity:a.strokeOpacity,strokeWeight:a.strokeWeight};a.hasOwnProperty("icons")&&(i.icons=a.icons),s.drawPolyline(i),a.step(o,t.legs[0].steps.length-1)}}0<e.length&&a.end&&a.end(e[e.length-1])}});else if(a.route&&0<a.route.legs.length)for(var e,t=a.route.legs[0].steps,o=0;e=t[o];o++){e.step_number=o;var n={path:e.path,strokeColor:a.strokeColor,strokeOpacity:a.strokeOpacity,strokeWeight:a.strokeWeight};a.hasOwnProperty("icons")&&(n.icons=a.icons),s.drawPolyline(n),a.step(e)}},p.Route=function(e){this.origin=e.origin,this.destination=e.destination,this.waypoints=e.waypoints,this.map=e.map,this.route=e.route,this.step_count=0,this.steps=this.route.legs[0].steps,this.steps_length=this.steps.length;var t={path:new google.maps.MVCArray,strokeColor:e.strokeColor,strokeOpacity:e.strokeOpacity,strokeWeight:e.strokeWeight};e.hasOwnProperty("icons")&&(t.icons=e.icons),this.polyline=this.map.drawPolyline(t).getPath()},p.Route.prototype.getRoute=function(t){var o=this;this.map.getRoutes({origin:this.origin,destination:this.destination,travelMode:t.travelMode,waypoints:this.waypoints||[],error:t.error,callback:function(){o.route=e[0],t.callback&&t.callback.call(o)}})},p.Route.prototype.back=function(){if(0<this.step_count){this.step_count--;var e=this.route.legs[0].steps[this.step_count].path;for(var t in e)e.hasOwnProperty(t)&&this.polyline.pop()}},p.Route.prototype.forward=function(){if(this.step_count<this.steps_length){var e=this.route.legs[0].steps[this.step_count].path;for(var t in e)e.hasOwnProperty(t)&&this.polyline.push(e[t]);this.step_count++}},p.prototype.checkGeofence=function(e,t,o){return o.containsLatLng(new google.maps.LatLng(e,t))},p.prototype.checkMarkerGeofence=function(e,t){if(e.fences)for(var o,n=0;o=e.fences[n];n++){var r=e.getPosition();this.checkGeofence(r.lat(),r.lng(),o)||t(e,o)}},p.prototype.toImage=function(e){e=e||{};var t={};if(t.size=e.size||[this.el.clientWidth,this.el.clientHeight],t.lat=this.getCenter().lat(),t.lng=this.getCenter().lng(),0<this.markers.length){t.markers=[];for(var o=0;o<this.markers.length;o++)t.markers.push({lat:this.markers[o].getPosition().lat(),lng:this.markers[o].getPosition().lng()})}if(0<this.polylines.length){var n=this.polylines[0];t.polyline={},t.polyline.path=google.maps.geometry.encoding.encodePath(n.getPath()),t.polyline.strokeColor=n.strokeColor,t.polyline.strokeOpacity=n.strokeOpacity,t.polyline.strokeWeight=n.strokeWeight}return p.staticMapURL(t)},p.staticMapURL=function(e){var t,o=[],n=("file:"===location.protocol?"http:":location.protocol)+"//maps.googleapis.com/maps/api/staticmap";e.url&&(n=e.url,delete e.url),n+="?";var r=e.markers;delete e.markers,!r&&e.marker&&(r=[e.marker],delete e.marker);var i=e.styles;delete e.styles;var a=e.polyline;if(delete e.polyline,e.center)o.push("center="+e.center),delete e.center;else if(e.address)o.push("center="+e.address),delete e.address;else if(e.lat)o.push(["center=",e.lat,",",e.lng].join("")),delete e.lat,delete e.lng;else if(e.visible){var s=encodeURI(e.visible.join("|"));o.push("visible="+s)}var l=e.size;l?(l.join&&(l=l.join("x")),delete e.size):l="630x300",o.push("size="+l),e.zoom||!1===e.zoom||(e.zoom=15);var p=!e.hasOwnProperty("sensor")||!!e.sensor;for(var c in delete e.sensor,o.push("sensor="+p),e)e.hasOwnProperty(c)&&o.push(c+"="+e[c]);if(r)for(var g,h,d=0;t=r[d];d++){for(var c in g=[],t.size&&"normal"!==t.size?(g.push("size:"+t.size),delete t.size):t.icon&&(g.push("icon:"+encodeURI(t.icon)),delete t.icon),t.color&&(g.push("color:"+t.color.replace("#","0x")),delete t.color),t.label&&(g.push("label:"+t.label[0].toUpperCase()),delete t.label),h=t.address?t.address:t.lat+","+t.lng,delete t.address,delete t.lat,delete t.lng,t)t.hasOwnProperty(c)&&g.push(c+":"+t[c]);g.length||0===d?(g.push(h),g=g.join("|"),o.push("markers="+encodeURI(g))):(g=o.pop()+encodeURI("|"+h),o.push(g))}if(i)for(d=0;d<i.length;d++){var u=[];i[d].featureType&&u.push("feature:"+i[d].featureType.toLowerCase()),i[d].elementType&&u.push("element:"+i[d].elementType.toLowerCase());for(var m=0;m<i[d].stylers.length;m++)for(var f in i[d].stylers[m]){var y=i[d].stylers[m][f];"hue"!=f&&"color"!=f||(y="0x"+y.substring(1)),u.push(f+":"+y)}var v=u.join("|");""!=v&&o.push("style="+v)}function k(e,t){if("#"===e[0]&&(e=e.replace("#","0x"),t)){if(t=parseFloat(t),0===(t=Math.min(1,Math.max(t,0))))return"0x00000000";1===(t=(255*t).toString(16)).length&&(t+=t),e=e.slice(0,8)+t}return e}if(a){if(t=a,a=[],t.strokeWeight&&a.push("weight:"+parseInt(t.strokeWeight,10)),t.strokeColor){var w=k(t.strokeColor,t.strokeOpacity);a.push("color:"+w)}if(t.fillColor){var L=k(t.fillColor,t.fillOpacity);a.push("fillcolor:"+L)}var b=t.path;if(b.join){var _;for(m=0;_=b[m];m++)a.push(_.join(","))}else a.push("enc:"+b);a=a.join("|"),o.push("path="+encodeURI(a))}var M=window.devicePixelRatio||1;return o.push("scale="+M),n+(o=o.join("&"))},p.prototype.addMapType=function(e,t){if(!t.hasOwnProperty("getTileUrl")||"function"!=typeof t.getTileUrl)throw"'getTileUrl' function required.";t.tileSize=t.tileSize||new google.maps.Size(256,256);var o=new google.maps.ImageMapType(t);this.map.mapTypes.set(e,o)},p.prototype.addOverlayMapType=function(e){if(!e.hasOwnProperty("getTile")||"function"!=typeof e.getTile)throw"'getTile' function required.";var t=e.index;delete e.index,this.map.overlayMapTypes.insertAt(t,e)},p.prototype.removeOverlayMapType=function(e){this.map.overlayMapTypes.removeAt(e)},p.prototype.addStyle=function(e){var t=new google.maps.StyledMapType(e.styles,{name:e.styledMapName});this.map.mapTypes.set(e.mapTypeId,t)},p.prototype.setStyle=function(e){this.map.setMapTypeId(e)},p.prototype.createPanorama=function(e){return e.hasOwnProperty("lat")&&e.hasOwnProperty("lng")||(e.lat=this.getCenter().lat(),e.lng=this.getCenter().lng()),this.panorama=p.createPanorama(e),this.map.setStreetView(this.panorama),this.panorama},p.createPanorama=function(o){var e=W(o.el,o.context);o.position=new google.maps.LatLng(o.lat,o.lng),delete o.el,delete o.context,delete o.lat,delete o.lng;for(var t=["closeclick","links_changed","pano_changed","position_changed","pov_changed","resize","visible_changed"],n=S({visible:!0},o),r=0;r<t.length;r++)delete n[t[r]];var i=new google.maps.StreetViewPanorama(e,n);for(r=0;r<t.length;r++)!function(e,t){o[t]&&google.maps.event.addListener(e,t,function(){o[t].apply(this)})}(i,t[r]);return i},p.prototype.on=function(e,t){return p.on(e,this,t)},p.prototype.off=function(e){p.off(e,this)},p.prototype.once=function(e,t){return p.once(e,this,t)},p.custom_events=["marker_added","marker_removed","polyline_added","polyline_removed","polygon_added","polygon_removed","geolocated","geolocation_failed"],p.on=function(e,t,o){if(-1==p.custom_events.indexOf(e))return t instanceof p&&(t=t.map),google.maps.event.addListener(t,e,o);var n={handler:o,eventName:e};return t.registered_events[e]=t.registered_events[e]||[],t.registered_events[e].push(n),n},p.off=function(e,t){-1==p.custom_events.indexOf(e)?(t instanceof p&&(t=t.map),google.maps.event.clearListeners(t,e)):t.registered_events[e]=[]},p.once=function(e,t,o){if(-1==p.custom_events.indexOf(e))return t instanceof p&&(t=t.map),google.maps.event.addListenerOnce(t,e,o)},p.fire=function(e,t,o){if(-1==p.custom_events.indexOf(e))google.maps.event.trigger(t,e,Array.prototype.slice.apply(arguments).slice(2));else if(e in o.registered_events)for(var n=o.registered_events[e],r=0;r<n.length;r++)i=n[r].handler,a=o,s=t,i.apply(a,[s]);var i,a,s},p.geolocate=function(t){var o=t.always||t.complete;navigator.geolocation?navigator.geolocation.getCurrentPosition(function(e){t.success(e),o&&o()},function(e){t.error(e),o&&o()},t.options):(t.not_supported(),o&&o())},p.geocode=function(e){this.geocoder=new google.maps.Geocoder;var o=e.callback;e.hasOwnProperty("lat")&&e.hasOwnProperty("lng")&&(e.latLng=new google.maps.LatLng(e.lat,e.lng)),delete e.lat,delete e.lng,delete e.callback,this.geocoder.geocode(e,function(e,t){o(e,t)})},"object"==typeof window.google&&window.google.maps&&(google.maps.Polygon.prototype.getBounds||(google.maps.Polygon.prototype.getBounds=function(e){for(var t,o=new google.maps.LatLngBounds,n=this.getPaths(),r=0;r<n.getLength();r++){t=n.getAt(r);for(var i=0;i<t.getLength();i++)o.extend(t.getAt(i))}return o}),google.maps.Polygon.prototype.containsLatLng||(google.maps.Polygon.prototype.containsLatLng=function(e){var t=this.getBounds();if(null!==t&&!t.contains(e))return!1;for(var o=!1,n=this.getPaths().getLength(),r=0;r<n;r++)for(var i=this.getPaths().getAt(r),a=i.getLength(),s=a-1,l=0;l<a;l++){var p=i.getAt(l),c=i.getAt(s);(p.lng()<e.lng()&&c.lng()>=e.lng()||c.lng()<e.lng()&&p.lng()>=e.lng())&&p.lat()+(e.lng()-p.lng())/(c.lng()-p.lng())*(c.lat()-p.lat())<e.lat()&&(o=!o),s=l}return o}),google.maps.Circle.prototype.containsLatLng||(google.maps.Circle.prototype.containsLatLng=function(e){return!google.maps.geometry||google.maps.geometry.spherical.computeDistanceBetween(this.getCenter(),e)<=this.getRadius()}),google.maps.Rectangle.prototype.containsLatLng=function(e){return this.getBounds().contains(e)},google.maps.LatLngBounds.prototype.containsLatLng=function(e){return this.contains(e)},google.maps.Marker.prototype.setFences=function(e){this.fences=e},google.maps.Marker.prototype.addFence=function(e){this.fences.push(e)},google.maps.Marker.prototype.getId=function(){return this.__gm_id}),Array.prototype.indexOf||(Array.prototype.indexOf=function(e){if(null==this)throw new TypeError;var t=Object(this),o=t.length>>>0;if(0===o)return-1;var n=0;if(1<arguments.length&&((n=Number(arguments[1]))!=n?n=0:0!=n&&n!=1/0&&n!=-1/0&&(n=(0<n||-1)*Math.floor(Math.abs(n)))),o<=n)return-1;for(var r=0<=n?n:Math.max(o-Math.abs(n),0);r<o;r++)if(r in t&&t[r]===e)return r;return-1}),p}),function(d){var e=function(n){this.base_url="https://maps.google.com/maps?";var r=this,i=16;if(parseFloat(d(n).data("zoom"))&&(i=d(n).data("zoom")),d(n).data("lat")&&d(n).data("lng")){var e=d(n).data("lat"),t=d(n).data("lng"),o=d(n).html(),a=new google.maps.LatLng(e,t);this.display(n,a,i,o)}else if(d(n).data("addr").length||d(n).text().length){var s=d(n).data("addr").length?d(n).data("addr"):d(n).text();GMaps.geocode({address:s,callback:function(e,t){if("OK"==t){var o=e[0].geometry.location;r.display(n,o,i,d(n).html())}}})}};e.prototype.display=function(e,t,o,n){d(e).show();var r=d(e).data("breakpoint");if(d("html").width()>r){var i,a;i="true"==d(e).data("map-type-control"),a=d(e).data("map-type-id")?d(e).data("map-type-id"):"ROADMAP";var s=new GMaps({div:e,lat:t.lat(),lng:t.lng(),mapTypeControl:i,zoom:parseFloat(o),streetViewControl:!1,scrollwheel:!1,mapTypeId:google.maps.MapTypeId[a],width:e.style.width,height:e.style.height});if(!d(e).is(":visible"))var l=setInterval(function(){d(e).is(":visible")&&(clearInterval(l),s.refresh(),s.setCenter(t.lat(),t.lng()))},1e3);if(n.length){var p=s.addMarker({lat:t.lat(),lng:t.lng(),infoWindow:{content:n}});"open"==d(e).data("infowindow")&&p.infoWindow.open(p.map,p)}else s.addMarker({lat:t.lat(),lng:t.lng()})}else{var c=GMaps.staticMapURL({center:t.lat()+","+t.lng(),zoom:o,size:r+"x"+d(e).height(),markers:[{lat:t.lat(),lng:t.lng()}]}),g=d("<img />");d(g).attr("src",c+"&key="+google_map_api_key),d(g).attr("alt",d(e).text());var h=d("<a />");d(h).attr("href",this.base_url+"q="+t.lat()+","+t.lng()+"&z="+o),d(h).html(g),d(e).html(h),d(e).addClass("staticmap")}},d(".simplemap").each(function(){new e(d("div",this).get(0))})}(jQuery);
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: miyauchi
|
3 |
Tags: google maps, map, shortcode, address
|
4 |
Requires at least: 3.9
|
5 |
-
Tested up to: 4.
|
6 |
-
Stable tag: 4.
|
7 |
|
8 |
Easy way to embed google map(s).
|
9 |
|
2 |
Contributors: miyauchi
|
3 |
Tags: google maps, map, shortcode, address
|
4 |
Requires at least: 3.9
|
5 |
+
Tested up to: 4.9
|
6 |
+
Stable tag: 4.9.0
|
7 |
|
8 |
Easy way to embed google map(s).
|
9 |
|
simple-map.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Author: Takayuki Miyauchi
|
5 |
* Plugin URI: https://github.com/miya0001/simple-map
|
6 |
* Description: Insert google map convert from address.
|
7 |
-
* Version: 4.
|
8 |
* Author URI: http://wpist.me/
|
9 |
* Text Domain: simple-map
|
10 |
* Domain Path: /languages
|
@@ -79,8 +79,9 @@ class Simple_Map {
|
|
79 |
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
80 |
add_action( 'admin_init', array( $this, 'settings_init' ) );
|
81 |
add_action( 'admin_init', array( $this, 'load_textdomain' ) );
|
82 |
-
|
83 |
-
|
|
|
84 |
if ( ! isset( $apikey ) || empty( $apikey ) ) {
|
85 |
add_action( 'admin_notices', array( $this, 'admin_notice__error' ) );
|
86 |
}
|
@@ -115,11 +116,12 @@ class Simple_Map {
|
|
115 |
|
116 |
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";
|
117 |
|
118 |
-
$
|
119 |
-
|
|
|
120 |
printf(
|
121 |
-
|
122 |
-
esc_js(
|
123 |
);
|
124 |
}
|
125 |
}
|
@@ -154,7 +156,7 @@ class Simple_Map {
|
|
154 |
* Output tags at footer.
|
155 |
* @param array $p Width,height,zoom.
|
156 |
* @param null $content Content.
|
157 |
-
* @return string
|
158 |
*/
|
159 |
public function shortcode( $p, $content = null ) {
|
160 |
|
@@ -230,7 +232,7 @@ class Simple_Map {
|
|
230 |
$content = $p['addr'];
|
231 |
}
|
232 |
} elseif ( ! $content ) {
|
233 |
-
return;
|
234 |
}
|
235 |
return sprintf(
|
236 |
'<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" data-map-type-control="%8$s" data-map-type-id="%9$s" style="width:%10$s;height:%11$s;">%12$s</div></div>',
|
@@ -252,13 +254,28 @@ class Simple_Map {
|
|
252 |
/**
|
253 |
* Get shortcode tag.
|
254 |
*
|
255 |
-
* @return mixed
|
256 |
*/
|
257 |
private function get_shortcode_tag() {
|
258 |
|
259 |
return apply_filters( 'simplemap_shortcode_tag', $this->shortcode_tag );
|
260 |
}
|
261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
|
263 |
/**
|
264 |
* Load textdomain.
|
@@ -280,16 +297,8 @@ class Simple_Map {
|
|
280 |
* @return string $url Map API key.
|
281 |
*/
|
282 |
public function get_api_url() {
|
283 |
-
|
284 |
-
$
|
285 |
-
|
286 |
-
if ( ! empty( $options['api_key_field'] ) ) {
|
287 |
-
$apikey = "?key=" . $options['api_key_field'];
|
288 |
-
} else {
|
289 |
-
$apikey = "";
|
290 |
-
}
|
291 |
-
|
292 |
-
$url = esc_url( '//maps.google.com/maps/api/js' . $apikey );
|
293 |
|
294 |
return $url;
|
295 |
}
|
@@ -417,15 +426,10 @@ class Simple_Map {
|
|
417 |
*/
|
418 |
public function api_key_field_render() {
|
419 |
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
<input type="text" name="simple_map_settings[api_key_field]" value="<?php echo esc_attr( $apikey ); ?>" size="30">
|
426 |
-
|
427 |
-
<?php
|
428 |
-
|
429 |
}
|
430 |
|
431 |
/**
|
4 |
* Author: Takayuki Miyauchi
|
5 |
* Plugin URI: https://github.com/miya0001/simple-map
|
6 |
* Description: Insert google map convert from address.
|
7 |
+
* Version: 4.9.0
|
8 |
* Author URI: http://wpist.me/
|
9 |
* Text Domain: simple-map
|
10 |
* Domain Path: /languages
|
79 |
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
80 |
add_action( 'admin_init', array( $this, 'settings_init' ) );
|
81 |
add_action( 'admin_init', array( $this, 'load_textdomain' ) );
|
82 |
+
|
83 |
+
$apikey = $this->get_api_key();
|
84 |
+
|
85 |
if ( ! isset( $apikey ) || empty( $apikey ) ) {
|
86 |
add_action( 'admin_notices', array( $this, 'admin_notice__error' ) );
|
87 |
}
|
116 |
|
117 |
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";
|
118 |
|
119 |
+
$apikey = $this->get_api_key();
|
120 |
+
|
121 |
+
if ( $apikey ) {
|
122 |
printf(
|
123 |
+
'<script>var google_map_api_key = "%s";</script>',
|
124 |
+
esc_js( $apikey )
|
125 |
);
|
126 |
}
|
127 |
}
|
156 |
* Output tags at footer.
|
157 |
* @param array $p Width,height,zoom.
|
158 |
* @param null $content Content.
|
159 |
+
* @return string
|
160 |
*/
|
161 |
public function shortcode( $p, $content = null ) {
|
162 |
|
232 |
$content = $p['addr'];
|
233 |
}
|
234 |
} elseif ( ! $content ) {
|
235 |
+
return "";
|
236 |
}
|
237 |
return sprintf(
|
238 |
'<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" data-map-type-control="%8$s" data-map-type-id="%9$s" style="width:%10$s;height:%11$s;">%12$s</div></div>',
|
254 |
/**
|
255 |
* Get shortcode tag.
|
256 |
*
|
257 |
+
* @return mixed
|
258 |
*/
|
259 |
private function get_shortcode_tag() {
|
260 |
|
261 |
return apply_filters( 'simplemap_shortcode_tag', $this->shortcode_tag );
|
262 |
}
|
263 |
|
264 |
+
/**
|
265 |
+
* @return string
|
266 |
+
*/
|
267 |
+
private function get_api_key() {
|
268 |
+
if ( defined( 'GOOGLE_MAP_API_KEY' ) && GOOGLE_MAP_API_KEY ) {
|
269 |
+
return GOOGLE_MAP_API_KEY;
|
270 |
+
} else {
|
271 |
+
$option = get_option( 'simple_map_settings' );
|
272 |
+
if ( trim( $option['api_key_field'] ) ) {
|
273 |
+
return trim( $option['api_key_field'] );
|
274 |
+
}
|
275 |
+
}
|
276 |
+
|
277 |
+
return "";
|
278 |
+
}
|
279 |
|
280 |
/**
|
281 |
* Load textdomain.
|
297 |
* @return string $url Map API key.
|
298 |
*/
|
299 |
public function get_api_url() {
|
300 |
+
$apikey = $this->get_api_key();
|
301 |
+
$url = esc_url( '//maps.google.com/maps/api/js?key=' . $apikey );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
302 |
|
303 |
return $url;
|
304 |
}
|
426 |
*/
|
427 |
public function api_key_field_render() {
|
428 |
|
429 |
+
printf(
|
430 |
+
'<input type="text" name="simple_map_settings[api_key_field]" value="%s" size="30">',
|
431 |
+
esc_attr( $this->get_api_key() )
|
432 |
+
);
|
|
|
|
|
|
|
|
|
|
|
433 |
}
|
434 |
|
435 |
/**
|