
var JSON=function(){var m={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},s={'boolean':function(x){return String(x);},number:function(x){return isFinite(x)?String(x):'null';},string:function(x){if(/["\\\x00-\x1f]/.test(x)){x=x.replace(/([\x00-\x1f\\"])/g,function(a,b){var c=m[b];if(c){return c;}
c=b.charCodeAt();return'\\u00'+
Math.floor(c/16).toString(16)+
(c%16).toString(16);});}
return'"'+x+'"';},object:function(x){if(x){var a=[],b,f,i,l,v;if(x instanceof Array){a[0]='[';l=x.length;for(i=0;i<l;i+=1){v=x[i];f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){if(b){a[a.length]=',';}
a[a.length]=v;b=true;}}}
a[a.length]=']';}else if(x instanceof Object){a[0]='{';for(i in x){v=x[i];f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){if(b){a[a.length]=',';}
a.push(s.string(i),':',v);b=true;}}}
a[a.length]='}';}else{return;}
return a.join('');}
return'null';}};return{copyright:'(c)2005 JSON.org',license:'http://www.crockford.com/JSON/license.html',stringify:function(v){var f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){return v;}}
return null;},parse:function(text){try{return!(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/"(\\.|[^"\\])*"/g,'')))&&eval('('+text+')');}catch(e){return false;}}};}();
function GeoBounds(minLat,minLng,maxLat,maxLng){this.minLat=minLat;this.maxLat=maxLat;this.minLng=minLng;this.maxLng=maxLng;}
GeoBounds.internalize=function(vl){if(vl["@type"]=="geoJSON:Box"){return geoJSONtoBounds(vl);}else{return new GeoBounds(vl.minLat,vl.minLng,vl.maxLat,vl.maxLng);}}
GeoBounds.prototype.stringify=function(){var minLat=this.minLat.toString().substr(0,8);var maxLat=this.maxLat.toString().substr(0,8);var minLng=this.minLng.toString().substr(0,8);var maxLng=this.maxLng.toString().substr(0,8);return"["+minLng+","+maxLng+","+minLat+","+maxLat+"]";}
GeoBounds.prototype.toStringRss=function(){var minLat=this.minLat.toString().substr(0,8);var maxLat=this.maxLat.toString().substr(0,8);var minLng=this.minLng.toString().substr(0,8);var maxLng=this.maxLng.toString().substr(0,8);return"["+minLat+","+minLng+","+maxLat+","+maxLng+"]";}
GeoBounds.prototype.toStringOpenSearch=function(omitBrackets){var minLat=this.minLat.toString().substr(0,8);var maxLat=this.maxLat.toString().substr(0,8);var minLng=this.minLng.toString().substr(0,8);var maxLng=this.maxLng.toString().substr(0,8);var rs=minLng+","+minLat+","+maxLng+","+maxLat;if(omitBrackets)return rs;return"["+rs+"]";}
GeoBounds.prototype.toString=function(){var minLat=this.minLat.toString().substr(0,8);var maxLat=this.maxLat.toString().substr(0,8);var minLng=this.minLng.toString().substr(0,8);var maxLng=this.maxLng.toString().substr(0,8);return'{"minLng":'+minLng+',"minLat":'+minLat+',"maxLng":'+maxLng+',"maxLat":'+maxLat+'}';}
GeoBounds.prototype.height=function(){return(this.maxLat-this.minLat)*111120.0;}
function GeoPoint(lat,lng){this.lat=lat;this.lng=lng;}
GeoPoint.internalize=function(vl){if(vl["@type"]=="geoJSON:Point"){return geoJSONtoPoint(vl);}else{return new GeoBounds(vl.lat,vl.lng);}}
function pointToGeoPoint(p){return new GeoPoint(p.y,p.x);}
function computeGeoBounds(pnts,minExtent)
{var minLng,maxLng,minY,maxLat;var first=true;for(var idx in pnts){var pnt=pnts[idx];var x=pnt.lng;var y=pnt.lat;if(first){maxLng=x;minLng=x;maxLat=y;minLat=y;first=false;}else{minLng=Math.min(minLng,x);maxLng=Math.max(maxLng,x);minLat=Math.min(minLat,y);maxLat=Math.max(maxLat,y);}}
if(first)return;var bnds=new GeoBounds(minLat,minLng,maxLat,maxLng);if(minExtent){csd=Math.cos(deg2rad(minLat));if(csd<0.001)csd=0.001;var ht=(maxLat-minLat)*111120;var wd=(maxLng-minLng)*111120*csd;if((ht<minExtent)||(wd<minExtent))
bnds=expandBoundsTo(bnds,minExtent/111120,minExtent/(111120*csd));}
return bnds;}
function expandBoundsTo(bnds,latSz,lngSz){if(!lngSz)lngSz=latSz;var minLng=bnds.minLng;var maxLng=bnds.maxLng;var minLat=bnds.minLat;var maxLat=bnds.maxLat;var wd=maxLng-minLng;var ht=maxLat-minLat;newbounds=false;if(wd<lngSz){var cntx=(maxLng+minLng)/2.0;minLng=cntx-0.5*lngSz;maxLng=cntx+0.5*lngSz;var newbounds=true;}
if(ht<latSz){var cnty=(maxLat+minLat)/2.0;minLat=cnty-0.5*latSz;maxLat=cnty+0.5*latSz;newbounds=true;}
if(newbounds)return new GeoBounds(minLat,minLng,maxLat,maxLng);return bnds;}
function expandBoundsBy(bnds,factor){var minLng=bnds.minLng;var maxLng=bnds.maxLng;var minLat=bnds.minLat;var maxLat=bnds.maxLat;var wd=maxLng-minLng;var ht=maxLat-minLat;var cntx=(maxLng+minLng)/2.0;minLng=cntx-0.5*wd*factor;maxLng=cntx+0.5*wd*factor;var cnty=(maxLat+minLat)/2.0;minLat=cnty-0.5*ht*factor;maxLat=cnty+0.5*ht*factor;minLat=Math.max(minLat,-89.99);minLng=Math.max(minLng,-179.99);maxLat=Math.min(maxLat,89.99);maxLng=Math.min(maxLng,179.99);return new GeoBounds(minLat,minLng,maxLat,maxLng);}
function boundsUnion(bnds0,bnds1){var minLng=Math.min(bnds0.minLng,bnds1.minLng);var maxLng=Math.max(bnds0.maxLng,bnds1.maxLng);var minLat=Math.min(bnds0.minLat,bnds1.minLat);var maxLat=Math.max(bnds0.maxLat,bnds1.maxLat);return new GeoBounds(minLat,minLng,maxLat,maxLng);}
function inBounds(pnt,bnds){if(!pnt||!bnds)return 0;var x=pnt.lng;var y=pnt.lat;var minlng=bnds.minLng;var maxlng=bnds.maxLng;var minlat=bnds.minLat;var maxlat=bnds.maxLat;if(y<minlat)return false;if(y>maxlat)return false;if((maxlat-minlat)>100)return true;if(minlng>maxlng){if((minlng<=x)&&(x<=180))return true;if((-180<=x)&&(x<=maxlng))return true;return false;}
if(x<minlng)return false;if(x>maxlng)return false;return true;}
function pointsAreInBounds(pnts,bnds){if(!pnts||!bnds)return 0;var ln=pnts.length;for(var i=0;i<ln;i++){if(!inBounds(pnts[i],bnds))return false;}
return true;}
function toStdLong(x){var rs=x;while(rs<-180)rs=rs+360;while(rs>180)rs=rs-360;return rs;}
function chopBoundsAtLong180(bnds){var minLng=toStdLong(bnds.minLng);var maxLng=toStdLong(bnds.maxLng);if(minLng>maxLng){if((180-minLng)>(maxLng+180)){return new GeoBounds(bnds.minLat,minLng,bnds.maxLat,180);}else{return new GeoBounds(bnds.minLat,-180,bnds.maxLat,maxLng);}}else{return bnds;}}
GeoBounds.prototype.splitAtLong180=function(){var minLng=toStdLong(this.minLng);var maxLng=toStdLong(this.maxLng);if(minLng>maxLng){return[new GeoBounds(this.minLat,minLng,this.maxLat,180),new GeoBounds(this.minLat,-180,this.maxLat,maxLng)];}}
function georssToPoint(st){var sp=st.split(" ");return{lat:parseFloat(sp[0]),lng:parseFloat(sp[1])};}
function geoJSONtoPoint(gp){var c=gp.coordinates;return{lat:c[1],lng:c[0]};}
function geoJSONtoBounds(gp){var c=gp.coordinates;return new GeoBounds(c[0][1],c[0][0],c[1][1],c[1][0]);}
function geoXtoPoint(gpnt){if(typeof gpnt=='object'){if(gpnt["@type"]=="geoJSON:Point"){return geoJSONtoPoint(gpnt);}else{console.log(gpnt);return gpnt;}
return georssToPoint(gpnt);}}
function boundsDiffer(a,b,factor)
{if((!a)&&(!b))return false;if((!a)||(!b))return true;var aminLng=a.minLng;var amaxLng=a.maxLng;var aminLat=a.minLat;var amaxLat=a.maxLat;var awd=Math.abs(amaxLng-aminLng);var acntx=(aminLng+amaxLng)/2.0;var acnty=(aminLat+amaxLat)/2.0;var bminLng=b.minLng;var bmaxLng=b.maxLng;var bminLat=b.minLat;var bmaxLat=b.maxLat;var bwd=Math.abs(bmaxLng-bminLng);var bcntx=(bminLng+bmaxLng)/2.0;var bcnty=(bminLat+bmaxLat)/2.0;if(bwd>awd*(1.0+factor))return true;if(bwd<awd*1.0/(1.0+factor))return true;var dx=bcntx-acntx;var dy=bcnty-acnty;var dst=Math.sqrt(dx*dx+dy*dy);if(dst>factor*awd)return true;return false;}
function deg2rad(x){return(x/180.0)*Math.PI;}
function pointToBounds(gpnt,dist){var latd=dist/111120.0;var lat=gpnt.lat;var lng=gpnt.lng;latmax=Math.min(90,lat+latd);latmin=Math.max(-90,lat-latd);csd=Math.cos(deg2rad(lat));if(csd>0.0001){longd=dist/(111120*csd);longmin=Math.max(-180,lng-longd);longmax=Math.min(180,lng+longd);}else{longmin=-180;longmax=180;}
return new GeoBounds(latmin,longmin,latmax,longmax);}
function boundsToBoundary(bnds){var minlng=bnds.minLng;var maxlng=bnds.maxLng;var minlat=bnds.minLat;var maxlat=bnds.maxLat;var p0=new GeoPoint(minlat,minlng);var p1=new GeoPoint(minlat,maxlng);var p2=new GeoPoint(maxlat,maxlng);var p3=new GeoPoint(maxlat,minlng);var rs=[p0,p1,p2,p3,p0];return rs;}
function boundsIntersect(bnds1,bnds2){return((bnds2.maxLng>bnds1.minLng)&&(bnds1.maxLng>bnds2.minLng))&&((bnds2.maxLat>bnds1.minLat)&&(bnds1.maxLat>bnds2.minLat));}
function propertySwap0(x,prps){if(x==null)return x;var tp=typeof x;if(tp=='object'){var ln=x.length;if(typeof ln=='undefined'){var rs={};for(var p in x){var v=propertySwap0(x[p],prps);var np=prps[p];if(np){rs[np]=v;}else{rs[p]=v;}}}else{rs=[];for(var i=0;i<ln;i++){rs.push(propertySwap0(x[i],prps));}}
return rs;}else{return x;}}
function propertySwap(x,props){var rs=propertySwap0(x,props);return rs;}
var oldToNewProps={"dc:title":"title","rdf:type":"@type","dc:author":"owner","dc:description":"description","georss:point":"geometry","cgeo:featureType":"featureType","dcterm:created":"created","dcterm:modified":"modified","@about":"@id","cgeo:memberName":"memberName","rdfs:seeAlso":"link","mapkit:approvalStatus":"approvalStatus","cgeo:tags":"tags","cgeo:rating":"rating","cgeo:beenTheres":"beenTheres","cgeo:anchorImage":"anchorImage","dc:subject":"topic","platialGeo:anchorThumb":"anchorThumb","rdf:value":"value","tiling:collection":"collection","tiling:level":"level","tiling:x":"x","tiling:y":"y","tiling:tileId":"tileId","tiling:clustered":"clustered","tiling:fullyPopulated":"fullyPopulated","tiling:clusters":"clusters","tiling:places":"places","tiling:requestId":"requestId","tiling:placeCount":"placeCount","tiling:alreadySent":"alreadySent","cgeo:sizedImage":"sizedImage","cgeo:width":"width","cgeo:height":"height","cgeo:fullAddressText":"address","cgeo:imageLink":"imageLink","cgeo:averageRating":"averageRating","cgeo:ratingCount":"ratingCount","cgeo:accuracyCode":"accuracyCode","dc:source":"source","dc:date":"date","cgeo:inMaps":"inMaps","platialGeo:sliderLayer":"sliderLayer","platialGeo:deleted":"deleted","cgeo:images":"images","dc:category":"category","cgeo:layers":"layers"};var newToOldProps=(function(){var rs={}
for(var i in oldToNewProps){var np=oldToNewProps[i];rs[np]=i;}
return rs;})();var oldv=null;var newv=null;var oldvs=[];var newvs=[];function toNewDF(x){oldv=x;newv=propertySwap(x,oldToNewProps);return newv;}
function toOldDF(x){return propertySwap(x,newToOldProps);}
var oprops=null;function toOldProps(prps){var rs=[];var ln=prps.length;for(var i=0;i<ln;i++){var p=prps[i];var np=newToOldProps[p];if(np)rs.push(np);else rs.push(p);}
oprops=rs;return rs;}
var tPlacesById;var tPlaces;function tCollectTopic(pst){if(pst["@type"]=="cgeo:Place")alert('internal error tCollectPlaces')
var tp=pst.topic;if(!tp)return null;var fullid=tp["@id"];var itid=fullid.split(":")[1];var cPlace=tPlacesById[itid];if(cPlace){cPlace.descriptors.push(pst);}else{tPlacesById[itid]=tp;tp.descriptors=[pst];}}
function postToEnrichedPlace(pst){if(pst["@type"]=="cgeo:Place")return pst;var tp=pst.topic;if(!tp)return null;tp.title=pst.title;if(!tp.title)tp.title="No title";if(!tp["@id"])tp["@id"]=pst["@id"];if(pst.tags)tp.tags=pst.tags;if(pst.thumb)var theThumb=pst.thumb;else
if(pst.anchorThumb)theThumb=pst.anchorThumb;if(theThumb){tp.anchorThumb=theThumb;tp.thumb=theThumb;}
tp.descriptors=[pst];if(pst.category)tp.category=pst.category;return tp;}
function postsToEnrichedPlaces(psts){tPlacesById={};psts.each(tCollectTopic);var rs=[];for(var i in tPlacesById)rs.push(tPlacesById[i]);return rs;}
var platialApiQueue=[];var platialApi;function platialApiDispatchCall(){if(platialApi.openSessionError)return;var ln=platialApiQueue.length;if(ln==0)return;if((!platialApi.sessionOpened)&&(!platialApi.openingSession))return;platialApi.openingSession=false;var script=document.createElement('script');script.type='text/javascript';var ssrc=platialApiQueue[0];script.src=ssrc;for(var i=0;i<(ln-1);i++)platialApiQueue[i]=platialApiQueue[i+1];platialApiQueue.pop();if(navigator.userAgent.indexOf('Safari'))script.charset='utf-8';script=document.getElementsByTagName('head')[0].appendChild(script);}
function stripTrailingSlash(h){var ln=h.length;if(h[ln-1]=="/")return h.substr(0,ln-1);else return h;}
function PlatialApi(){this.sessionOpened=false;this.openingSession=false;this.apiKey=apiKey;this.apiLevel=28;this.alias=platialAlias;this.memberName=platialMemberName;this.apiCode=stripTrailingSlash(window.location.host);this.scripts=[];this.version=2;this.host=null;this.sessionId=null;this.openSessionError=false;}
function PlatialCall(method){this["api:method"]="api:"+method;}
PlatialApi.prototype.checkDate=function(dt){var tms=Date.parse(dt);if(tms==tms){var st=new Date(tms).toString();var rst=st.split("GMT")[0];return rst;}else{return false;}}
var PlatialWhereOps={"=":"api:equal","<":"api:lessp",">":"api:greaterp","<=":"api:leq",">=":"api:geq"};function PlatialWhere(prop,op,value){var opname=PlatialWhereOps[op];if(!opname)opname=op;this["rdf:type"]="api:PropertyRestriction";this["api:Method"]=opname;this["arg:property"]=prop;this["arg:value"]=value;}
PlatialApi.prototype.commafy=function(vls){var rs="";var nf=false;var ln=vls.length;for(var i=0;i<ln;i++){if(nf)rs+=",";rs+='"'+vls[i]+'"';nf=true;}
return rs;}
PlatialApi.prototype.cleanup=function(){var ps=this.scripts;for(var i=0;i<ps.length;i++){scr=ps[i];if(scr.parentNode)
scr.parentNode.removeChild(scr);}}
var efi;function platialErrorFilter(x){efi=x;var tp=x["rdf:type"];if(tp=="api:Error"){alert("ERROR: "+x["dc:description"]);return null;}
return x;}
var callob;var calltext;var restCall;var lastCalltext;var lastRestCall;var lastRestCall2;var aabbcc=333;PlatialApi.prototype.call=function(icallback,callvl){callob=callvl;this.lastCall=callvl;callvl["api:version"]=this.version;callvl["arg:api_key"]=this.apiKey;callvl["arg:api_code"]=this.apiCode;var sessionGetArg="";if(this.sessionId!='0'){callvl["arg:session_id"]=this.sessionId;callvl["arg:time"]=new Date().getTime();sessionGetArg="&session="+(this.sessionId);}
var alias=this.alias;if(alias)callvl["arg:alias"]=alias;var memberName=this.memberName;if(memberName)callvl["arg:memberName"]=memberName;if(typeof icallback=='object'){var ln=icallback.length;var cb=icallback[0];var cba=[];for(var i=1;i<ln;i++){cba[i-1]=icallback[i];}
callvl["arg:callbackArguments"]=cba;var callback=icallback[0];}else{callback=icallback;}
if(typeof callvl=="string"){calltext=callvl;}else{calltext=JSON.stringify(callvl);}
lastCalltext=calltext;consolelog(calltext);var calltext=encodeURIComponent(calltext);var domain=new String(document.domain);var restCall="http://"+this.host+"/rest?callback="+callback+"&json="+calltext+sessionGetArg;lastRestCall2=lastRestCall;lastRestCall=restCall;platialApiQueue.push(restCall);setTimeout("platialApiDispatchCall()",100);}
PlatialApi.prototype.mkSelectMembers=function(colId,bnds,props,offset,limit){var cl={};cl["api:method"]="api:selectMembers";cl["arg:ofType"]="cgeo:Post";if(parseInt(colId)==colId)colId='platialCollection:'+colId;cl["arg:collection"]=colId;if(bnds){cl["arg:bounds"]=bnds.stringify();}
cl["arg:properties"]=toOldProps(props);cl["arg:limit"]=limit;cl["arg:offset"]=offset;cl["arg:api_key"]=this.apiKey;cl["arg:api_code"]=this.apiCode;return cl;}
PlatialApi.prototype.selectMembers=function(callback,colId,bnds,props,offset,limit){var cl=this.mkSelectMembers(colId,bnds,props,offset,limit);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkGetTile=function(colId,level,xIndex,yIndex,props){var cl={};cl["api:method"]="api:getTile";if(parseInt(colId)==colId)colId='platialCollection:'+colId;cl["arg:collection"]=colId;cl["arg:properties"]=toOldProps(props);cl["arg:level"]=level;cl["arg:xIndex"]=xIndex;cl["arg:yIndex"]=yIndex;return cl;}
PlatialApi.prototype.getTile=function(callback,colId,level,xIndex,yIndex,props){var cl=this.mkGetTile(colId,level,xIndex,yIndex,props);cls=JSON.stringify(cl);this.call(callback,cls);}
PlatialApi.prototype.mkGetTiles=function(colId,level,indices,requestId,props,firstCall){var cl={};cl["api:method"]="api:getTiles";if(parseInt(colId)==colId)colId='platialCollection:'+colId;cl["arg:collection"]=colId;cl["arg:properties"]=toOldProps(props);cl["arg:level"]=level;cl["arg:indices"]=indices;cl["arg:firstCall"]=firstCall;cl["arg:requestId"]=requestId;return cl;}
PlatialApi.prototype.getTiles=function(callback,colId,level,indices,requestId,props,firstCall){var cl=this.mkGetTiles(colId,level,indices,requestId,props,firstCall);this.call(callback,cl);}
PlatialApi.prototype.mkGetCTiles=function(colId,ids,props){var cl={};cl["api:method"]="api:getCTiles";if(parseInt(colId)==colId)colId='platialCollection:'+colId;cl["arg:collection"]=colId;cl["arg:properties"]=toOldProps(props);cl["arg:tileIds"]=ids;return cl;}
PlatialApi.prototype.getCTiles=function(callback,colId,ids,props){var cl=this.mkGetCTiles(colId,ids,props);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkGetCoveringTiles=function(colId,level,indices){var cl={};cl["api:method"]="api:getCoveringTiles";if(parseInt(colId)==colId)colId='platialCollection:'+colId;cl["arg:collection"]=colId;cl["arg:level"]=level;cl["arg:indices"]=indices;return cl;}
PlatialApi.prototype.getCoveringTiles=function(callback,colId,level,indices){var cl=this.mkGetCoveringTiles(colId,level,indices);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkGetCell=function(colId,level,x,y){var cl={};cl["api:method"]="api:getCell";if(parseInt(colId)==colId)colId='platialCollection:'+colId;cl["arg:collection"]=colId;cl["arg:level"]=level;cl["arg:x"]=x;cl["arg:y"]=y;return cl;}
PlatialApi.prototype.getCell=function(callback,colId,level,x,y){var cl=this.mkGetCell(colId,level,x,y);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkGetSliderTiles=function(colId,level,indices,props,firstCall){var cl={};cl["api:method"]="api:getSliderTiles";if(parseInt(colId)==colId)colId='platialCollection:'+colId;cl["arg:collection"]=colId;cl["arg:properties"]=toOldProps(props);cl["arg:level"]=level;cl["arg:firstCall"]=firstCall;cl["arg:indices"]=indices;return cl;}
PlatialApi.prototype.getSliderTiles=function(callback,colId,level,indices,props,firstCall){var cl=this.mkGetSliderTiles(colId,level,indices,props,firstCall);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkSearch=function(what,bnds,props,offset,limit,backfill){var cl={};cl["api:method"]="api:search";cl["arg:ofType"]="cgeo:Post";cl["arg:what"]=what;cl["arg:properties"]=toOldProps(props);cl["arg:limit"]=limit;cl["arg:offset"]=offset;if(bnds){cl["arg:bounds"]=bnds.toStringRss();}
if(backfill){cl["arg:backfill"]=true;}
return cl;}
PlatialApi.prototype.search=function(callback,what,bnds,props,offset,limit,backfill){var cl=this.mkSearch(what,bnds,props,offset,limit,backfill);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkSelectMembersPendingApproval=function(colId,props){var cl={};cl["api:method"]="api:selectMembers";if(parseInt(colId)==colId)colId='platialCollection:'+colId;cl["arg:collection"]=colId;cl["arg:properties"]=toOldProps(props);cl["arg:pendingApproval"]=true;return cl;}
PlatialApi.prototype.selectMembersPendingApproval=function(callback,colId,props){var cl=this.mkSelectMembersPendingApproval(colId,props);this.call(callback,cl);}
PlatialApi.prototype.mkCountMembersPendingApproval=function(colId){var cl={};cl["api:method"]="api:selectMembers";if(parseInt(colId)==colId)colId='platialCollection:'+colId;cl["arg:collection"]=colId;cl["arg:countOnly"]=true;cl["arg:pendingApproval"]=true;return cl;}
PlatialApi.prototype.countMembersPendingApproval=function(callback,colId){var cl=this.mkCountMembersPendingApproval(colId);this.call(callback,cl);}
PlatialApi.prototype.mkSelectMembersAbout=function(collection,subject,props,imageWidth,approvedOnly){var cl={};cl["api:method"]="api:selectMembers";cl["arg:collection"]=collection;cl["arg:properties"]=toOldProps(props);cl["arg:subject"]=subject;if(imageWidth)cl["arg:imageWidth"]=imageWidth;if(approvedOnly)cl["arg:approvedOnly"]=approvedOnly;return cl;}
PlatialApi.prototype.selectMembersAbout=function(callback,collection,subject,props,imageWidth,approvedOnly){var cl=this.mkSelectMembersAbout(collection,subject,props,imageWidth,approvedOnly);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkSelectCollectionPlaces=function(colId,bnds,props,offset,limit,pendingApproval){var cl={};cl["api:method"]="api:selectCollectionPlaces";cl["arg:ofType"]="cgeo:Post";if(parseInt(colId)==colId)colId='platialCollection:'+colId;cl["arg:collection"]=colId;if(bnds){cl["arg:bounds"]=bnds.stringify();}
cl["arg:properties"]=toOldProps(props);cl["arg:limit"]=limit;cl["arg:offset"]=offset;cl["arg:api_key"]=this.apiKey;cl["arg:api_code"]=this.apiCode;if(pendingApproval)cl["arg:pendingApproval"]=true;return cl;}
PlatialApi.prototype.selectCollectionPlaces=function(callback,colId,bnds,props,offset,limit,pendingApproval){var cl=this.mkSelectCollectionPlaces(colId,bnds,props,offset,limit,pendingApproval);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.selectCollectionPlacesPendingApproval=function(callback,colId,bnds,props,offset,limit){var cl=this.mkSelectCollectionPlaces(colId,bnds,props,offset,limit,true);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkSetApprovalStatus=function(collection,item,vl){var cl={};cl["api:method"]="api:setApprovalStatus";if(parseInt(collection)==collection)collection='platialCollection:'+collection;if(parseInt(item)==item)item='platialItem:'+item;cl["arg:collection"]=collection;cl["arg:subject"]=item;cl["arg:value"]=vl;return cl;}
PlatialApi.prototype.setApprovalStatus=function(callback,collection,item,vl){var cl=this.mkSetApprovalStatus(collection,item,vl);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkRateItem=function(collection,item,vl){var cl={};cl["api:method"]="api:rateItem";if(parseInt(collection)==collection)collection='platialCollection:'+collection;if(parseInt(item)==item)item='platialItem:'+item;cl["arg:collection"]=collection;cl["arg:subject"]=item;cl["arg:rating"]=vl;return cl;}
PlatialApi.prototype.rateItem=function(callback,collection,item,vl){var cl=this.mkRateItem(collection,item,vl);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkClearCollectionCache=function(colId){var cl={};cl["api:method"]="api:clearCollectionCache";if(parseInt(colId)==colId)colId='platialCollection:'+colId;cl["arg:collection"]=colId;return cl;}
PlatialApi.prototype.clearCollectionCache=function(callback,colId){var cl=this.mkClearCollectionCache(colId);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkSelect=function(tp,bnds,props,offset,limit){var cl={};cl["api:method"]="api:select";cl["arg:ofType"]=tp;cl["arg:properties"]=toOldProps(props);cl["arg:limit"]=limit;cl["arg:offset"]=offset;cl["arg:api_key"]=this.apiKey;cl["arg:api_code"]=this.apiCode;if(bnds){cl["arg:bounds"]=bnds.stringify();}
cl["arg:sortBy"]="dcterm:created";cl["arg:sortDirection"]="descending";return cl;}
PlatialApi.prototype.select=function(callback,tp,bnds,props,offset,limit){var cl=this.mkSelect(tp,bnds,props,offset,limit);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkGet=function(itemId,props){var cl=new PlatialCall("get");cl["subject"]=itemId;cl["properties"]=toOldProps(props);return cl;}
PlatialApi.prototype.get=function(callback,itemId,props){var cl=this.mkGet(itemId,props);this.call(callback,cl);}
PlatialApi.prototype.mkRights=function(x){var cl=new PlatialCall("rights");cl["subject"]=x;return cl;}
PlatialApi.prototype.rights=function(callback,x){var cl=this.mkRights(x);this.call(callback,cl);}
PlatialApi.prototype.mkGeocode=function(address){var cl=new PlatialCall("geocode");cl["arg:address"]=address;return cl;}
PlatialApi.prototype.geocode=function(callback,address){this.call(callback,this.mkGeocode(address));}
PlatialApi.prototype.mkRemoveAllElements=function(col){var cl=new PlatialCall("removeAllElements");cl["arg:collection"]=col;return cl;}
PlatialApi.prototype.removeAllElements=function(callback,col){this.call(callback,this.mkRemoveAllElements(col));}
PlatialApi.prototype.mkGetAnchorPost=function(collection,place,props,imageWidth,alternateImageWidths){var cl={};cl["api:method"]="api:getAnchorPost";cl["arg:subject"]=place;cl["arg:collection"]=collection;cl["arg:properties"]=toOldProps(props);if(imageWidth)cl["arg:imageWidth"]=imageWidth;if(alternateImageWidths)cl["arg:alternateImageWidths"]=alternateImageWidths;return cl;}
PlatialApi.prototype.getAnchorPost=function(callback,collection,place,props,imageWidth,alternateImageWidths){this.call(callback,this.mkGetAnchorPost(collection,place,props,imageWidth,alternateImageWidths));}
PlatialApi.prototype.mkGetComments=function(post){var cl={};cl["api:method"]="api:getComments";cl["arg:subject"]=post;return cl;}
PlatialApi.prototype.getComments=function(callback,post){this.call(callback,this.mkGetComments(post));}
PlatialApi.prototype.mkGetPostsOnPlace=function(itemId,collection,props,byCurrentUser){var cl={};cl["api:method"]="api:getPostsOnPlace";cl["arg:subject"]=itemId;cl["arg:properties"]=toOldProps(props);cl["arg:byCurrentUser"]=byCurrentUser;if(collection)cl["collection"]=collection;return cl;}
PlatialApi.prototype.getPostsOnPlace=function(callback,item,collection,props,byCurrentUser){this.call(callback,this.mkGetPostsOnPlace(item,collection,props,byCurrentUser));}
PlatialApi.prototype.getMyPostsOnPlace=function(callback,item,props){this.call(callback,this.mkGetPostsOnPlace(item,null,props,true));}
PlatialApi.prototype.mkDeleteFromCollection=function(itemId,collection){var cl={};cl["api:method"]="api:deleteFromCollection";cl["arg:subject"]=itemId;cl["arg:collection"]=collection;return cl;}
PlatialApi.prototype.deleteFromCollection=function(callback,item,collection){var dl=this.mkDeleteFromCollection(item,collection);this.call(callback,dl);}
PlatialApi.prototype.mkInsertPlace=function(title,address,location,props,memberName){var cl={};cl["api:method"]="api:insert";if(props)cl["properties"]=toOldProps(props);var vl={};vl["rdf:type"]="cgeo:Place";vl["dc:title"]=title;if(address)vl["cgeo:fullAddressText"]=address;if(location)vl["georss:point"]=location;if(memberName)vl["cgeo:memberName"]=memberName;cl["arg:value"]=vl;if(typeof platialExternalApi!='undefined')cl["arg:identifyFirst"]=1;return cl;}
PlatialApi.prototype.insertPlace=function(callback,title,address,location,props,memberName){var cl=this.mkInsertPlace(title,address,location,props,memberName);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkInsertTopic=function(vl,props){var cl={};cl["api:method"]="api:insert";if(props)cl["properties"]=toOldProps(props);vl["rdf:type"]="cgeo:Place";cl["arg:value"]=vl;return cl;}
PlatialApi.prototype.insertTopic=function(callback,vl,props){var cl=this.mkInsertTopic(vl,props);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkInsert=function(vl,props){var cl={};cl["api:method"]="api:insert";if(props)cl["properties"]=toOldProps(props);cl["arg:value"]=vl;return cl;}
PlatialApi.prototype.insert=function(callback,vl,props){var cl=this.mkInsert(vl,props);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkUpdate=function(vl,props){var cl={};cl["api:method"]="api:update";if(props)cl["properties"]=toOldProps(props);cl["arg:value"]=vl;return cl;}
PlatialApi.prototype.update=function(callback,vl,props){var cl=this.mkUpdate(vl,props);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkIdentifyPlacesByAddress=function(title,address,props,strict){var cl={};cl["api:method"]="api:identify";cl["arg:properties"]=toOldProps(props);var vl={};vl["rdf:type"]="cgeo:Place";vl["dc:title"]=title;vl["cgeo:fullAddressText"]=address;cl["arg:value"]=vl;if(strict){cl["arg:strict"]=true;}
return cl;}
PlatialApi.prototype.identifyPlacesByAddress=function(callback,title,address,props,strict){var cl=this.mkIdentifyPlacesByAddress(title,address,props,strict);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkInsertPost=function(title,description,place,props,memberName){var cl={};cl["api:method"]="api:insert";if(props)cl["properties"]=toOldProps(props);var vl={};vl["rdf:type"]="cgeo:Post";vl["dc:title"]=title;vl["dc:subject"]=place;if(description)vl["dc:description"]=description;if(memberName)vl["cgeo:memberName"]=memberName;cl["arg:value"]=vl;return cl;}
PlatialApi.prototype.insertPost=function(callback,title,description,place,props,memberName){var cl=this.mkInsertPost(title,description,place,props,memberName);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkInsertPostObject=function(vl,place,props){var cl={};cl["api:method"]="api:insert";if(props)cl["properties"]=toOldProps(props);vl["rdf:type"]="cgeo:Post";vl["dc:subject"]=place;cl["arg:value"]=vl;return cl;}
PlatialApi.prototype.insertPostObject=function(callback,vl,place,props){var cl=this.mkInsertPostObject(vl,place,props);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkAddComment=function(comment,item,props,memberName){var cl={};cl["api:method"]="api:insert";if(props)cl["properties"]=toOldProps(props);var vl={};vl["rdf:type"]="cgeo:Comment";vl["dc:title"]='comment';vl["dc:subject"]=item;vl["dc:description"]=comment;if(memberName)vl["cgeo:memberName"]=memberName;cl["arg:value"]=vl;return cl;}
PlatialApi.prototype.addComment=function(callback,comment,item,props,memberName){var cl=this.mkAddComment(comment,item,props,memberName);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkSetBeenThere=function(item,value){var cl={};cl["api:method"]="api:setBeenThere";cl["arg:subject"]=item;cl["arg:value"]=value;return cl;}
PlatialApi.prototype.setBeenThere=function(callback,item,value){var cl=this.mkSetBeenThere(item,value);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkAddTags=function(item,tags){var cl={};cl["api:method"]="api:addTags";cl["arg:subject"]=item;cl["arg:tags"]=tags
return cl;}
PlatialApi.prototype.addTags=function(callback,item,tags){var cl=this.mkAddTags(item,tags);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkRemoveTags=function(item,tags){var cl={};cl["api:method"]="api:removeTags";cl["arg:subject"]=item;cl["arg:tags"]=tags
return cl;}
PlatialApi.prototype.removeTags=function(callback,item,tags){var cl=this.mkRemoveTags(item,tags);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkAddToMaps=function(item,maps){var cl={};cl["api:method"]="api:addToMaps";cl["arg:subject"]=item;cl["arg:maps"]=maps
return cl;}
PlatialApi.prototype.addToMaps=function(callback,item,maps){var cl=this.mkAddToMaps(item,maps);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkRemoveFromMaps=function(item,maps){var cl={};cl["api:method"]="api:removeFromMaps";cl["arg:subject"]=item;cl["arg:maps"]=maps
return cl;}
PlatialApi.prototype.removeFromMaps=function(callback,item,maps){var cl=this.mkRemoveFromMaps(item,maps);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkGetUserMaps=function(){var cl={};cl["api:method"]="api:getUserMaps";return cl;}
PlatialApi.prototype.getUserMaps=function(callback){var cl=this.mkGetUserMaps();cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkAddNewElement=function(collection,item,props,nonce){var cl={};cl["api:method"]="api:addNewElement";cl["arg:collection"]=collection;cl["arg:nonce"]=nonce;if(props)cl["arg:properties"]=toOldProps(props);cl["arg:value"]=item;return cl;}
PlatialApi.prototype.addNewElement=function(callback,collection,item,props,nonce){var cl=this.mkAddNewElement(collection,item,props,nonce);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkInsertPost=function(collection,item,subject,props,nonce){var cl={};cl["api:method"]="api:addNewElement";cl["arg:collection"]=collection;item["dc:subject"]=subject;cl["arg:nonce"]=nonce;if(props)cl["arg:properties"]=toOldProps(props);cl["arg:value"]=item;return cl;}
PlatialApi.prototype.insertPost=function(callback,collection,item,subject,props,nonce){var cl=this.mkInsertPost(collection,item,subject,props,nonce);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkAddCommentWithinCollection=function(collection,subject,comment){var cl={};cl["api:method"]="api:addCommentWithinCollection";cl["arg:collection"]=collection;cl["arg:subject"]=subject;cl["arg:comment"]=comment;return cl;}
PlatialApi.prototype.addCommentWithinCollection=function(callback,collection,subject,comment){var cl=this.mkAddCommentWithinCollection(collection,subject,comment);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkSetMapStyle=function(collection,style){var cl={};cl["api:method"]="api:setMapStyle";cl["arg:collection"]=collection;cl["arg:style"]=style;return cl;}
PlatialApi.prototype.setMapStyle=function(callback,collection,style){var cl=this.mkSetMapStyle(collection,style);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkGetMapStyle=function(collection){var cl={};cl["api:method"]="api:getMapStyle";cl["arg:collection"]=collection;return cl;}
PlatialApi.prototype.getMapStyle=function(callback,collection){var cl=this.mkGetMapStyle(collection,style);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkAllocPostInCollection=function(post,place,collection,props){var cl={};cl["api:method"]="api:allocPostInCollection";cl["arg:collection"]=collection;if(props)cl["properties"]=toOldProps(props);post["dc:subject"]=place;cl["arg:value"]=post;return cl;}
PlatialApi.prototype.allocPostInCollection=function(callback,post,place,collection,props){var cl=this.mkAllocPostInCollection(post,place,collection,props);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkAddPendingPostToCollection=function(post,place,collection,props){var cl={};cl["api:method"]="api:addPendingPostToCollection";cl["arg:collection"]=collection;if(props)cl["properties"]=toOldProps(props);post["dc:subject"]=place;cl["arg:value"]=post;return cl;}
PlatialApi.prototype.addPendingPostToCollection=function(callback,post,place,collection,props){var cl=this.mkAddPendingPostToCollection(post,place,collection,props);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkUpdateItem=function(vl,props,nonce){var cl={};cl["api:method"]="api:update";cl["arg:nonce"]=nonce;if(props)cl["properties"]=toOldProps(props);vl["rdf:type"]="cgeo:Post";cl["arg:value"]=vl;return cl;}
PlatialApi.prototype.updateItem=function(callback,vl,props,nonce){var cl=this.mkUpdateItem(vl,props,nonce);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.setDescription=function(callback,item,description,props){var vl={};vl["@about"]=item;vl["dc:description"]=description;var cl=this.mkUpdateItem(vl,toOldProps(props));this.call(callback,cl);}
PlatialApi.prototype.setDescriptionByMember=function(callback,item,description,memberName,props){var vl={};vl["@about"]=item;vl["dc:description"]=description;vl["cgeo:memberName"]=memberName;var cl=this.mkUpdateItem(vl,toOldProps(props));this.call(callback,cl);}
PlatialApi.prototype.mkAddElement=function(collection,value){var cl={};cl["api:method"]="api:addElement";cl["arg:collection"]=collection;cl["arg:value"]=value;return cl;}
PlatialApi.prototype.addElement=function(callback,collection,value){var cl=this.mkAddElement(collection,value);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkAddFeed=function(collection,url){var cl={};cl["api:method"]="api:addFeed";cl["arg:collection"]=collection;cl["arg:url"]=url;return cl;}
PlatialApi.prototype.addFeed=function(callback,collection,url){var cl=this.mkAddFeed(collection,url);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkDeleteImage=function(item,image){var cl=new PlatialCall("deleteImage");if(typeof item=='string')var itmarg=item;else itmarg=item["@about"];cl["arg:subject"]=itmarg;cl["arg:image"]=image;return cl;}
PlatialApi.prototype.deleteImage=function(callback,item,imageId){var cl=this.mkDeleteImage(item,imageId);this.call(callback,cl);}
PlatialApi.prototype.genMapKitCode=function(callback,collection){var cl={};cl["api:method"]="api:genMapKitCode";cl["arg:collection"]=collection;cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkPing=function(){var cl={};cl["api:method"]="api:ping";cl["arg:api_key"]=this.apiKey;cl["arg:api_code"]=this.apiCode;return cl;}
PlatialApi.prototype.ping=function(callback){var cl=this.mkPing();cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkOpenSession=function(){var cl={};cl["api:method"]="api:openSession";cl["arg:getGoogleMapsKey"]=1;return cl;}
PlatialApi.prototype.openSession=function(callback){this.openingSession=true;var cl=this.mkOpenSession();cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkOpenNewSession=function(){var cl={};cl["api:method"]="api:openNewSession";return cl;}
PlatialApi.prototype.openNewSession=function(callback){this.openingSession=true;var cl=this.mkOpenNewSession();cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkLog=function(msg){var cl={};cl["api:method"]="api:log";cl["arg:api_key"]=this.apiKey;cl["arg:api_code"]=this.apiCode;cl["arg:host"]=this.host;cl["arg:message"]=msg;return cl;}
PlatialApi.prototype.log=function(callback,msg){var cl=this.mkLog(msg);cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.mkRequestPlatialAccess=function(){var cl={};cl["api:method"]="api:requestPlatialAccess";cl["arg:api_key"]=this.apiKey;cl["arg:api_code"]=this.apiCode;return cl;}
PlatialApi.prototype.requestPlatialAccess=function(callback){var cl=this.mkRequestPlatialAccess();cls=JSON.stringify(cl);this.call(callback,cl);}
PlatialApi.prototype.openSessionCallback=function(rs){if(rs["rdf:type"]=="api:Error"){this.openSessionError=true;}else{this.sessionOpened=true;var vl=rs["rdf:value"];if(vl!="ok")platialApi.username=vl;platialApiDispatchCall();}}
var osess;PlatialApi.prototype.openNewSessionCallback=function(rs){osess=rs;if(rs["rdf:type"]=="api:Error"){this.openSessionError=true;}else{this.sessionOpened=true;var vl=rs["rdf:value"];platialApi.username=vl["user"];platialApi.sessionId=vl["sessionId"];}}
PlatialApi.prototype.mkGetUserFavorites=function(bnds,props,offset,limit){var cl={};cl["api:method"]="api:getUserFavorites";cl["arg:ofType"]="cgeo:Post";if(bnds){cl["arg:bounds"]=bnds.stringify();}
cl["arg:properties"]=toOldProps(props);cl["arg:limit"]=limit;cl["arg:offset"]=offset;cl["arg:api_key"]=this.apiKey;cl["arg:api_code"]=this.apiCode;return cl;}
PlatialApi.prototype.getUserFavorites=function(callback,bnds,props,offset,limit){var cl=this.mkGetUserFavorites(bnds,props,offset,limit);cls=JSON.stringify(cl);this.call(callback,cl);}
function consolelog(msg){if(typeof console!='undefined'){console.log(msg);}}
var enableApiV2=true;var gVectorTileLoadCount=0;var gTileLoadListeners=[];function addTileLoadListener(listener)
{for(var i=0;i<gTileLoadListeners.length;i++)
{if(gTileLoadListeners[i]==listener)return;}
gTileLoadListeners.push(listener);}
function removeTileLoadListener(listener)
{for(var i=0;i<gTileLoadListeners.length;i++)
{if(gTileLoadListeners[i]==listener)
{gTileLoadListeners.splice(i,1);return;}}}
function notifyTileLoadListeners()
{for(var i=0;i<gTileLoadListeners.length;i++)
{var listener=gTileLoadListeners[i];if(listener.onTileLoadComplete)
{listener.onTileLoadComplete();}}}
function consoleLog(st){if(typeof console=='undefined')return;if(typeof console.log=='undefined')return;console.log(st);}
function PlatialApiV2(){if(typeof platialMemberName!='undefined')
this.memberName=platialMemberName;this.token=null;}
PlatialApiV2.prototype.uriIndex=function(s){var sp=s.split(":");return sp[1];}
PlatialApiV2.prototype.itemIndex=function(itm){if(!itm)return null;if(typeof itm=='number')return itm;if(typeof itm=='string')return this.uriIndex(itm);if(typeof itm!='object')return null;var abt=itm["@id"];if(abt)return this.uriIndex(abt);return null;}
PlatialApiV2.prototype.addHeaders=function(xhr){if(remoteMapKit&&platialToken){consoleLog("["+remoteMapKit+" addHeader Platial_token "+platialToken+"]");xhr.setHeader('platial_token',platialToken);}
return xhr;}
PlatialApiV2.prototype.callApi=function(callback,httpMethod,path,arguments){var xhr=new XHR({method:httpMethod});xhr.onSuccess=function(){var txt=xhr.transport.responseText;if(callback){if(typeof callback!=Function)
{callback=eval(callback);}
callback(txt);}};var url=path;if(!arguments){arguments={}}
var qs=Object.toQueryString(arguments);this.addHeaders(xhr);xhr.send(url,qs);}
PlatialApiV2.prototype.errorValue=function(code,msg){var rs={"@type":"Wrapper","error":code};if(msg){rs.message=msg;}
return rs;}
PlatialApiV2.prototype.errorString=function(code,msg){var rs=this.errorValue(code,msg);return JSON.stringify(rs);}
PlatialApiV2.prototype.getPlace=function(callback,placeId,props){var args={};if(props)args.properties=props;var path="/api_v2/place/"+placeId;this.callApi(callback,'get',path,args);}
PlatialApiV2.prototype.getDescriptor=function(callback,dId,props){var args={};if(props)args.properties=props;var path="/api_v2/descriptor/"+dId;this.callApi(callback,'get',path,args);}
PlatialApiV2.prototype.getMap=function(callback,mapId,props){var args={};if(props)args.properties=props;var path="/api_v2/map/"+mapId;this.callApi(callback,'get',path,args);}
PlatialApiV2.prototype.update=function(callback,item,props){var args={value:JSON.stringify(item)};var itemId=this.itemIndex(item);if(props)args.properties=JSON.stringify(props);var tp=item["@type"];if(tp=="cgeo:Post"){var tpn="descriptor";}else if(tp=="cgeo:Place"){tpn="place";}else if(tp=="cgeo:Map"){tpn="map";}else{callback(this.errorString("badOrMissingUpdateType"));return;}
var path="/api_v2/"+tpn+"/"+itemId+"/update()";this.callApi(callback,'post',path,args);}
PlatialApiV2.prototype.deleteFromMap=function(callback,item,collection){var iid=this.itemIndex(item);var sitm={"@id":iid};var clid=this.itemIndex(collection);var path="/api_v2/map/"+clid+"/removeMembers()";var args={"value":JSON.stringify([sitm])};this.callApi(callback,'post',path,args);}
PlatialApiV2.prototype.deletePost=function(callback,item){var tp=item["@type"];var iid=this.itemIndex(item);var path="/api_v2/descriptor/"+iid+"/delete()";this.callApi(callback,'post',path,{});}
PlatialApiV2.prototype.addComment=function(callback,item,value){var iid=this.itemIndex(item);var path="/api_v2/descriptor/"+iid+"/addComment()";var args={"value":value};this.callApi(callback,'post',path,args);}
PlatialApiV2.prototype.search=function(callback,query,bounds,props,count,offset,inMapView,notInMapView,backfill){if(!query)query='';var path="/api_v2/search()?q="+escape(query);if(bounds){var bstr=bounds.minLng+","+bounds.minLat+","+bounds.maxLng+","+bounds.maxLat;path+="&bbox="+bstr;}
if(count){path+="&count="+parseInt(count);}
if(offset){path+="&count="+parseInt(offset);}
if(inMapView){path+="&inMapView="+inMapView;}
if(notInMapView){path+="&notInMapView="+notInMapView;}
if(backfill){path+="&backfill="+backfill;}
path+="&properties="+props;this.callApi(callback,'get',path,{});}
PlatialApiV2.prototype.userItems=function(callback,username,props){var path="/api_v2/user/"+username+"/userItems()";if(props)path+="?properties="+props;this.callApi(callback,'get',path,{});}
PlatialApiV2.prototype.getMapView=function(callback,mapViewId,pendingOnly){var path="/api_v2/mapview/"+mapViewId;if(pendingOnly)path+="?pending_only=1";this.callApi(callback,'get',path,{});}
PlatialApiV2.prototype.get=function(callback,tp,id,props,inMapView){var path="/api_v2/"+tp+"/"+id;var delim="?";if(props){path+="?properties="+props;delim="&";}
if(inMapView){path+=delim+"mapview="+inMapView;}
this.callApi(callback,'get',path,{});}
PlatialApiV2.prototype.mapMembers=function(callback,mapId,maxCount,props,pendingOnly){var path="/api_v2/map/"+mapId+"/members()";var delim="?";if(props){path+="?properties="+props;delim="&";}
if(pendingOnly){path+=delim+"pending_only=1";delim="&";}
if(maxCount)path+=delim+"count="+maxCount;this.callApi(callback,'get',path,{});}
PlatialApiV2.prototype.mapTiles=function(callback,mapId,tiles,maxCount,props){var path="/api_v2/map/"+mapId+"/tiles()?ids="+(tiles.join(","));if(props){path+="&properties="+props;}
if(maxCount)path+="&count="+maxCount;this.callApi(callback,'get',path,{});}
PlatialApiV2.prototype.tilesVector=function(callback,inputs){gVectorTileLoadCount++;console.log('tilesVector gVectorTileLoadCount: '+gVectorTileLoadCount);var path="/api_v2/tilesVector()";var args={"inputs":Json.toString(inputs)};this.callApi(callback,'post',path,args);}
PlatialApiV2.prototype.coveringTiles=function(callback,mapId,tiles){var path="/api_v2/map/"+mapId+"/coveringTiles()?ids="+(tiles.join(","));this.callApi(callback,'get',path,{});}
PlatialApiV2.prototype.addImage=function(callback,item,value){var iid=this.itemIndex(item);var path="/api_v2/descriptor/"+iid+"/addImage()";var args={"value":Json.toString(value)};this.callApi(callback,'post',path,args);}
PlatialApiV2.prototype.geocode=function(callback,address){var path="/v2/geocode()";var args={"address":address};this.callApi(callback,'post',path,args);}
PlatialApiV2.prototype.insertPlace=function(callback,title,address,pnt,props){var path='/v2/insert()';var value={"@type":"cgeo:Place"};if(pnt)value.geometry={"coordinates":[pnt.lng,pnt.lat]};if(title)value.title=title;if(address)value.address=address;var args={"value":Json.toString(value)};this.callApi(callback,'post',path,args);}