switching to gmap3
This commit is contained in:
1 parent
03217058e8
commit
42d891b952
23 files changed
+384895
-30
No files matched your search
File mode changed.
Regular → Executable
+2
-2
@@ -1,2 +1,2 @@
|
||||
/* Spot Librairy - findmespot.com */
|
||||
//function SpotMain(){this.scriptName="spot-main-min.js";this.COMPRESSED=true;this.scriptLocation=null;this.scriptsToLoad=["markermanager.js","spot-widget.js"];this.stylesToLoad=["Resources/css/spotlivewidget.css"]}function MarkerManager(e,t){var n=this;n.map_=e;n.mapZoom_=e.getZoom();n.projectionHelper_=new ProjectionHelperOverlay(e);google.maps.event.addListener(n.projectionHelper_,"ready",function(){n.projection_=this.getProjection();n.initialize(e,t)})}function GridBounds(e){this.minX=Math.min(e[0].x,e[1].x);this.maxX=Math.max(e[0].x,e[1].x);this.minY=Math.min(e[0].y,e[1].y);this.maxY=Math.max(e[0].y,e[1].y)}function ProjectionHelperOverlay(e){this.setMap(e);var t=8;var n=1<<t;var r=7;this._map=e;this._zoom=-1;this._X0=this._Y0=this._X1=this._Y1=-1}SpotMain.prototype.getScriptLocation=function(){if(this.scriptLocation==null){var e=document.getElementsByTagName("script");for(var t=0;t<e.length;t++){var n=e[t].getAttribute("src");if(n){var r=n.lastIndexOf(this.scriptName);var i=n.lastIndexOf("?");if(i<0){i=n.length}if(r>-1&&r+this.scriptName.length==i){this.scriptLocation=n.slice(0,i-this.scriptName.length);break}}}}return this.scriptLocation};SpotMain.prototype.loadStyles=function(){for(var e=0;e<this.stylesToLoad.length;e++){var t=document.getElementsByTagName("head")[0],n=document.createElement("link");n.rel="stylesheet";n.type="text/css";n.href=this.getScriptLocation()+this.stylesToLoad[e];n.media="all";t.appendChild(n)}};SpotMain.prototype.loadScript=function(e){document.write('<script src="'+this.getScriptLocation()+e+'"></script>')};SpotMain.prototype.loadScripts=function(e){for(var t=0;t<this.scriptsToLoad.length;t++){this.loadScript(this.scriptsToLoad[t])}};SpotMain.prototype.load=function(){if(this.COMPRESSED===false)this.loadScripts();this.loadStyles()};window.spotMain=new SpotMain;spotMain.load();MarkerManager.prototype.initialize=function(e,t){var n=this;t=t||{};n.tileSize_=MarkerManager.DEFAULT_TILE_SIZE_;var r=e.mapTypes;var i=1;for(var s in r){if(typeof e.mapTypes.get(s)==="object"&&typeof e.mapTypes.get(s).maxZoom==="number"){var o=e.mapTypes.get(s).maxZoom;if(o>i){i=o}}}n.maxZoom_=t.maxZoom||19;n.trackMarkers_=t.trackMarkers;n.show_=t.show||true;var u;if(typeof t.borderPadding==="number"){u=t.borderPadding}else{u=MarkerManager.DEFAULT_BORDER_PADDING_}n.swPadding_=new google.maps.Size(-u,u);n.nePadding_=new google.maps.Size(u,-u);n.borderPadding_=u;n.gridWidth_={};n.grid_={};n.grid_[n.maxZoom_]={};n.numMarkers_={};n.numMarkers_[n.maxZoom_]=0;google.maps.event.addListener(e,"dragend",function(){n.onMapMoveEnd_()});google.maps.event.addListener(e,"zoom_changed",function(){n.onMapMoveEnd_()});n.removeOverlay_=function(e){e.setMap(null);n.shownMarkers_--};n.addOverlay_=function(e){if(n.show_){e.setMap(n.map_);n.shownMarkers_++}};n.resetManager_();n.shownMarkers_=0;n.shownBounds_=n.getMapGridBounds_();google.maps.event.trigger(n,"loaded")};MarkerManager.DEFAULT_TILE_SIZE_=1024;MarkerManager.DEFAULT_BORDER_PADDING_=100;MarkerManager.MERCATOR_ZOOM_LEVEL_ZERO_RANGE=256;MarkerManager.prototype.resetManager_=function(){var e=MarkerManager.MERCATOR_ZOOM_LEVEL_ZERO_RANGE;for(var t=0;t<=this.maxZoom_;++t){this.grid_[t]={};this.numMarkers_[t]=0;this.gridWidth_[t]=Math.ceil(e/this.tileSize_);e<<=1}};MarkerManager.prototype.clearMarkers=function(){this.processAll_(this.shownBounds_,this.removeOverlay_);this.resetManager_()};MarkerManager.prototype.getTilePoint_=function(e,t,n){var r=this.projectionHelper_.LatLngToPixel(e,t);var i=new google.maps.Point(Math.floor((r.x+n.width)/this.tileSize_),Math.floor((r.y+n.height)/this.tileSize_));return i};MarkerManager.prototype.addMarkerBatch_=function(e,t,n){var r=this;var i=e.getPosition();e.MarkerManager_minZoom=t;if(this.trackMarkers_){google.maps.event.addListener(e,"changed",function(e,t,n){r.onMarkerMoved_(e,t,n)})}var s=this.getTilePoint_(i,n,new google.maps.Size(0,0,0,0));for(var o=n;o>=t;o--){var u=this.getGridCellCreate_(s.x,s.y,o);u.push(e);s.x=s.x>>1;s.y=s.y>>1}};MarkerManager.prototype.isGridPointVisible_=function(e){var t=this.shownBounds_.minY<=e.y&&e.y<=this.shownBounds_.maxY;var n=this.shownBounds_.minX;var r=n<=e.x&&e.x<=this.shownBounds_.maxX;if(!r&&n<0){var i=this.gridWidth_[this.shownBounds_.z];r=n+i<=e.x&&e.x<=i-1}return t&&r};MarkerManager.prototype.onMarkerMoved_=function(e,t,n){var r=this.maxZoom_;var i=false;var s=this.getTilePoint_(t,r,new google.maps.Size(0,0,0,0));var o=this.getTilePoint_(n,r,new google.maps.Size(0,0,0,0));while(r>=0&&(s.x!==o.x||s.y!==o.y)){var u=this.getGridCellNoCreate_(s.x,s.y,r);if(u){if(this.removeFromArray_(u,e)){this.getGridCellCreate_(o.x,o.y,r).push(e)}}if(r===this.mapZoom_){if(this.isGridPointVisible_(s)){if(!this.isGridPointVisible_(o)){this.removeOverlay_(e);i=true}}else{if(this.isGridPointVisible_(o)){this.addOverlay_(e);i=true}}}s.x=s.x>>1;s.y=s.y>>1;o.x=o.x>>1;o.y=o.y>>1;--r}if(i){this.notifyListeners_()}};MarkerManager.prototype.removeMarker=function(e){var t=this.maxZoom_;var n=false;var r=e.getPosit
Line truncated
|
||||
/* Gmap3 - v6.0.0 - http://gmap3.net - Licensed under GPL v3 */
|
||||
!function(t,n){function e(t){return"object"==typeof t}function o(t){return"string"==typeof t}function i(t){return"number"==typeof t}function a(t){return t===n}function r(){q=google.maps,A||(A={verbose:!1,queryLimit:{attempt:5,delay:250,random:250},classes:function(){var n={};return t.each("Map Marker InfoWindow Circle Rectangle OverlayView StreetViewPanorama KmlLayer TrafficLayer BicyclingLayer GroundOverlay StyledMapType ImageMapType".split(" "),function(t,e){n[e]=q[e]}),n}(),map:{mapTypeId:q.MapTypeId.ROADMAP,center:[46.578498,2.457275],zoom:2},overlay:{pane:"floatPane",content:"",offset:{x:0,y:0}},geoloc:{getCurrentPosition:{maximumAge:6e4,timeout:5e3}}})}function s(t,n){return a(t)?"gmap3_"+(n?Z+1:++Z):t}function u(t){var n,e=q.version.split(".");for(t=t.split("."),n=0;n<e.length;n++)e[n]=parseInt(e[n],10);for(n=0;n<t.length;n++){if(t[n]=parseInt(t[n],10),!e.hasOwnProperty(n))return!1;if(e[n]<t[n])return!1}return!0}function l(n,e,o,i,a){function r(e,i){e&&t.each(e,function(t,e){var r=n,s=e;R(e)&&(r=e[0],s=e[1]),i(o,t,function(t){s.apply(r,[a||o,t,u])})})}var s=e.td||{},u={id:i,data:s.data,tag:s.tag};r(s.events,q.event.addListener),r(s.onces,q.event.addListenerOnce)}function d(t){var n,e=[];for(n in t)t.hasOwnProperty(n)&&e.push(n);return e}function c(t,n){var e,o=arguments;for(e=2;e<o.length;e++)if(n in o[e]&&o[e].hasOwnProperty(n))return void(t[n]=o[e][n])}function p(n,e){var o,i,a=["data","tag","id","events","onces"],r={};if(n.td)for(o in n.td)n.td.hasOwnProperty(o)&&"options"!==o&&"values"!==o&&(r[o]=n.td[o]);for(i=0;i<a.length;i++)c(r,a[i],e,n.td);return r.options=t.extend({},n.opts||{},e.options||{}),r}function f(){if(A.verbose){var t,n=[];if(window.console&&z(console.error)){for(t=0;t<arguments.length;t++)n.push(arguments[t]);console.error.apply(console,n)}else{for(n="",t=0;t<arguments.length;t++)n+=arguments[t].toString()+" ";alert(n)}}}function g(t){return(i(t)||o(t))&&""!==t&&!isNaN(t)}function h(t){var n,o=[];if(!a(t))if(e(t))if(i(t.length))o=t;else for(n in t)o.push(t[n]);else o.push(t);return o}function v(n){return n?z(n)?n:(n=h(n),function(o){var i;if(a(o))return!1;if(e(o)){for(i=0;i<o.length;i++)if(t.inArray(o[i],n)>=0)return!0;return!1}return t.inArray(o,n)>=0}):void 0}function m(t,n,e){var i=n?t:null;return!t||o(t)?i:t.latLng?m(t.latLng):t instanceof q.LatLng?t:g(t.lat)?new q.LatLng(t.lat,t.lng):!e&&R(t)&&g(t[0])&&g(t[1])?new q.LatLng(t[0],t[1]):i}function y(t){var n,e;return!t||t instanceof q.LatLngBounds?t||null:(R(t)?2===t.length?(n=m(t[0]),e=m(t[1])):4===t.length&&(n=m([t[0],t[1]]),e=m([t[2],t[3]])):"ne"in t&&"sw"in t?(n=m(t.ne),e=m(t.sw)):"n"in t&&"e"in t&&"s"in t&&"w"in t&&(n=m([t.n,t.e]),e=m([t.s,t.w])),n&&e?new q.LatLngBounds(e,n):null)}function w(t,n,e,i,a){var r=e?m(i.td,!1,!0):!1,s=r?{latLng:r}:i.td.address?o(i.td.address)?{address:i.td.address}:i.td.address:!1,u=s?G.get(s):!1,l=this;s?(a=a||0,u?(i.latLng=u.results[0].geometry.location,i.results=u.results,i.status=u.status,n.apply(t,[i])):(s.location&&(s.location=m(s.location)),s.bounds&&(s.bounds=y(s.bounds)),M().geocode(s,function(o,r){r===q.GeocoderStatus.OK?(G.store(s,{results:o,status:r}),i.latLng=o[0].geometry.location,i.results=o,i.status=r,n.apply(t,[i])):r===q.GeocoderStatus.OVER_QUERY_LIMIT&&a<A.queryLimit.attempt?setTimeout(function(){w.apply(l,[t,n,e,i,a+1])},A.queryLimit.delay+Math.floor(Math.random()*A.queryLimit.random)):(f("geocode failed",r,s),i.latLng=i.results=!1,i.status=r,n.apply(t,[i]))}))):(i.latLng=m(i.td,!1,!0),n.apply(t,[i]))}function L(n,e,o,i){function a(){do s++;while(s<n.length&&!("address"in n[s]));return s>=n.length?void o.apply(e,[i]):void w(r,function(e){delete e.td,t.extend(n[s],e),a.apply(r,[])},!0,{td:n[s]})}var r=this,s=-1;a()}function b(t,n,e){var o=!1;navigator&&navigator.geolocation?navigator.geolocation.getCurrentPosition(function(i){o||(o=!0,e.latLng=new q.LatLng(i.coords.latitude,i.coords.longitude),n.apply(t,[e]))},function(){o||(o=!0,e.latLng=!1,n.apply(t,[e]))},e.opts.getCurrentPosition):(e.latLng=!1,n.apply(t,[e]))}function x(t){var n,o=!1;if(e(t)&&t.hasOwnProperty("get")){for(n in t)if("get"!==n)return!1;o=!t.get.hasOwnProperty("callback")}return o}function M(){return V.geocoder||(V.geocoder=new q.Geocoder),V.geocoder}function I(){var t=[];this.get=function(n){if(t.length){var o,i,a,r,s,u=d(n);for(o=0;o<t.length;o++){for(r=t[o],s=u.length===r.keys.length,i=0;i<u.length&&s;i++)a=u[i],s=a in r.request,s&&(s=e(n[a])&&"equals"in n[a]&&z(n[a])?n[a].equals(r.request[a]):n[a]===r.request[a]);if(s)return r.results}}},this.store=function(n,e){t.push({request:n,keys:d(n),results:e})}}function P(){var t=[],n=this;n.empty=function(){return!t.length},n.add=function(n){t.push(n)},n.get=function(){return t.length?t[0]:!1},n.ack=function(){t.shift()}}function k(){function n(t){return{id:t.id,name:t.name,object:t.obj,tag:t.tag,data:t.data}}function e(t){z(t.setMap)&&t.setMap(null),z(t.remove)&&t.remove(),z(t.free)&&t.free(),t=null}var o={},i={},r=this;r.add=function(t,n,e,a){var u=t.td||{},l=s(Line truncated
|
||||
Regular → Executable
+39
-2
@@ -3,7 +3,7 @@ function Spot(asGlobals)
|
||||
self = this;
|
||||
this.consts = asGlobals.consts;
|
||||
this.consts.hash_sep = '-';
|
||||
this.consts.title = 'Find Me Spot';
|
||||
this.consts.title = 'Te Araroa';
|
||||
this.consts.default_page = 'messages';
|
||||
|
||||
/* Initialization */
|
||||
@@ -58,6 +58,38 @@ function Spot(asGlobals)
|
||||
return self.vars(asVarName, oValue);
|
||||
};
|
||||
|
||||
/* Interface with server */
|
||||
|
||||
this.get = function(sAction, fOnSuccess, oVars, fOnError, bProcessIcon)
|
||||
{
|
||||
if(!oVars) oVars = {};
|
||||
bProcessIcon = bProcessIcon || false;
|
||||
//if(bProcessIcon) self.addBufferIcon();
|
||||
|
||||
oVars['a'] = sAction;
|
||||
$.ajax(
|
||||
{
|
||||
url: self.consts.process_page,
|
||||
data: oVars,
|
||||
dataType: 'json'
|
||||
})
|
||||
.done(function(oData)
|
||||
{
|
||||
if(oData.result==self.consts.error) fOnError(oData.desc);
|
||||
else
|
||||
{
|
||||
//if(bProcessIcon) self.resetIcon();
|
||||
fOnSuccess(oData.data);
|
||||
}
|
||||
})
|
||||
.fail(function(jqXHR, textStatus, errorThrown)
|
||||
{
|
||||
//if(bProcessIcon) self.resetIcon();
|
||||
if(!fOnError) console.log(textStatus+' '+errorThrown);
|
||||
else fOnError(textStatus);
|
||||
});
|
||||
};
|
||||
|
||||
/* Page Switch - Trigger & Event catching */
|
||||
|
||||
this.onHashChange = function()
|
||||
@@ -181,4 +213,9 @@ function setElem(aoAnchor, asPath, oValue)
|
||||
var sKey = (typeof asPath == 'object')?asPath.shift():asPath;
|
||||
return aoAnchor[sKey] = (!(sKey in aoAnchor) && (oValue in asTypes))?asTypes[oValue]:oValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$.prototype.addIcon = function(sIcon)
|
||||
{
|
||||
return $(this).prepend($('<i>', {'class':'fa '+sIcon}));
|
||||
};
|
||||
Reference in new issue
Block a user