
function MarkerManager(map,opt_opts){var me=this;me.map_=map;me.mapZoom_=map.getZoom();me.projection_=map.getCurrentMapType().getProjection();opt_opts=opt_opts||{};me.tileSize_=MarkerManager.DEFAULT_TILE_SIZE_;var maxZoom=MarkerManager.DEFAULT_MAX_ZOOM_;if(opt_opts.maxZoom!=undefined){maxZoom=opt_opts.maxZoom;}
me.maxZoom_=maxZoom;me.trackMarkers_=opt_opts.trackMarkers;var padding;if(typeof opt_opts.borderPadding=="number"){padding=opt_opts.borderPadding;}else{padding=MarkerManager.DEFAULT_BORDER_PADDING_;}
me.swPadding_=new GSize(-padding,padding);me.nePadding_=new GSize(padding,-padding);me.borderPadding_=padding;me.gridWidth_=[];me.grid_=[];me.grid_[maxZoom]=[];me.numMarkers_=[];me.numMarkers_[maxZoom]=0;me.zoomLevels_=[];me.zoomLevels_[maxZoom]=[];GEvent.bind(map,"moveend",me,me.onMapMoveEnd_);me.hide_=function(marker){me.onHide(marker);me.shownMarkers_--;};me.show_=function(marker){me.onShow(marker);me.shownMarkers_++;};me.add_=function(marker){me.onAdd(marker);me.totalMarkers_++;};me.remove_=function(marker){me.onRemove(marker);me.totalMarkers_--;};me.enter_=function(marker){me.onEnter(marker);me.visibleMarkers_++;};me.leave_=function(marker){me.onLeave(marker);me.visibleMarkers_++;};me.resetManager_();me.totalMarkers_=0;me.shownMarkers_=0;me.visibleMarkers_=0;me.shownGridBounds_=me.getMapGridBounds_();me.shownMapBounds_=me.map_.getBounds();};MarkerManager.DEFAULT_TILE_SIZE_=1024;MarkerManager.DEFAULT_MAX_ZOOM_=17;MarkerManager.DEFAULT_BORDER_PADDING_=100;MarkerManager.MERCATOR_ZOOM_LEVEL_ZERO_RANGE=256;MarkerManager.prototype.onHide=function(marker){this.map_.removeOverlay(marker);};MarkerManager.prototype.onShow=function(marker){this.map_.addOverlay(marker);};MarkerManager.prototype.onAdd=function(marker){};MarkerManager.prototype.onRemove=function(marker){};MarkerManager.prototype.onEnter=function(marker){};MarkerManager.prototype.onLeave=function(marker){};MarkerManager.prototype.resetManager_=function(){var me=this;var mapWidth=MarkerManager.MERCATOR_ZOOM_LEVEL_ZERO_RANGE;for(var zoom=0;zoom<=me.maxZoom_;++zoom){me.grid_[zoom]=[];me.numMarkers_[zoom]=0;me.gridWidth_[zoom]=Math.ceil(mapWidth/me.tileSize_);mapWidth<<=1;me.zoomLevels_[zoom]=[];}};MarkerManager.prototype.clearMarkers=function(){var me=this;me.processBounds_(me.shownGridBounds_,function(marker){me.hide_(marker);var point=marker.getPoint?marker.getPoint():marker.getCenter();if(point&&me.shownMapBounds_.contains(point)){me.leave_(marker);}});me.processAll_(me.remove_);me.resetManager_();};MarkerManager.prototype.getTilePoint_=function(latlng,zoom,padding){var pixelPoint=this.projection_.fromLatLngToPixel(latlng,zoom);return new GPoint(Math.floor((pixelPoint.x+padding.width)/this.tileSize_),Math.floor((pixelPoint.y+padding.height)/this.tileSize_));};MarkerManager.prototype.addMarkerBatch_=function(marker,minZoom,maxZoom){var me=this;if(marker.getPoint){var mPoint=marker.getPoint();if(this.trackMarkers_){GEvent.bind(marker,"changed",this,this.onMarkerMoved_);}
var gridPoint=this.getTilePoint_(mPoint,maxZoom,GSize.ZERO);for(var zoom=maxZoom;zoom>=minZoom;zoom--){var cell=this.getGridCellCreate_(gridPoint.x,gridPoint.y,zoom);cell.push(marker);gridPoint.x=gridPoint.x>>1;gridPoint.y=gridPoint.y>>1;}
gridPoint=me.getTilePoint_(marker.getPoint(),me.mapZoom_,GSize.ZERO);if(me.isGridPointVisible_(gridPoint)&&minZoom<=me.shownGridBounds_.z&&me.shownGridBounds_.z<=maxZoom){me.show_(marker);if(me.shownMapBounds_.contains(marker.getPoint())){me.enter_(marker);}
me.notifyListeners_();}
this.numMarkers_[minZoom]++;}else{for(var zoom=maxZoom;zoom>=minZoom;zoom--){this.zoomLevels_[zoom].push(marker);}
if(minZoom<=me.shownGridBounds_.z&&me.shownGridBounds_.z<=maxZoom){me.show_(marker);var point=marker.getPoint?marker.getPoint():marker.getCenter();if(point&&me.shownMapBounds_.contains(point)){me.enter_(marker);}
me.notifyListeners_();}
this.numMarkers_[minZoom]++;}
this.onAdd(marker);};MarkerManager.prototype.isGridPointVisible_=function(point){var me=this;var vertical=me.shownGridBounds_.minY<=point.y&&point.y<=me.shownGridBounds_.maxY;var minX=me.shownGridBounds_.minX;var horizontal=minX<=point.x&&point.x<=me.shownGridBounds_.maxX;if(!horizontal&&minX<0){var width=me.gridWidth_[me.shownGridBounds_.z];horizontal=minX+width<=point.x&&point.x<=width-1;}
return vertical&&horizontal;}
MarkerManager.prototype.onMarkerMoved_=function(marker,oldPoint,newPoint){var me=this;var zoom=me.maxZoom_;var changed=false;var oldGrid=me.getTilePoint_(oldPoint,zoom,GSize.ZERO);var newGrid=me.getTilePoint_(newPoint,zoom,GSize.ZERO);while(zoom>=0&&(oldGrid.x!=newGrid.x||oldGrid.y!=newGrid.y)){var cell=me.getGridCellNoCreate_(oldGrid.x,oldGrid.y,zoom);if(cell){if(me.removeFromArray(cell,marker)){me.getGridCellCreate_(newGrid.x,newGrid.y,zoom).push(marker);}}
if(zoom==me.mapZoom_){if(me.isGridPointVisible_(oldGrid)){if(!me.isGridPointVisible_(newGrid)){me.hide_(marker);changed=true;}}else{if(me.isGridPointVisible_(newGrid)){me.show_(marker);changed=true;}}}
oldGrid.x=oldGrid.x>>1;oldGrid.y=oldGrid.y>>1;newGrid.x=newGrid.x>>1;newGrid.y=newGrid.y>>1;--zoom;}
if(changed){me.notifyListeners_();}};MarkerManager.prototype.removeMarker=function(marker){var me=this;var changed=false;var zoom=me.maxZoom_;if(marker.getPoint){var point=marker.getPoint();var grid=me.getTilePoint_(point,zoom,GSize.ZERO);while(zoom>=0){var cell=me.getGridCellNoCreate_(grid.x,grid.y,zoom);if(cell){me.removeFromArray(cell,marker);}
if(zoom==me.mapZoom_){if(me.isGridPointVisible_(grid)){me.hide_(marker);changed=true;}}
grid.x=grid.x>>1;grid.y=grid.y>>1;--zoom;}}else{while(zoom>=0){me.removeFromArray(this.zoomLevels_[zoom],marker);if(zoom==me.mapZoom_){me.hide_(marker);changed=true;}
--zoom;}}
if(changed){me.notifyListeners_();}
me.onRemove(marker);};MarkerManager.prototype.addMarkers=function(markers,minZoom,opt_maxZoom){var maxZoom=this.getOptMaxZoom_(opt_maxZoom);for(var i=markers.length-1;i>=0;i--){this.addMarkerBatch_(markers[i],minZoom,maxZoom);}
this.numMarkers_[minZoom]+=markers.length;};MarkerManager.prototype.getOptMaxZoom_=function(opt_maxZoom){return opt_maxZoom!=undefined?opt_maxZoom:this.maxZoom_;}
MarkerManager.prototype.getMarkerCount=function(zoom){var total=0;for(var z=0;z<=zoom;z++){total+=this.numMarkers_[z];}
return total;};MarkerManager.prototype.inBounds=function(marker){}
MarkerManager.prototype.addMarker=function(marker,minZoom,opt_maxZoom){var me=this;var maxZoom=this.getOptMaxZoom_(opt_maxZoom);me.addMarkerBatch_(marker,minZoom,maxZoom);};MarkerManager.prototype.getGridCellCreate_=function(x,y,z){var grid=this.grid_[z];if(x<0){x+=this.gridWidth_[z];}
var gridCol=grid[x];if(!gridCol){gridCol=grid[x]=[];return gridCol[y]=[];}
var gridCell=gridCol[y];if(!gridCell){return gridCol[y]=[];}
return gridCell;};MarkerManager.prototype.getGridCellNoCreate_=function(x,y,z){var grid=this.grid_[z];if(x<0){x+=this.gridWidth_[z];}
var gridCol=grid[x];return gridCol?gridCol[y]:undefined;};MarkerManager.prototype.getGridBounds_=function(bounds,zoom,swPadding,nePadding){zoom=Math.min(zoom,this.maxZoom_);var bl=bounds.getSouthWest();var tr=bounds.getNorthEast();var sw=this.getTilePoint_(bl,zoom,swPadding);var ne=this.getTilePoint_(tr,zoom,nePadding);var gw=this.gridWidth_[zoom];if(tr.lng()<bl.lng()||ne.x<sw.x){sw.x-=gw;}
if(ne.x-sw.x+1>=gw){sw.x=0;ne.x=gw-1;}
var gridBounds=new GBounds([sw,ne]);gridBounds.z=zoom;return gridBounds;};MarkerManager.prototype.getMapGridBounds_=function(){var me=this;return me.getGridBounds_(me.map_.getBounds(),me.mapZoom_,me.swPadding_,me.nePadding_);};MarkerManager.prototype.onMapMoveEnd_=function(){var me=this;this.updateMarkers_();return;me.objectSetTimeout_(this,this.updateMarkers_,0);};MarkerManager.prototype.objectSetTimeout_=function(object,command,milliseconds){return window.setTimeout(function(){command.call(object);},milliseconds);};MarkerManager.prototype.refresh=function(){var me=this;if(me.shownMarkers_>0){me.processBounds_(me.shownGridBounds_,me.hide_);}
me.processBounds_(me.shownGridBounds_,me.show_);me.notifyListeners_();};MarkerManager.prototype.updateMarkers_=function(){var me=this;me.mapZoom_=this.map_.getZoom();var newGridBounds=me.getMapGridBounds_();var newMapBounds=this.map_.getBounds();me.checkViewport_(newGridBounds,me.shownGridBounds_,newMapBounds,me.shownMapBounds_,me.enter_,me.leave_);me.shownMapBounds_=newMapBounds;if(newGridBounds.equals(me.shownGridBounds_)&&newGridBounds.z==me.shownGridBounds_.z){return;}
if(newGridBounds.z!=me.shownGridBounds_.z){me.processBounds_(me.shownGridBounds_,me.hide_);me.processBounds_(newGridBounds,me.show_);}else{me.rectangleDiff_(me.shownGridBounds_,newGridBounds,me.removeCellMarkers_);me.rectangleDiff_(newGridBounds,me.shownGridBounds_,me.addCellMarkers_);}
me.shownGridBounds_=newGridBounds;me.notifyListeners_();};MarkerManager.prototype.notifyListeners_=function(){GEvent.trigger(this,"changed",this.shownGridBounds_,this.shownMarkers_);};MarkerManager.prototype.processBounds_=function(bounds,callback){for(var x=bounds.minX;x<=bounds.maxX;x++){for(var y=bounds.minY;y<=bounds.maxY;y++){this.processCellMarkers_(x,y,bounds.z,callback);}}
var zoomLevel=this.zoomLevels_[bounds.z];for(var i=zoomLevel.length-1;i>=0;i--){callback(zoomLevel[i]);}};MarkerManager.prototype.processAll_=function(callback){for(var z=this.grid_.length-1;z>=0;z--){for(var x in this.grid_[z]){for(var y in this.grid_[z][x]){for(var i=this.grid_[z][x][y].length-1;i>=0;i--){callback(this.grid_[z][x][y][i]);}}}}
for(var l in this.zoomLevels_){for(var i=this.zoomLevels_[l].length-1;i>=0;i--){callback(this.zoomLevels_[l][i]);}}};MarkerManager.prototype.processCellMarkers_=function(x,y,z,callback){var cell=this.getGridCellNoCreate_(x,y,z);if(cell){for(var i=cell.length-1;i>=0;i--){callback(cell[i]);}}};MarkerManager.prototype.removeCellMarkers_=function(x,y,z){this.processCellMarkers_(x,y,z,this.hide_);};MarkerManager.prototype.addCellMarkers_=function(x,y,z){this.processCellMarkers_(x,y,z,this.show_);};MarkerManager.prototype.rectangleDiff_=function(bounds1,bounds2,callback){var me=this;me.rectangleDiffCoords(bounds1,bounds2,function(x,y){callback.apply(me,[x,y,bounds1.z]);});};MarkerManager.prototype.rectangleUnion_=function(bounds1,bounds2,callback){var me=this;me.rectangleUnionCoords(bounds1,bounds2,function(x,y){callback.apply(me,[x,y,bounds1.z]);});};MarkerManager.prototype.checkViewport_=function(newGridBounds,oldGridBounds,newMapBounds,oldMapBounds,enterCallback,leaveCallback){var me=this;if(newMapBounds.equals(oldMapBounds)&&newGridBounds.z==oldGridBounds.z){return;}
if(newGridBounds.z!=oldGridBounds.z){me.processBounds_(oldGridBounds,function(marker){var point=marker.getPoint?marker.getPoint():marker.getCenter();if(point&&oldMapBounds.contains(point)){leaveCallback(marker);}});me.processBounds_(newGridBounds,function(marker){var point=marker.getPoint?marker.getPoint():marker.getCenter();if(point&&newMapBounds.contains(point)){enterCallback(marker);}});}else{me.rectangleDiff_(oldGridBounds,newGridBounds,function(x,y,z){me.processCellMarkers_(x,y,z,function(marker){if(oldMapBounds.contains(marker.getPoint())){leaveCallback(marker);}});});me.rectangleDiff_(newGridBounds,oldGridBounds,function(x,y,z){me.processCellMarkers_(x,y,z,function(marker){if(newMapBounds.contains(marker.getPoint())){enterCallback(marker);}});});me.rectangleUnion_(newGridBounds,oldGridBounds,function(x,y,z){me.processCellMarkers_(x,y,z,function(marker){var point=marker.getPoint();var inNewBounds=newMapBounds.contains(point);var inShownBounds=oldMapBounds.contains(point);if(inNewBounds&&!inShownBounds){enterCallback(marker);}else if(!inNewBounds&&inShownBounds){leaveCallback(marker);}});});var zoomLevel=this.zoomLevels_[newGridBounds.z];for(var i=zoomLevel.length-1;i>=0;i--){var marker=zoomLevel[i];var point=marker.getPoint?marker.getPoint():marker.getCenter();if(point){var inNewBounds=newMapBounds.contains(point);var inShownBounds=oldMapBounds.contains(point);if(inNewBounds&&!inShownBounds){enterCallback(marker);}else if(!inNewBounds&&inShownBounds){leaveCallback(marker);}}}}};MarkerManager.prototype.rectangleDiffCoords=function(bounds1,bounds2,callback){var minX1=bounds1.minX;var minY1=bounds1.minY;var maxX1=bounds1.maxX;var maxY1=bounds1.maxY;var minX2=bounds2.minX;var minY2=bounds2.minY;var maxX2=bounds2.maxX;var maxY2=bounds2.maxY;for(var x=minX1;x<=maxX1;x++){for(var y=minY1;y<=maxY1&&y<minY2;y++){callback(x,y);}
for(var y=Math.max(maxY2+1,minY1);y<=maxY1;y++){callback(x,y);}}
for(var y=Math.max(minY1,minY2);y<=Math.min(maxY1,maxY2);y++){for(var x=Math.min(maxX1+1,minX2)-1;x>=minX1;x--){callback(x,y);}
for(var x=Math.max(minX1,maxX2+1);x<=maxX1;x++){callback(x,y);}}};MarkerManager.prototype.rectangleUnionCoords=function(bounds1,bounds2,callback){var me=this;var z=bounds1.z;var minX=Math.max(bounds1.minX,bounds2.minX);var maxX=Math.min(bounds1.maxX,bounds2.maxX);var minY=Math.max(bounds1.minY,bounds2.minY);var maxY=Math.min(bounds1.maxY,bounds2.maxY);for(var x=minX;x<=maxX;x++){for(var y=minY;y<=maxY;y++){callback(x,y);}}}
MarkerManager.prototype.removeFromArray=function(array,value,opt_notype){var shift=0;for(var i=0;i<array.length;++i){if(array[i]===value||(opt_notype&&array[i]==value)){array.splice(i--,1);shift++;}}
return shift;};var ANWB_MAPS_VERSION='0.1.2-SNAPSHOT';AnwbMapsMap.DEFAULT_ZOOM=7;AnwbMapsMap.DEFAULT_SINGLE_POINT_ZOOM=11;AnwbMapsMap.DEFAULT_CENTER={lat:52.08395,lng:5.26175};AnwbMapsMap.DEFAULT_MAP_TYPE='normal';AnwbMapsMap.DEFAULT_MAP_TYPES=['normal','satellite','hybrid'];AnwbMapsMap.prototype.refreshInProgress=false;AnwbMapsMap.prototype.loadingDiv=null;AnwbMapsMap.prototype.gotoDefaultViewportRequested=false;function AnwbMapsMap(container,displayOptions){Error.throwOnConditions({"container is required":(!container),"Browser does not support Google Maps.":(!AnwbMapsBrowserIsCompatible())});this.container=container;this.gmap=this.createGmapFromOptions(container,displayOptions);this.layers=new Array();if(displayOptions.layers){for(i=0;i<displayOptions.layers.length;i++){this.addLayer(AnwbMapsLayer.create(displayOptions.layers[i]));}}
var anwbMap=this;var moveendCallback=function(){window.setTimeout(function(){anwbMap.refreshLayers(anwbMap.getViewBoundary());},1);}
GEvent.addListener(this.gmap,"moveend",moveendCallback);}
AnwbMapsMap.prototype.setCenter=function(center){if(center)this.gmap.setCenter(center);}
AnwbMapsMap.prototype.setZoom=function(zoom){this.gmap.setZoom(zoom);}
AnwbMapsMap.prototype.createGmapFromOptions=function(container,options){var gOptions={};if(options.height&&options.width)
gOptions.size=new GSize(options.height,options.width);var toGMapType=function(type){if(type=='normal')return G_NORMAL_MAP;if(type=='satellite')return G_SATELLITE_MAP;if(type=='hybrid')return G_HYBRID_MAP;if(type=='terrain')return G_PHYSICAL_MAP;return undefined;}
if(!options.mapTypes)options.mapTypes=AnwbMapsMap.DEFAULT_MAP_TYPES;if(!options.mapType)options.mapType=AnwbMapsMap.DEFAULT_MAP_TYPE;gOptions.mapTypes=[];var mapTypeFound=false;for(i=0;i<options.mapTypes.length;i++){var gMapType=toGMapType(options.mapTypes[i]);if(gMapType)gOptions.mapTypes.push(gMapType);if(options.mapTypes[i]==options.mapType)mapTypeFound=true;}
if(!mapTypeFound){options.mapTypes.push(options.mapType);gOptions.mapTypes.push(toGMapType(options.mapType));}
var map=new GMap2(container,gOptions);var zoomable=true;var draggable=true;var overview=false;var scale=false;var smallControls=false;if(options){if(options.zoomable!=undefined)zoomable=options.zoomable;if(options.draggable!=undefined)draggable=options.draggable;if(options.overview!=undefined)overview=options.overview;if(options.scale!=undefined)scale=options.scale;if(options.smallControls!=undefined)smallControls=options.smallControls;if(options.center){if(options.center.constructor==AnwbMapsLatLng){map.setCenter(options.center.toGLatLng());}else{map.setCenter(new AnwbMapsLatLng(options.center.lat,options.center.lng).toGLatLng());}
map.setZoom(options.zoom?options.zoom:AnwbMapsMap.DEFAULT_ZOOM);}else{map.setCenter(AnwbMapsLatLng.create(AnwbMapsMap.DEFAULT_CENTER).toGLatLng());map.setZoom(AnwbMapsMap.DEFAULT_ZOOM);}
this.gotoDefaultViewportRequested=options.gotoDefaultViewport?options.gotoDefaultViewport:(!options.center);if(options.loadingDiv){this.loadingDiv=document.getElementById(options.loadingDiv);}
if(options.mapType){var mapType=toGMapType(options.mapType);if(mapType)map.setMapType(mapType);}}
draggable?map.enableDragging():map.disableDragging();zoomable?map.enableDoubleClickZoom():map.disableDoubleClickZoom();zoomable?map.enableScrollWheelZoom():map.disableScrollWheelZoom();var anwbMap=this;map.oo=function(){anwbMap.gotoDefaultViewport();};if(zoomable&&draggable)
smallControls?map.addControl(new GSmallMapControl()):map.addControl(new GLargeMapControl());if(zoomable&&!draggable)
map.addControl(new GSmallZoomControl());if(overview)
map.addControl(new GOverviewMapControl());if(scale)
map.addControl(new GScaleControl());map.addControl(new GMapTypeControl());return map;}
AnwbMapsMap.prototype.getViewBoundary=function(){var bounds=this.gmap.getBounds();var zoom=this.gmap.getZoom();return new AnwbMapsBoundary(new AnwbMapsLatLngBounds(new AnwbMapsLatLng(bounds.getSouthWest().lat(),bounds.getSouthWest().lng()),new AnwbMapsLatLng(bounds.getNorthEast().lat(),bounds.getNorthEast().lng())),new AnwbMapsZoomBounds(zoom,zoom));}
AnwbMapsMap.prototype.setViewBoundary=function(viewBoundary){var bounds=viewBoundary.toGLatLngBounds();this.gmap.setCenter(bounds.getCenter(),this.gmap.getBoundsZoomLevel(bounds));}
AnwbMapsMap.prototype.layers=new Array();AnwbMapsMap.prototype.addLayer=function(layer){this.showLoadingIndicator();this.layers.push(layer);layer.setMap(this);layer.setLoaded(false);layer.refresh(this.getViewBoundary(),this.createRefreshLayersCallbackClosure());}
AnwbMapsMap.prototype.loadingDiv=null;AnwbMapsMap.prototype.setLoadingDiv=function(div){this.loadingDiv=div;}
AnwbMapsMap.prototype.getLoadingDiv=function(){return this.loadingDiv;}
AnwbMapsMap.prototype.refreshLayers=function(viewBoundary){if(!this.layers||this.layers.length==0){return;}
this.showLoadingIndicator();var refreshLayersCallbackClosure=this.createRefreshLayersCallbackClosure();for(var layer in this.layers){this.layers[layer].setLoaded(false);}
for(var layer in this.layers){this.layers[layer].refresh(viewBoundary,refreshLayersCallbackClosure);}}
AnwbMapsMap.prototype.gotoDefaultViewport=function(){this.gotoDefaultViewportRequested=true;if(!this.refreshInProgress){this.doGotoDefaultViewport();}}
AnwbMapsMap.prototype.doGotoDefaultViewport=function(){if(this.gotoDefaultViewportRequested)
{this.gotoDefaultViewportRequested=false;var calculatedBounds=null;for(var layerIndex in this.layers){var layer=this.layers[layerIndex];var localCalculatedBounds=layer.getCalculatedBoundary();if(localCalculatedBounds)
{if(calculatedBounds)
{calculatedBounds.extend(localCalculatedBounds.toGLatLngBounds().getSouthWest());calculatedBounds.extend(localCalculatedBounds.toGLatLngBounds().getNorthEast());}
else
{calculatedBounds=localCalculatedBounds.toGLatLngBounds();}}}
if(calculatedBounds)
{if(calculatedBounds.getSouthWest().lat()==calculatedBounds.getNorthEast().lat()&&calculatedBounds.getSouthWest().lng()==calculatedBounds.getNorthEast().lng()){this.gmap.setCenter(calculatedBounds.getSouthWest(),AnwbMapsMap.DEFAULT_SINGLE_POINT_ZOOM);}else{this.setViewBoundary(AnwbMapsLatLngBounds.fromGLatLngBounds(calculatedBounds));}
this.refreshLayers(this.getViewBoundary());}}}
AnwbMapsMap.prototype.onAllLayersLoaded=function(){this.doGotoDefaultViewport();}
AnwbMapsMap.prototype.createRefreshLayersCallbackClosure=function(){var anwbMap=this;var refreshLayersCallbackClosure=function(callingLayer){anwbMap.refreshLayersCallback(callingLayer);}
return refreshLayersCallbackClosure;}
AnwbMapsMap.prototype.refreshLayersCallback=function(callingLayer){var allLayersLoaded=true;for(var layer in this.layers){if(this.layers[layer]==callingLayer){continue;}
allLayersLoaded=allLayersLoaded&&this.layers[layer].getLoaded();}
callingLayer.setLoaded(true);if(allLayersLoaded)
{this.onAllLayersLoaded();this.hideLoadingIndicator();}}
AnwbMapsMap.prototype.removeLayer=function(layer){for(var id in this.layers){if(this.layers[id]==layer){layers.splice(id,1);layer.destroy();}}}
AnwbMapsMap.prototype.showLoadingIndicator=function(){this.refreshInProgress=true;if(this.loadingDiv){this.loadingDiv.style.visibility='';}}
AnwbMapsMap.prototype.hideLoadingIndicator=function(){this.refreshInProgress=false;if(this.loadingDiv){this.loadingDiv.style.visibility='hidden';}}
AnwbMapsBrowserIsCompatible=function(){return GBrowserIsCompatible();}
Error.throwOnConditions=function(conditions){for(conditionName in conditions){if(conditions[conditionName]){throw new Error(conditionName);}}};function AnwbMapsBoundary(latLngBounds,zoomBounds){this.latLngBounds=latLngBounds;this.zoomBounds=zoomBounds;}
AnwbMapsBoundary.prototype.scale=function(multipliers){var latIncrease=(multipliers.x-1)*this.latLngBounds.getLatitudeWidth()/2;var lngIncrease=(multipliers.y-1)*this.latLngBounds.getLongitudeWidth()/2;if((this.latLngBounds.getLongitudeWidth()*(multipliers.y-1))>=360){var sw=new AnwbMapsLatLng(this.latLngBounds.southWest.lat-latIncrease,-180);var ne=new AnwbMapsLatLng(this.latLngBounds.northEast.lat+latIncrease,180);}else{var sw=new AnwbMapsLatLng(this.latLngBounds.southWest.lat-latIncrease,this.latLngBounds.southWest.lng-lngIncrease);var ne=new AnwbMapsLatLng(this.latLngBounds.northEast.lat+latIncrease,this.latLngBounds.northEast.lng+lngIncrease);}
var latLngBounds=new AnwbMapsLatLngBounds(sw,ne);var zoomBounds=new AnwbMapsZoomBounds(Math.max(this.zoomBounds.min-multipliers.z,0),Math.min(this.zoomBounds.max+multipliers.z,17));return new AnwbMapsBoundary(latLngBounds,zoomBounds);}
AnwbMapsBoundary.prototype.contains=function(other){return this.latLngBounds.containsBounds(other.latLngBounds)&&this.zoomBounds.contains(other.zoomBounds);}
AnwbMapsBoundary.prototype.intersects=function(other){return this.latLngBounds.intersects(other.latLngBounds)&&this.zoomBounds.intersects(other.zoomBounds);}
AnwbMapsBoundary.prototype.toString=function(){return"{\n\tlatLngBounds: "+this.latLngBounds+",\n\tzoomBounds: "+this.zoomBounds+"\n}";}
function AnwbMapsBoundaryMultipliers(x,y,z){this.x=x;this.y=y;this.z=z;}
function AnwbMapsLatLng(lat,lng){this.lat=AnwbMapsLatLng.normalizeLat(lat);this.lng=AnwbMapsLatLng.normalizeLng(lng);}
AnwbMapsLatLng.normalizeLat=function(lat){if(lat<-90.0){return-90.0;}else if(lat>90.0){return 90.0;}else{return lat;}}
AnwbMapsLatLng.normalizeLng=function(lng){return AnwbMapsLatLng.normalizeLngWithCenter(lng,0.0);}
AnwbMapsLatLng.normalizeLng360=function(lng){return AnwbMapsLatLng.normalizeLngWithCenter(lng,180.0);}
AnwbMapsLatLng.normalizeLngWithCenter=function(lng,center){return center+Math.ieeeRemainder(lng-center,360.0);}
AnwbMapsLatLng.prototype.toGLatLng=function(){return new GLatLng(this.lat,this.lng);}
function AnwbMapsLatLngBounds(southWest,northEast){this.southWest=southWest;this.northEast=northEast;}
AnwbMapsLatLngBounds.prototype.getCenter=function(){var moveLng=this.southWest.lng<this.northEast.lng?0:360;return new AnwbMapsLatLng((this.southWest.lat+this.northEast.lat)/2,((this.southWest.lng+this.northEast.lng+moveLng)/2)-moveLng);}
AnwbMapsLatLngBounds.prototype.getLongitudeWidth=function(){return(this.northEast.lng-this.southWest.lng)+(this.southWest.lng<this.northEast.lng?0:360);}
AnwbMapsLatLngBounds.prototype.getLatitudeWidth=function(){return Math.abs(this.southWest.lat-this.northEast.lat);}
AnwbMapsLatLngBounds.prototype.containsLatLng=function(point){if(point.lat<this.southWest.lat||this.northEast.lat<point.lat){return false;}
if(this.crosses180DegreeLongtitude()){return(this.southWest.lng<=point.lng&&point.lng<=180.0)||(-180.0<=point.lng&&point.lng<=this.northEast.lng);}else{return this.southWest.lng<=point.lng&&point.lng<=this.northEast.lng;}}
AnwbMapsLatLngBounds.prototype.containsBounds=function(latLngBounds){return this.containsLatLng(latLngBounds.southWest)&&this.containsLatLng(latLngBounds.northEast);}
AnwbMapsLatLngBounds.prototype.intersects=function(latLngBounds){var swLat=this.southWest.lat<latLngBounds.northEast.lat;var swLng=this.southWest.lng<latLngBounds.northEast.lng;var neLat=this.northEast.lat>latLngBounds.southWest.lat;var neLng=this.northEast.lng>latLngBounds.southWest.lng;var intersects=swLat&&swLng&&neLat&&neLng;return intersects;}
AnwbMapsLatLngBounds.prototype.crosses180DegreeLongtitude=function(){return this.southWest.lng>this.northEast.lng;}
AnwbMapsLatLngBounds.prototype.toGLatLngBounds=function(){return new GLatLngBounds(this.southWest.toGLatLng(),this.northEast.toGLatLng());}
AnwbMapsLatLngBounds.fromGLatLngBounds=function(gLatLngBounds){return new AnwbMapsLatLngBounds(new AnwbMapsLatLng(gLatLngBounds.getSouthWest().lat(),gLatLngBounds.getSouthWest().lng()),new AnwbMapsLatLng(gLatLngBounds.getNorthEast().lat(),gLatLngBounds.getNorthEast().lng()));}
function AnwbMapsZoomBounds(min,max){this.min=min;this.max=max;}
AnwbMapsZoomBounds.prototype.contains=function(other){return(this.min<=other.min||this.min==undefined)&&(this.max>=other.max||this.max==undefined);}
AnwbMapsZoomBounds.prototype.intersects=function(other){return!((other.min>this.max)||(other.max<this.min));}
AnwbMapsZoomBounds.prototype.containsZoomLevel=function(other){return(other==undefined)||(this.min<=other&&(this.max==undefined||this.max>=other));}
AnwbMapsZoomBounds.prototype.toString=function(){return"{min: "+this.min+", max: "+this.max+"}";}
Math.ieeeRemainder=function(f1,f2){var d=f1/f2;var n=Math.floor(d+0.5);if(n==d+0.5&&n%2==1){n=n-1;}
return f1-f2*n;};function AnwbMapsLayer(){}
AnwbMapsLayer.prototype.loaded=false;AnwbMapsLayer.prototype.calculatedBoundary=null;AnwbMapsLayer.prototype.getLoaded=function(){return this.loaded;}
AnwbMapsLayer.prototype.setLoaded=function(loaded){this.loaded=loaded;}
AnwbMapsLayer.prototype.setMap=function(map){this.map=map;}
AnwbMapsLayer.prototype.refresh=function(viewBoundary){this.viewBoundary=viewBoundary;}
AnwbMapsLayer.prototype.getCalculatedBoundary=function(){return this.calculatedBoundary;}
AnwbMapsLayer.prototype.resetCalculatedBoundary=function(){this.calculatedBoundary=null;}
AnwbMapsDataLayer.prototype.calculatedGLatLngBounds=null;AnwbMapsLayer.prototype.destroy=function(){}
AnwbMapsDataLayer.prototype=new AnwbMapsLayer;function AnwbMapsDataLayer(dataProvider,action,itemProcessor,itemManager){this.setAction(action);this.setDataProvider(dataProvider);this.setItemProcessor(itemProcessor);this.setItemManager(itemManager);}
AnwbMapsDataLayer.prototype.setMap=function(map){this.map=map;if(!this.itemManager)
this.itemManager=new AnwbMapsItemManager();this.itemManager.setMap(map);this.itemManager.setLayer(this);}
AnwbMapsDataLayer.prototype.setAction=function(action){if(action){action.layer=this;this.action=action;}}
AnwbMapsDataLayer.prototype.setDataProvider=function(dataProvider){this.dataProvider=dataProvider;}
AnwbMapsDataLayer.prototype.setItemProcessor=function(itemProcessor){this.itemProcessor=itemProcessor;}
AnwbMapsDataLayer.prototype.setItemManager=function(itemManager){this.itemManager=itemManager?itemManager:new AnwbMapsItemManager();}
AnwbMapsDataLayer.prototype.refresh=function(viewBoundary,layerLoadedCallback){AnwbMapsLayer.prototype.refresh.call(this,viewBoundary);this.layerLoadedCallback=layerLoadedCallback;if(this.isRefetchNeeded()){this.dataBoundary=this.getDesiredDataBoundary();var dataLayer=this;this.dataProvider.fetchItemSet(this.dataBoundary,function(itemSet){dataLayer.handleFetchItemSet(itemSet);});}
else
{this.itemManager.refresh(false);this.layerLoadedCallback(this);}};AnwbMapsDataLayer.prototype.resetCalculatedBoundary=function(){AnwbMapsLayer.prototype.resetCalculatedBoundary.call(this);this.calculatedGLatLngBounds=null;}
AnwbMapsDataLayer.prototype.handleFetchItemSet=function(itemSet){if(!this.idParam){if(!itemSet.boundary.contains(this.getVirtualViewBoundary()))return;this.itemManager.clearItems();this.resetCalculatedBoundary();}else{if(!this.retrievedIds)this.retrievedIds={};}
if(itemSet.boundary){this.dataBoundary=itemSet.boundary;}
for(id in itemSet.items){var item=itemSet.items[id];if(item&&!(this.idParam&&this.retrievedIds[item[this.idParam]])){var overlay=this.createOverlayFromItem(item);this.itemManager.addItem(item,overlay,this);this.calculatedGLatLngBounds=item.extendGLatLngBounds(this.calculatedGLatLngBounds);if(this.idParam){this.retrievedIds[item[this.idParam]]=true;}}}
if(!this.idParam){this.itemManager.refresh(true);}
if(this.layerLoadedCallback)
{this.layerLoadedCallback(this);}}
AnwbMapsDataLayer.prototype.getCalculatedBoundary=function(){if(this.calculatedBoundary){return this.calculatedBoundary;}
if(!this.calculatedGLatLngBounds){return null;}
this.calculatedBoundary=AnwbMapsLatLngBounds.fromGLatLngBounds(this.calculatedGLatLngBounds);return this.calculatedBoundary;}
AnwbMapsDataLayer.prototype.createOverlayFromItem=function(item,force){if(!item){return null;}
var options=this.itemProcessor?this.itemProcessor.getOptions(overlay,item):{};var overlay=null;if(typeof(item)=='object'&&(item.constructor==AnwbMapsPoint||item.constructor==AnwbMapsPointAndKML)){var point=new GLatLng(item.latLng.lat,item.latLng.lng);if(!options.title)options.title=item.title;if(!options.clickable)options.clickable=!item.inert;overlay=new GMarker(point,options);}else if(force&&typeof(item)=='object'&&item.constructor==AnwbMapsPolyline){if(!options.color)options.color=item.color;if(!options.weight)options.weight=item.weight;if(!options.points)options.points=item.encodedPoints;if(!options.opacity)options.opacity=item.opacity;if(!options.levels)options.levels=item.encodedLevels;if(!options.zoomFactor)options.zoomFactor=item.zoomFactor;if(!options.numLevels)options.numLevels=item.numLevels;overlay=new GPolyline.fromEncoded(options);}
if(overlay){overlay._item=item;item._overlay=overlay;item._layer=this;if(this.itemProcessor){overlay=this.itemProcessor.process(overlay,item)}}
return overlay;}
AnwbMapsDataLayer.prototype.isRefetchNeeded=function(){if(!this.dataBoundary){return true;}else{return!this.dataBoundary.contains(this.getVirtualViewBoundary());}}
AnwbMapsDataLayer.prototype.destroy=function(){this.itemManager.clearItems();}
AnwbMapsDataLayer.prototype.dataBoundaryMultipliers=new AnwbMapsBoundaryMultipliers(1.5,1.5,0);AnwbMapsDataLayer.prototype.setDataBoundaryMultipliers=function(dataBoundaryMultipliers){this.dataBoundaryMultipliers=dataBoundaryMultipliers;}
AnwbMapsDataLayer.prototype.getDesiredDataBoundary=function(){return this.viewBoundary.scale(this.dataBoundaryMultipliers);}
AnwbMapsDataLayer.prototype.virtualViewBoundaryMultipliers=new AnwbMapsBoundaryMultipliers(1,1,0);AnwbMapsDataLayer.prototype.setVirtualViewBoundaryMultipliers=function(virtualViewBoundaryMultipliers){this.virtualViewBoundaryMultipliers=virtualViewBoundaryMultipliers;}
AnwbMapsDataLayer.prototype.getVirtualViewBoundary=function(){return this.viewBoundary.scale(this.virtualViewBoundaryMultipliers);}
AnwbMapsKmlLayer.prototype=new AnwbMapsLayer;function AnwbMapsKmlLayer(url,zoomBounds,action){Error.throwOnConditions({"no url provided":(!url)});this.url=url;this.zoomBounds=zoomBounds;this.action=action;var layer=this;var kmlLoadedCallback=function(){layer.kmlLoaded();}
this.kmlOverlay=new GGeoXml(this.url,kmlLoadedCallback);Error.throwOnConditions({"Datafile could not be loaded.":(!this.kmlOverlay)});var kmlAction=function(){layer.action.execute();}
GEvent.bind(this.kmlOverlay,"click",kmlAction);this.visible=false;}
AnwbMapsKmlLayer.prototype.kmlLoaded=function(){var defaultBounds=this.kmlOverlay.getDefaultBounds();if(this.kmlOverlay.loadedCorrectly()&&defaultBounds){this.calculatedBoundary=AnwbMapsLatLngBounds.fromGLatLngBounds(this.kmlOverlay.getDefaultBounds());}else{this.calculatedBoundary=null;alert("De kaart-gegevens kunnen niet geladen worden.");}
this.layerLoadedCallback(this);}
AnwbMapsKmlLayer.prototype.refresh=function(viewBoundary,layerLoadedCallback){AnwbMapsLayer.prototype.refresh.call(this,arguments);this.layerLoadedCallback=layerLoadedCallback;newVisibility=this.zoomBounds?this.zoomBounds.contains(viewBoundary.zoomBounds):true;if(this.visible!=newVisibility){if(newVisibility){this.map.gmap.addOverlay(this.kmlOverlay);}else{this.map.gmap.removeOverlay(this.kmlOverlay);}
this.visible=newVisibility;}
if(this.kmlOverlay.loadedCorrectly()){this.kmlLoaded();}};function AnwbMapsAction(){};AnwbMapsAction.prototype.execute=function(item){};AnwbMapsInfoWindowAction.prototype=new AnwbMapsAction;function AnwbMapsInfoWindowAction(param,generator,isUrl){this.param=param;this.generator=generator;this.isUrl=isUrl;};AnwbMapsInfoWindowAction.prototype.execute=function(item){var mymap=this.layer.map;if(this.isUrl){var url=this.generator?this.generator(item):(this.param?item[this.param]:item.url);if(url){GDownloadUrl(url,function(html){mymap.gmap.openInfoWindowHtml(item.getCenter(),html);});}}else{var html=this.generator?this.generator(item):(this.param?item[this.param]:item.html);if(html){mymap.gmap.openInfoWindowHtml(item.getCenter(),html);}}
return false;};AnwbMapsLinkAction.prototype=new AnwbMapsAction;function AnwbMapsLinkAction(urlParam,urlGenerator){this.urlParam=urlParam;this.urlGenerator=urlGenerator;};AnwbMapsLinkAction.prototype.execute=function(item){var link;if(this.urlParam){link=item.details.get(this.urlParam);}else{link=this.urlGenerator(item.id,item.details);}
if(link){location.href=link;}
return false;};AnwbMapsDivAction.prototype=new AnwbMapsAction;function AnwbMapsDivAction(divId,sourceParam,sourceGenerator){this.divId=divId;this.sourceParam=sourceParam;this.sourceGenerator=sourceGenerator;};AnwbMapsDivAction.prototype.execute=function(marker){div=document.getElementById(this.divId);if(this.sourceGenerator){source=this.sourceGenerator(marker.id,marker.details);}else{source=marker.details.get(this.sourceParam);}
if(div)div.innerHTML=source;return true;};AnwbMapsIFrameAction.prototype=new AnwbMapsAction;function AnwbMapsIFrameAction(iframeId,urlParam,urlGenerator){this.iframeId=iframeId;this.urlParam=urlParam;this.urlGenerator=urlGenerator;};AnwbMapsIFrameAction.prototype.execute=function(item){div=document.getElementById(this.iframeId);if(this.urlGenerator){url=this.urlGenerator(item);}else{url=eval("item."+urlParam);}
if(div)div.src=url;return true;};function AnwbMapsDataProvider(){}
AnwbMapsDataProvider.prototype.fetchItemSet=function(boundary,itemSetCallback){itemSetCallback(new AnwbMapsItemSet());};AnwbMapsLocalDataProvider.prototype=new AnwbMapsDataProvider;function AnwbMapsLocalDataProvider(itemSet){this.itemSet=itemSet;}
AnwbMapsLocalDataProvider.prototype.fetchItemSet=function(boundary,itemSetCallback){itemSetCallback(this.itemSet);}
AnwbMapsJSONDataProvider.prototype=new AnwbMapsDataProvider;function AnwbMapsJSONDataProvider(url,expander,extraParams){this.url=url;this.expander=expander;this.extraParams=extraParams;}
AnwbMapsJSONDataProvider.prototype.fetchItemSet=function(boundary,itemSetCallback){var bounds=boundary.latLngBounds;var sw=bounds.southWest;var ne=bounds.northEast;var zoomBounds=boundary.zoomBounds;var viewPort={latsw:sw.lat,lonsw:sw.lng,latne:ne.lat,lonne:ne.lng,zoommin:zoomBounds.min,zoommax:zoomBounds.max};var expandRecord=this.expander;jQuery.ajax({url:this.url,data:jQuery.extend(viewPort,this.extraParams),dataType:"json",cache:true,success:function(data){var items=[];var itemData=data.items;for(id in itemData){items.push(AnwbMapsItem.create(expandRecord(itemData[id])));}
itemSetCallback(new AnwbMapsItemSet(AnwbMapsBoundary.create(data.boundary),items));},error:function(e1,e2){if(console)console.log("Error retrieving dataset: "+e1+"("+e2+")");}});}
AnwbMapsSampleDataProvider.prototype=new AnwbMapsDataProvider;function AnwbMapsSampleDataProvider(nrOfPoints,coveragePercentage,newItemSetAtEveryCall){this.nrOfPoints=nrOfPoints;this.coveragePercentage=coveragePercentage?coveragePercentage:.40;this.itemSet=null;this.newItemSetAtEveryCall=newItemSetAtEveryCall;}
AnwbMapsSampleDataProvider.prototype.fetchItemSet=function(boundary,itemSetCallback){if(this.newItemSetAtEveryCall||!this.itemSet){boundary.zoomBounds.min=Math.max(boundary.zoomBounds.min-1,0);boundary.zoomBounds.max=Math.min(boundary.zoomBounds.max+1,17);this.itemSet=new AnwbMapsItemSet(boundary,new Array());for(i=1;i<=this.nrOfPoints;i++){this.itemSet.items.push(new AnwbMapsPoint(i,boundary.zoomBounds,((Math.random()*10)|0)+".) Marker #"+i,null,this.randomPoint(boundary.latLngBounds),true,(i%2)==0));}
this.itemSet.items.push(new AnwbMapsPolyline("redl1",new AnwbMapsZoomBounds(16,18),"redline1",null,true,"#ff0000",10,1,false,"arzhHadfw@hb@c|@hJwXoB_k@lLc^~b@cm@~[iR",20,"AAAAAAA",2));this.itemSet.items.push(new AnwbMapsPolyline("greenl2",new AnwbMapsZoomBounds(13,18),"greenline2",null,true,"#00ff00",10,0.5,true,"_vxhHkmgw@hVu_@rIiR|Oy`@nMo\zMwX",20,"AAAAAA",2));this.itemSet.items.push(new AnwbMapsPolyline("bluel3",new AnwbMapsZoomBounds(10,18),"blueline3",null,true,"#0000ff",10,0.5,false,"u{whH_niw@jBeEvCyGz@uAKgFo@oDMkBXaBn@a@h@?r@jAHdCk@`B",20,"BBBBBBBBBBBBB",2));}
itemSetCallback(this.itemSet);}
AnwbMapsSampleDataProvider.prototype.randomPoint=function(bounds){var lat=(Math.random()-0.5)*bounds.getLatitudeWidth()*this.coveragePercentage;var lng=(Math.random()-0.5)*bounds.getLongitudeWidth()*this.coveragePercentage;var center=bounds.getCenter();return new AnwbMapsLatLng(center.lat+lat,center.lng+lng);}
AnwbMapsRemoteDataProvider.prototype=new AnwbMapsDataProvider;function AnwbMapsRemoteDataProvider(delegateDataProvider){this.delegate=delegateDataProvider;}
AnwbMapsRemoteDataProvider.prototype.convertBoundaryFromJS=function(boundary){return boundary;}
AnwbMapsRemoteDataProvider.prototype.convertItemSetToJS=null;AnwbMapsRemoteDataProvider.prototype.fetchItemSet=function(boundary,callback){var handler=this;var localCallback=function(itemSet){callback(handler.convertItemSetToJS(itemSet));}
this.getItemSet(boundary,localCallback);}
AnwbMapsRemoteDataProvider.prototype.getItemSet=function(boundary,callback){};function AnwbMapsItemSet(boundary,items){this.boundary=boundary;this.items=items;}
AnwbMapsItem.prototype._overlay=null;AnwbMapsItem.prototype.inert=false;function AnwbMapsItem(typeId,id,zoomBounds,title,details,showInList){this.typeId=typeId;this.id=id;this.zoomBounds=zoomBounds;this.title=title;this.getLayer=function(){return this._layer};this.getOverlay=function(){return this._overlay};this.getEventListeners=function(){return this._eventListeners};this.showInList=showInList;}
AnwbMapsItem.prototype.extendGLatLngBounds=function(gLatLngBounds){return gLatLngBounds;}
AnwbMapsItem.prototype.getCenter=function(){return null;}
AnwbMapsPoint.prototype=new AnwbMapsItem;AnwbMapsPoint.prototype.constructor=AnwbMapsPoint;function AnwbMapsPoint(id,zoomBounds,title,details,latLng,showInList,inert){this.typeId="AnwbMapsPoint";this.id=id;this.zoomBounds=zoomBounds;this.title=title;this.details=details;this.latLng=latLng;this.showInList=showInList;this.inert=inert;}
AnwbMapsPoint.prototype.extendGLatLngBounds=function(gLatLngBounds){if(gLatLngBounds){gLatLngBounds.extend(new GLatLng(this.latLng.lat,this.latLng.lng));}
else{gLatLngBounds=new GLatLngBounds(new GLatLng(this.latLng.lat,this.latLng.lng),new GLatLng(this.latLng.lat,this.latLng.lng));}
return gLatLngBounds;}
AnwbMapsPoint.prototype.getCenter=function(){if(!this._overlay){return null;}
return this.getOverlay().getLatLng();}
AnwbMapsPointAndKML.prototype=new AnwbMapsItem;AnwbMapsPointAndKML.prototype.constructor=AnwbMapsPointAndKML;function AnwbMapsPointAndKML(id,zoomBounds,title,kmlUrl,kmlZoomBounds,latLng){this.typeId="AnwbMapsPointAndKML";this.id=id;this.zoomBounds=zoomBounds;this.title=title;this.kmlUrl=kmlUrl;this.kmlZoomBounds=kmlZoomBounds;this.latLng=latLng;}
AnwbMapsPointAndKML.prototype.extendGLatLngBounds=function(gLatLngBounds){if(gLatLngBounds){gLatLngBounds.extend(new GLatLng(this.latLng.lat,this.latLng.lng));}
else{gLatLngBounds=new GLatLngBounds(new GLatLng(this.latLng.lat,this.latLng.lng),new GLatLng(this.latLng.lat,this.latLng.lng));}
return gLatLngBounds;}
AnwbMapsPointAndKML.prototype.getCenter=function(){if(!this._overlay){return null;}
return this.getOverlay().getLatLng();}
AnwbMapsPolyline.prototype=new AnwbMapsItem;AnwbMapsPolyline.prototype.constructor=AnwbMapsPolyline;function AnwbMapsPolyline(id,boundary,title,details,showInList,color,weight,opacity,inert,encodedPoints,zoomFactor,encodedLevels,numLevels){this.typeId="AnwbMapsPolyline";this.id=id;this.boundary=boundary;this.title=title;this.details=details;this.showInList=showInList;this.color=color;this.weight=weight;this.opacity=opacity;this.inert=inert;this.encodedPoints=encodedPoints;this.zoomFactor=zoomFactor;this.encodedLevels=encodedLevels;this.numLevels=numLevels;}
AnwbMapsPolyline.prototype.getCenter=function(){if(!this.getOverlay()||this.getOverlay().getVertexCount()==0){return null;}
var centerVertexIndex=this.getOverlay().getVertexCount()/2;return this.getOverlay().getVertex(Math.floor(centerVertexIndex));}
AnwbMapsPolyline.prototype.extendGLatLngBounds=function(gLatLngBounds){var bounds;if(this._overlay){bounds=this.getOverlay().getBounds();}else{bounds=this.boundary.latLngBounds.toGLatLngBounds();}
if(gLatLngBounds){gLatLngBounds.extend(bounds.getSouthWest());gLatLngBounds.extend(bounds.getNorthEast());}else{gLatLngBounds=new GLatLngBounds(bounds.getSouthWest(),bounds.getNorthEast());}
return gLatLngBounds;};AnwbMapsDwrRemoteDataProvider.prototype=new AnwbMapsRemoteDataProvider;AnwbMapsDwrRemoteDataProvider.prototype.delegate=null;function AnwbMapsDwrRemoteDataProvider(baseUrl,dataSet,lazy,queueStyle){if(baseUrl.length>0&&baseUrl[baseUrl.length-1]!='/')baseUrl=baseUrl+'/';function QueryQueue(style){this.queries=new Array();var queries=this.queries;this.style=style;this.queueQuery=function(query){this.queries.push(query);}
this.clear=function(){this.queries=new Array();}
this.execute=function(args){if(!style||style=='fifo'){for(i=0;i<queries.length;i++){queries[i].apply(args);}}else if(style=='filo'){for(i=queries.length-1;i>=0;i--){queries[i].apply(args);}}else if(style=='lo'){queries[queries.length-1].apply(args);}else if(style=='fo'){queries[0].apply(args);}
this.clear();}}
this.queryQueue=new QueryQueue(queueStyle);if(!lazy)this.instantiateDelegate(baseUrl,dataSet);}
AnwbMapsDwrRemoteDataProvider.prototype.instantiateDelegate=function(baseUrl,dataSet){this.loadingDelegate=true;var dataProvider=this;new AnwbUtilsCachingResourceLoader([baseUrl+"util.js",baseUrl+"engine.js",baseUrl+"interface/"+dataSet+".js"],function(){dataProvider.delegate=eval(dataSet);dataProvider.queryQueue.execute(dataProvider.delegate);dataProvider.loadingDelegate=false;}).fetch();}
AnwbMapsDwrRemoteDataProvider.prototype.submitQuery=function(query){if(this.delegate){query(this.delegate);}else{if(!this.loadingDelegate)this.instantiateDelegate();this.queryQueue.queueQuery(query);}}
AnwbMapsDwrRemoteDataProvider.prototype.getItemSet=function(boundary,callback){var dataProvider=this;var delegateCallback=function(){dataProvider.delegate.getItemSet(dataProvider.convertBoundaryFromJS(boundary),callback);};this.submitQuery(delegateCallback);}
AnwbMapsDwrRemoteDataProvider.prototype.convertBoundaryFromJS=function(boundary){return boundary;}
AnwbMapsDwrRemoteDataProvider.prototype.convertBoundaryToJS=function(boundary){var latLngBounds=this.convertLatLngBoundsToJS(boundary.latLngBounds);var zoomBounds=this.convertZoomBoundsToJS(boundary.zoomBounds);return new AnwbMapsBoundary(latLngBounds,zoomBounds);}
AnwbMapsDwrRemoteDataProvider.prototype.convertBoundaryMultipliersToJS=function(boundaryMultipliers){return AnwbMapsBoundaryMultipliers(boundaryMultipliers.x,boundaryMultipliers.y,boundaryMultipliers.z);}
AnwbMapsDwrRemoteDataProvider.prototype.convertLatLngToJS=function(latLng){return new AnwbMapsLatLng(latLng.lat,latLng.lng);}
AnwbMapsDwrRemoteDataProvider.prototype.convertLatLngBoundsToJS=function(latLngBounds){var southWest=this.convertLatLngToJS(latLngBounds.southWest);var northEast=this.convertLatLngToJS(latLngBounds.northEast);return new AnwbMapsLatLngBounds(southWest,northEast);}
AnwbMapsDwrRemoteDataProvider.prototype.convertItemToJS=function(itemData){if(itemData.typeId=='TypeIdMarkerData'){return this.convertPointDataToJS(itemData);}
else if(itemData.typeId=='TypeIdPolyline'){return this.convertPolylineToJS(itemData);}}
AnwbMapsDwrRemoteDataProvider.prototype.convertPolylineToJS=function(itemData){var zoomBounds=this.convertZoomBoundsToJS(itemData.zoomBounds);return new AnwbMapsPolyline(itemData.id,zoomBounds,itemData.title,itemData.params,itemData.showInList,itemData.color,itemData.weight,itemData.opacity,itemData.inert,itemData.encodedPoints,itemData.zoomFactor,itemData.encodedLevels,itemData.numLevels);}
AnwbMapsDwrRemoteDataProvider.prototype.convertPointDataToJS=function(itemData){var point=this.convertLatLngToJS(itemData.point);var zoomBounds=this.convertZoomBoundsToJS(itemData.zoomBounds);return new AnwbMapsPoint(itemData.id,zoomBounds,itemData.title,itemData.params,point,itemData.showInList,itemData.inert);}
AnwbMapsDwrRemoteDataProvider.prototype.convertItemSetToJS=function(itemSet){var boundary=this.convertBoundaryToJS(itemSet.boundary);var markers=new Array(itemSet.items.length);var itemResultIndex=0;for(var i=0;i<itemSet.items.length;i++){var item=this.convertItemToJS(itemSet.items[i]);if(!item){continue;}
markers[itemResultIndex]=item;itemResultIndex++;}
return new AnwbMapsItemSet(boundary,markers);}
AnwbMapsDwrRemoteDataProvider.prototype.convertZoomBoundsToJS=function(zoomBounds){return new AnwbMapsZoomBounds(zoomBounds.min,zoomBounds.max);};AnwbMapsSeamRemoteDataProvider.prototype=new AnwbMapsRemoteDataProvider;AnwbMapsSeamRemoteDataProvider.prototype.delegate=null;AnwbMapsSeamRemoteDataProvider.prototype=new AnwbMapsRemoteDataProvider;function AnwbMapsSeamRemoteDataProvider(baseUrl,dataSet,lazy,queueStyle){if(baseUrl.length>0&&baseUrl[baseUrl.length-1]!='/')baseUrl=baseUrl+'/';this.baseUrl=baseUrl;this.dataSet=dataSet;this.lazy=lazy;this.delegate=null;function QueryQueue(style){this.queries=new Array();var queries=this.queries;this.style=style;this.queueQuery=function(query){this.queries.push(query);}
this.clear=function(){this.queries=new Array();}
this.execute=function(args){if(!style||style=='fifo'){for(i=0;i<queries.length;i++){queries[i].apply(args);}}else if(style=='filo'){for(i=queries.length-1;i>=0;i--){queries[i].apply(args);}}else if(style=='lo'){queries[queries.length-1].apply(args);}else if(style=='fo'){queries[0].apply(args);}
this.clear();}}
this.queryQueue=new QueryQueue(queueStyle);if(!lazy)this.instantiateDelegate(baseUrl,dataSet);}
AnwbMapsSeamRemoteDataProvider.prototype.instantiateDelegate=function(baseUrl,dataSet){this.loadingDelegate=true;var dataProvider=this;this._loaderTmp=new AnwbUtilsCachingResourceLoader([baseUrl+"resource/remote.js",baseUrl+"interface.js?"+dataSet],function(){dataProvider.delegate=Seam.Component.getInstance(dataSet);Seam.Remoting.displayLoadingMessage=function(){};Seam.Remoting.hideLoadingMessage=function(){};dataProvider.queryQueue.execute(dataProvider.delegate);dataProvider.loadingDelegate=false;}).fetch();}
AnwbMapsSeamRemoteDataProvider.prototype.submitQuery=function(query){if(this.delegate){query(this.delegate);}else{if(!this.loadingDelegate)this.instantiateDelegate(this.baseUrl,this.dataSet);this.queryQueue.queueQuery(query);}}
AnwbMapsSeamRemoteDataProvider.prototype.getItemSet=function(boundary,callback){var dataProvider=this;var delegateCallback=function(){dataProvider.delegate.getItemSet(dataProvider.convertBoundaryFromJS(boundary),callback);};this.submitQuery(delegateCallback);}
AnwbMapsSeamRemoteDataProvider.prototype.convertBoundaryFromJS=function(jsBoundary){var southWest=Seam.Remoting.createType("nl.anwb.online.support.maps.LatLng");southWest.setLat(jsBoundary.latLngBounds.southWest.lat);southWest.setLng(jsBoundary.latLngBounds.southWest.lng);var northEast=Seam.Remoting.createType("nl.anwb.online.support.maps.LatLng");northEast.setLat(jsBoundary.latLngBounds.northEast.lat);northEast.setLng(jsBoundary.latLngBounds.northEast.lng);var latLngBounds=Seam.Remoting.createType("nl.anwb.online.support.maps.LatLngBounds");latLngBounds.setSouthWest(southWest);latLngBounds.setNorthEast(northEast);var zoomBounds=Seam.Remoting.createType("nl.anwb.online.support.maps.ZoomBounds");zoomBounds.setMin(jsBoundary.zoomBounds.min);zoomBounds.setMax(jsBoundary.zoomBounds.max);var boundary=Seam.Remoting.createType("nl.anwb.online.support.maps.Boundary");boundary.setLatLngBounds(latLngBounds);boundary.setZoomBounds(zoomBounds);return boundary;}
AnwbMapsSeamRemoteDataProvider.prototype.convertBoundaryToJS=function(boundary){var latLngBounds=this.convertLatLngBoundsToJS(boundary.getLatLngBounds());var zoomBounds=this.convertZoomBoundsToJS(boundary.getZoomBounds());return new AnwbMapsBoundary(latLngBounds,zoomBounds);}
AnwbMapsSeamRemoteDataProvider.prototype.convertBoundaryMultipliersToJS=function(boundaryMultipliers){return new AnwbMapsBoundaryMultipliers(boundaryMultipliers.getX(),boundaryMultipliers.getY(),boundaryMultipliers.getZ());}
AnwbMapsSeamRemoteDataProvider.prototype.convertLatLngToJS=function(latLng){return new AnwbMapsLatLng(latLng.getLat(),latLng.getLng());}
AnwbMapsSeamRemoteDataProvider.prototype.convertLatLngBoundsToJS=function(latLngBounds){var southWest=this.convertLatLngToJS(latLngBounds.getSouthWest());var northEast=this.convertLatLngToJS(latLngBounds.getNorthEast());return new AnwbMapsLatLngBounds(southWest,northEast);}
AnwbMapsSeamRemoteDataProvider.prototype.convertItemToJS=function(itemData){if(itemData.typeId=='TypeIdMarkerData'){return this.convertPointDataToJS(itemData);}
else if(itemData.typeId=='TypeIdPolyline'){return this.convertPolylineToJS(itemData);}}
AnwbMapsSeamRemoteDataProvider.prototype.convertPointDataToJS=function(itemData){var point=this.convertLatLngToJS(itemData.getPoint());var zoomBounds=this.convertZoomBoundsToJS(itemData.getZoomBounds());return new AnwbMapsPoint(itemData.getId(),zoomBounds,itemData.getTitle(),itemData.getParams(),point,itemData.getShowInList(),itemData.getInert());}
AnwbMapsSeamRemoteDataProvider.prototype.convertPolylineToJS=function(itemData){var zoomBounds=this.convertZoomBoundsToJS(itemData.getZoomBounds());return new AnwbMapsPolyline(itemData.getId(),zoomBounds,itemData.getTitle(),itemData.getParams(),itemData.getShowInList(),itemData.getColor(),itemData.getWeight(),itemData.getOpacity(),itemData.getInert(),itemData.getEncodedPoints(),itemData.getZoomFactor(),itemData.getEncodedLevels(),itemData.getNumLevels());}
AnwbMapsSeamRemoteDataProvider.prototype.convertItemSetToJS=function(itemSet){var boundary=this.convertBoundaryToJS(itemSet.getBoundary());var markers=new Array(itemSet.getItems().length);var itemResultIndex=0;for(var i=0;i<itemSet.items.length;i++){var item=this.convertItemToJS(itemSet.items[i]);if(!item){continue;}
markers[itemResultIndex]=item;itemResultIndex++;}
return new AnwbMapsItemSet(boundary,markers);}
AnwbMapsSeamRemoteDataProvider.prototype.convertZoomBoundsToJS=function(zoomBounds){return new AnwbMapsZoomBounds(zoomBounds.getMin(),zoomBounds.getMax());};function AnwbMapsItemManager(map){if(map)this.setMap(map);}
AnwbMapsItemManager.prototype.setMap=function(map){this.map=map;if(this.markerManager)this.clearItems();this.markerManager=this.createMarkerManager(map.gmap);}
AnwbMapsItemManager.prototype.setLayer=function(layer){this.layer=layer;}
AnwbMapsItemManager.prototype.createMarkerManager=function(map){var me=this;var markerManager=new MarkerManager(map);markerManager.onHide=function(marker){}
markerManager.onShow=function(marker){}
markerManager.onLeave=function(marker){map.removeOverlay(marker);marker._anwb_is_on_map=false;me.onLeave(marker._item);};markerManager.onEnter=function(marker){map.addOverlay(marker);marker._anwb_is_on_map=true;me.onEnter(marker._item);};return markerManager;}
AnwbMapsItemManager.prototype.onLeave=function(){};AnwbMapsItemManager.prototype.onEnter=function(){};AnwbMapsItemManager.prototype.onClickCallback=function(item){if(item&&!item.inert&&item._layer&&item._layer.action){return item._layer.action.execute(item);}else{return true;}}
AnwbMapsItemManager.prototype.registerEventListeners=function(item,overlay){if(item.inert){return new Array();}
var itemManager=this;var clickListener=GEvent.addListener(overlay,"click",function(overlay){itemManager.onClickCallback(item);});return new Array(clickListener);}
AnwbMapsItemManager.prototype.items=new Array();AnwbMapsItemManager.prototype.addItem=function(item,overlay,layer){if(overlay){item._eventListeners=this.registerEventListeners(item,overlay);}
this.items.push(item);if(typeof(item)=='object'&&item.constructor==AnwbMapsPoint){var minZoom=item.zoomBounds?item.zoomBounds.min:0;var maxZoom=item.zoomBounds?item.zoomBounds.max:17;this.markerManager.addMarker(overlay,minZoom,maxZoom);}}
AnwbMapsItemManager.prototype.clearItems=function(){for(itemId in this.items){var item=this.items[itemId];if(item._eventListeners){for(eventId in item._eventListeners){GEvent.removeListener(item._eventListeners[eventId]);}}
if(typeof(item)=='object'&&item.constructor==AnwbMapsPolyline){if(item._overlay){this.map.gmap.removeOverlay(item._overlay)};}}
this.markerManager.clearMarkers();delete this.items;this.items=new Array();}
AnwbMapsItemManager.prototype.refresh=function(refetch){if(refetch){this.markerManager.refresh();}
var viewBoundary=this.map.getViewBoundary();for(var i=0,item;item=this.items[i++];){if(typeof(item)=='object'&&item.constructor==AnwbMapsPolyline){if(item.boundary.intersects(viewBoundary)){if(!item._overlay){this.layer.createOverlayFromItem(item,true);item._eventListeners=this.registerEventListeners(item,item._overlay);}
if(!item._shownOnMap){this.map.gmap.addOverlay(item._overlay);item._shownOnMap=true;this.onEnter(item);}}else{if(item._shownOnMap){this.map.gmap.removeOverlay(item._overlay);item._shownOnMap=false;this.onLeave(item);}}}}}
AnwbMapsItemManager.prototype.isVisible=function(item){if(typeof(item)=='object'&&(item.constructor==AnwbMapsPoint||item.constructor==AnwbMapsPointAndKML)){if(item._overlay._anwb_is_on_map!=undefined&&!item._overlay._anwb_is_on_map)return false;if(item._overlay.isHidden())return false;return this.map.gmap.getBounds().contains(item._overlay.getPoint())&&(!item.zoomBounds||item.zoomBounds.containsZoomLevel(this.map.gmap.getZoom()));}else if(typeof(item)=='object'&&item.constructor==AnwbMapsPolyline){return!item._overlay.isHidden();}}
AnwbMapsListBoundItemManager.prototype=new AnwbMapsItemManager;function AnwbMapsListBoundItemManager(list,style,selector,creator){this.style=style;this.list=list;if(selector)this.includeItemInList=selector;if(creator)this.createListItem=creator;}
AnwbMapsListBoundItemManager.prototype.listItems=new Array();AnwbMapsListBoundItemManager.prototype.style=null;AnwbMapsListBoundItemManager.prototype.list=new Array();AnwbMapsListBoundItemManager.SHOW_ALL_SELECTOR=function(){return true;}
AnwbMapsListBoundItemManager.SHOW_IN_LIST_SELECTOR=function(item){return!item.inert&&item.showInList;}
AnwbMapsListBoundItemManager.prototype.includeItemInList=AnwbMapsListBoundItemManager.SHOW_IN_LIST_SELECTOR;AnwbMapsListBoundItemManager.HREF_LIST_ITEM_CREATOR=function(item,onClickCallback,onMouseoverCallback,onMouseoutCallback){listHref=document.createElement("a");listHref.innerHTML=item.title;listHref.onclick=onClickCallback;listHref.onmouseover=onMouseoverCallback;listHref.onmouseout=onMouseoutCallback;listItem=document.createElement("li");listItem.appendChild(listHref);this.showListItem(listItem,false);return listItem;}
AnwbMapsListBoundItemManager.prototype.createListItem=AnwbMapsListBoundItemManager.HREF_LIST_ITEM_CREATOR;AnwbMapsListBoundItemManager.prototype.addItem=function(item,overlay,layer){AnwbMapsItemManager.prototype.addItem.call(this,item,overlay,layer);}
AnwbMapsListBoundItemManager.prototype.clearItems=function(){this.clearListItems();AnwbMapsItemManager.prototype.clearItems.call(this);}
AnwbMapsListBoundItemManager.prototype.clearListItems=function(){while(this.list.firstChild){this.list.removeChild(this.list.firstChild);}
this.listItems=new Array();}
AnwbMapsListBoundItemManager.prototype.itemSortCompare=function(a,b){if(a.title<b.title)return-1;if(a.title>b.title)return 1;return 0;}
AnwbMapsListBoundItemManager.prototype.refresh=function(refetch){AnwbMapsItemManager.prototype.refresh.call(this,refetch);if(refetch){this.clearListItems();this.items.sort(this.itemSortCompare);for(itemId in this.items){var listItem=this.addListItem(this.items[itemId]);if(listItem)this.list.appendChild(listItem);}}
for(itemId in this.items){var item=this.items[itemId];if(item&&item._overlay){var isVisible=this.isVisible(item);this.showListItem(this.listItems[item.id],isVisible);}}}
AnwbMapsListBoundItemManager.prototype.showListItem=function(htmlItem,show){if(!htmlItem){return;}
if(show){htmlItem.style.visibility='';htmlItem.style.height='';}
else{htmlItem.style.visibility='hidden';htmlItem.style.height='0px';}}
AnwbMapsListBoundItemManager.prototype.addListItem=function(item){if(this.includeItemInList(item)){itemManager=this;var onClickCallback=function(){var continueExecution=itemManager.onClickCallback(item);if(continueExecution){itemManager.map.setCenter(item.getCenter());}};var onMouseoverCallback=function(){itemManager.onMouseOverCallback(item);};var onMouseoutCallback=function(){itemManager.onMouseOutCallback(item);};var listItem=this.createListItem(item,onClickCallback,onMouseoverCallback,onMouseoutCallback);this.listItems[item.id]=listItem;this.updateListItemStyle(item,false,true);return listItem;}else{return null;}}
AnwbMapsListBoundItemManager.prototype.registerEventListeners=function(item,overlay){var itemManager=this;var listeners=AnwbMapsItemManager.prototype.registerEventListeners.call(this,item,overlay);if(this.includeItemInList(item)){listeners.push(GEvent.addListener(overlay,"mouseover",function(){itemManager.onMouseOverCallback(item);}));listeners.push(GEvent.addListener(overlay,"mouseout",function(){itemManager.onMouseOutCallback(item);}));}
return listeners;}
AnwbMapsListBoundItemManager.prototype.onClickCallback=function(item){if(this.style.visited)this.registerVisit(item);return AnwbMapsItemManager.prototype.onClickCallback.call(this,item);}
AnwbMapsListBoundItemManager.prototype.visitedItems=new Array();AnwbMapsListBoundItemManager.prototype.registerVisit=function(item){this.visitedItems[item.id]=true;}
AnwbMapsListBoundItemManager.prototype.onMouseOverCallback=function(item){this.updateListItemStyle(item,true);}
AnwbMapsListBoundItemManager.prototype.onMouseOutCallback=function(item){this.updateListItemStyle(item,false);}
AnwbMapsListBoundItemManager.prototype.updateListItemStyle=function(item,hover,reload){var updateMarker=this.style.marker&&!reload&&item._overlay.Nm;var visitedItem=this.style.visited&&this.visitedItems[item.id];if(hover){this.listItems[item.id].firstChild.className=(visitedItem)?this.style.visited.hover:this.style.normal.hover;if(updateMarker)item._overlay.setImage(this.style.marker.hover);}else{this.listItems[item.id].firstChild.className=(visitedItem)?this.style.visited.inactive:this.style.normal.inactive;if(updateMarker)item._overlay.setImage(this.style.marker.inactive);}};AnwbMapsCategoryItemManager.prototype=new AnwbMapsItemManager;function AnwbMapsCategoryItemManager(parameter,onUpdateCount,onEnterView,onLeaveView,onHideCategory,onShowCategory){this.parameter=parameter;this.onUpdateCount=onUpdateCount;this.onEnterView=onEnterView;this.onLeaveView=onLeaveView;this.onHideCategory=onHideCategory;this.onShowCategory=onShowCategory;this.categoryItems={};this.categoryCounts={};}
AnwbMapsCategoryItemManager.prototype.setActiveCategory=function(categoryName){if(this.activeCategory==categoryName)return;for(i in this.categoryItems[this.activeCategory]){this.onLeaveView(this.categoryItems[this.activeCategory][i],this.activeCategory);}
for(i in this.categoryItems[categoryName]){this.onEnterView(this.categoryItems[categoryName][i],categoryName,this);}
this.activeCategory=categoryName;}
AnwbMapsCategoryItemManager.prototype.onLeave=function(item){var category=item[this.parameter];var categoryBucket=this.categoryItems[category];var j=0;while(j<categoryBucket.length)categoryBucket[j]==item?categoryBucket.splice(j,1):j++;this.categoryCounts[category]--;if(category==this.activeCategory)this.onLeaveView(item,category,this);this.onUpdateCount(category,this.categoryCounts[category]);if(this.categoryCounts[category]==0)this.onHideCategory(category);}
AnwbMapsCategoryItemManager.prototype.onEnter=function(item){var category=item[this.parameter];if(!this.categoryItems[category])this.categoryItems[category]=[];this.categoryItems[category].push(item);if(!this.categoryCounts[category])this.categoryCounts[category]=0;this.categoryCounts[category]++;if(category==this.activeCategory)this.onEnterView(item,category,this);this.onUpdateCount(category,this.categoryCounts[category]);if(this.categoryCounts[category]==1)this.onShowCategory(category);}
function AnwbMapsItemProcessor(nextProcessor){this.nextProcessor=nextProcessor;}
AnwbMapsItemProcessor.prototype.attachProcessor=function(processor){if(this.nextProcessor)
processor.attachProcessor(this.nextProcessor);this.nextProcessor=processor;return this;}
AnwbMapsItemProcessor.prototype.preProcess=function(item,options){return item;}
AnwbMapsItemProcessor.prototype.postProcess=function(item,options){return item;}
AnwbMapsItemProcessor.prototype.getOptions=function(item,options){return{};}
AnwbMapsItemProcessor.prototype.process=function(item,options){item=this.preProcess(item,options);if(this.nextProcessor)
item=this.nextProcessor.process(item,options);return this.postProcess(item,options);}
AnwbMapsDefaultIconItemProcessor.prototype=new AnwbMapsItemProcessor;function AnwbMapsDefaultIconItemProcessor(nextProcessor,defaultIcon){this.nextProcessor=nextProcessor;this.defaultIcon=defaultIcon;}
AnwbMapsDefaultIconItemProcessor.prototype.getOptions=function(overlay,item){return{icon:this.defaultIcon};};AnwbMapsIconConfigurerItemProcessor.prototype=new AnwbMapsItemProcessor;function AnwbMapsIconConfigurerItemProcessor(nextProcessor,groupParamName,markerGroups,defaultIcon){this.nextProcessor=nextProcessor;this.groupParamName=groupParamName;if(markerGroups){this.markerGroups=markerGroups;}else{this.markerGroups={};}
this.defaultIcon=defaultIcon;};AnwbMapsIconConfigurerItemProcessor.prototype.addMarkerGroup=function(groupName,groupIcon){this.markerGroups[groupName]=groupIcon;};AnwbMapsIconConfigurerItemProcessor.prototype.removeMarkerGroup=function(groupName){delete this.markerGroups[groupName];};AnwbMapsIconConfigurerItemProcessor.prototype.setGroupParamName=function(groupParamName){this.groupParamName=groupParamName;};AnwbMapsIconConfigurerItemProcessor.prototype.getGroupParamName=function(){return groupParamName;};AnwbMapsIconConfigurerItemProcessor.prototype.setDefaultIcon=function(defaultIcon){this.defaultIcon=defaultIcon;}
AnwbMapsIconConfigurerItemProcessor.prototype.getDefaultIcon=function(){return this.defaultIcon;}
AnwbMapsIconConfigurerItemProcessor.prototype.getOptions=function(overlay,item){return{icon:this.markerGroups[item[this.groupParamName]]||this.defaultIcon};};var nl={anwb:{online:{support:{maps:{Map:AnwbMapsMap,BrowserIsCompatible:AnwbMapsBrowserIsCompatible,Boundary:AnwbMapsBoundary,BoundaryMultipliers:AnwbMapsBoundaryMultipliers,LatLng:AnwbMapsLatLng,LatLngBounds:AnwbMapsLatLngBounds,ZoomBounds:AnwbMapsZoomBounds,layer:{Layer:AnwbMapsLayer,DataLayer:AnwbMapsDataLayer,KmlLayer:AnwbMapsKmlLayer},manager:{ItemManager:AnwbMapsItemManager,ListBoundItemManager:AnwbMapsListBoundItemManager},processor:{ItemProcessor:AnwbMapsItemProcessor,IconConfigurerItemProcessor:AnwbMapsIconConfigurerItemProcessor,DefaultIconItemProcessor:AnwbMapsDefaultIconItemProcessor},dataprovider:{DataProvider:AnwbMapsDataProvider,LocalDataProvider:AnwbMapsLocalDataProvider,SampleDataProvider:AnwbMapsSampleDataProvider,RemoteDataProvider:AnwbMapsRemoteDataProvider,DwrRemoteDataProvider:AnwbMapsDwrRemoteDataProvider,SeamRemoteDataProvider:AnwbMapsSeamRemoteDataProvider},Item:AnwbMapsItem,Point:AnwbMapsPoint,Polyline:AnwbMapsPolyline,ItemSet:AnwbMapsItemSet,action:{Action:AnwbMapsAction,InfoWindowAction:AnwbMapsInfoWindowAction,LinkAction:AnwbMapsLinkAction,DivAction:AnwbMapsDivAction,IFrameAction:AnwbMapsIFrameAction}}}}}};function AnwbUtilsResourceLoader(resources,onLoadCallback){this.resources=resources;this.onLoadCallback=onLoadCallback;}
AnwbUtilsResourceLoader.prototype.fetch=function(){if(this.resources.length<1){if(this.onLoadCallback)onLoadCallback();return;}
var head=document.getElementsByTagName("head")[0];var loader=this;var resources=this.resources;var onLoadCallback=this.onLoadCallback;var counter=resources.length;var callbackCreator=function(resource,domElement){var loaded=false;return function(){if(!loaded){loaded=true;if(loader.postFetchCallback)loader.postFetchCallback(resource);if(--counter==0){loader.onLoadCallback();head.removeChild(domElement);}}}};for(i=0;i<resources.length;i++){var resource=resources[i];if(typeof(resource)=='string')resource={url:resource};if(!resource.type)resource.type="text/javascript";if(!loader.preFetchCallback||loader.preFetchCallback(resource)){var domElement=document.createElement("script");domElement.src=resource.url;domElement.type=resource.type;if(onLoadCallback){domElement.callback=callbackCreator(resource,domElement);if(resource.callbackSetter){resource.callbackSetter(domElement.callback);}
else{domElement.onload=domElement.onreadystatechange=function(){if(!this.readyState||this.readyState=='complete'||this.readyState=='loaded'){this.callback();}}}}
head.appendChild(domElement);}else{if(--counter==0)
this.onLoadCallback();}}}
AnwbUtilsCachingResourceLoader.prototype=new AnwbUtilsResourceLoader;function AnwbUtilsCachingResourceLoader(resources,onLoadCallback,reschedule,cacheRegister){AnwbUtilsResourceLoader.call(this,resources,onLoadCallback);this.reschedule=reschedule;loaderClass=AnwbUtilsCachingResourceLoader;this.cacheRegister=cacheRegister||loaderClass.resourceCache?loaderClass.resourceCache:loaderClass.resourceCache={};}
AnwbUtilsCachingResourceLoader.prototype.postFetchCallback=function(resource){this.cacheRegister[resource.src]=true;}
AnwbUtilsCachingResourceLoader.prototype.preFetchCallback=function(resource){var registryEntry=this.cacheRegister[resource.url];var continueFetch=(registryEntry==undefined)?true:(this.reschedule&&registryEntry==false);if(continueFetch)this.cacheRegister[resource.url]=false;return continueFetch;}
AnwbUtilsResourceLoader.loadAnwbMaps=function(definitionOrCallback){if(typeof(definitionOrCallback)=='function'){createCallback=definitionOrCallback;}else{createCallback=function(){AnwbMaps.create(definitionOrCallback);}}
var resources=[{url:"http://maps.google.com/maps?file=api&v=2&key="+ANWB_MAPS_KEY+"&async=2&callback=_anwbMapsOnLoadCallback",callbackSetter:function(callback){self._anwbMapsOnLoadCallback=callback}},"markermanager.js","nl.anwb.maps.js","nl.anwb.maps.model.js","nl.anwb.maps.action.js","nl.anwb.maps.processor.js","nl.anwb.maps.manager.js","nl.anwb.maps.layer.js","nl.anwb.maps.dataprovider.js","nl.anwb.maps.dataprovider.dwr.js","nl.anwb.maps.dataprovider.seam.js","nl.anwb.maps.factory.js","nl.anwb.maps.classes.js"];new AnwbUtilsCachingResourceLoader(resources,createCallback).fetch();}
Function.AbstractFunction=function(){throw new Error("Abstract function called.");}
Error.throwOnConditions=function(conditions){for(conditionName in conditions){if(conditions[conditionName]){throw new Error(conditionName);}}};AnwbMapsAction.create=function(def){if(!def||def.constructor!=Object)return def;if(def.type=='info-window'){return new AnwbMapsInfoWindowAction.create(def);}else if(def.type=='link'){return new AnwbMapsLinkAction.create(def);}else if(def.type=='div'){return new AnwbMapsDivAction.create(def);}else if(def.type=='iframe'){return new AnwbMapsIFrameAction.create(def);}else{return null;}}
AnwbMapsInfoWindowAction.create=function(def){if(!def||def.constructor!=Object)return def;return new AnwbMapsInfoWindowAction(def.param,def.generator,def.isUrl);}
AnwbMapsDivAction.create=function(def){if(!def||def.constructor!=Object)return def;return new AnwbMapsDivAction(def.div,def.param,def.generator);}
AnwbMapsLinkAction.create=function(def){if(!def||def.constructor!=Object)return def;return new AnwbMapsLinkAction(def.param,def.generator);}
AnwbMapsIFrameAction.create=function(def){if(!def||def.constructor!=Object)return def;return new AnwbMapsIFrameAction(def.iframe,def.preFix,def.param,def.postFix,def.generator);}
AnwbMapsDataProvider.create=function(def){if(!def||def.constructor!=Object)return def;if(def.type=='seam'){return new AnwbMapsSeamRemoteDataProvider.create(def);}else if(def.type=='dwr'){return new AnwbMapsDwrRemoteDataProvider.create(def);}else if(def.type=='local'){return new AnwbMapsLocalDataProvider.create(def);}else{return null;}}
AnwbMapsLocalDataProvider.create=function(def){if(!def||def.constructor!=Object)return def;return new AnwbMapsLocalDataProvider(AnwbMapsItemSet.create(def.itemSet));}
AnwbMapsSeamRemoteDataProvider.create=function(def){if(!def||def.constructor!=Object)return def;return new AnwbMapsSeamRemoteDataProvider(def.baseUrl,def.dataSet,def.lazy,def.queueStyle);}
AnwbMapsDwrRemoteDataProvider.create=function(def){if(!def||def.constructor!=Object)return def;return new AnwbMapsDwrRemoteDataProvider(def.baseUrl,def.dataSet,def.lazy,def.queueStyle);}
AnwbMapsJSONDataProvider.create=function(def){if(!def||def.constructor!=Object)return def;return new AnwbMapsJSONDataProvider(def.url,def.expander,def.extraParams);}
AnwbMapsLayer.create=function(def){if(!def||def.constructor!=Object)return def;var layer;if(def.type=='kml'){layer=new AnwbMapsKmlLayer.create(def);}else if(def.type=='data'){layer=new AnwbMapsDataLayer.create(def);}
return layer;}
AnwbMapsDataLayer.create=function(def){if(!def||def.constructor!=Object)return def;var dataLayer=new AnwbMapsDataLayer(AnwbMapsDataProvider.create(def.dataProvider),AnwbMapsAction.create(def.action),AnwbMapsItemProcessor.create(def.itemProcessor),AnwbMapsItemManager.create(def.itemManager),AnwbMapsBoundary.create(def.activeBoundary));if(def.dataBoundaryMultipliers){dataLayer.setDataBoundaryMultipliers(AnwbMapsBoundaryMultipliers.create(def.dataBoundaryMultipliers));}
if(def.viewBoundaryMultipliers){dataLayer.setVirtualViewBoundaryMultipliers(AnwbMapsBoundaryMultipliers.create(def.virtualViewBoundaryMultipliers));}
return dataLayer;}
AnwbMapsKmlLayer.create=function(def){if(!def||def.constructor!=Object)return def;return new AnwbMapsKmlLayer(def.url,AnwbMapsZoomBounds.create(def.zoomBounds),AnwbMapsAction.create(def.action),AnwbMapsBoundary.create(def.activeBoundary));}
AnwbMapsMap.create=function(def,div){if(!def||def.constructor!=Object)return def;map=new AnwbMapsMap(div,def);for(i=0;i<def.layers.length;i++){map.addLayer(AnwbMapsLayer.create(def.layers[i]));}
return map;}
AnwbMapsItemManager.create=function(def){if(!def||def.constructor!=Object)return def;if(def.type=='list'){return AnwbMapsListBoundItemManager.create(def);}else if(def.type=='category'){return AnwbMapsCategoryItemManager.create(def);}else{return new AnwbMapsItemManager();}};AnwbMapsListBoundItemManager.create=function(def){if(!def||def.constructor!=Object)return def;return new AnwbMapsListBoundItemManager(def.list,def.style,def.selector,def.creator);}
AnwbMapsCategoryItemManager.create=function(def){if(!def||def.constructor!=Object)return def;return new AnwbMapsCategoryItemManager(def.parameter,def.onUpdateCount,def.onEnterView,def.onLeaveView,def.onHideCategory,def.onShowCategory);}
AnwbMapsBoundary.create=function(def){if(def=='EVERYTHING'){def={latLngBounds:{southWest:{lat:-90,lng:-180},northEast:{lat:90,lng:180}},zoomBounds:{min:0,max:18}};}
if(!def||def.constructor!=Object)return def;if(def.bounds&&!def.latLngBounds)def.latLngBounds=def.bounds;return new AnwbMapsBoundary(AnwbMapsLatLngBounds.create(def.latLngBounds),AnwbMapsZoomBounds.create(def.zoomBounds));}
AnwbMapsLatLngBounds.create=function(def){if(def&&def.constructor==GBounds)return AnwbMapsLatLngBounds.createFromGoogle(def);if(!def||def.constructor!=Object)return def;return new AnwbMapsLatLngBounds(AnwbMapsLatLng.create(def.southWest),AnwbMapsLatLng.create(def.northEast));}
AnwbMapsLatLngBounds.createFromGoogle=function(def){return new AnwbMapsLatLngBounds(AnwbMapsLatLng.create(def.getSouthWest()),AnwbMapsLatLng.create(def.getNorthEast()));}
AnwbMapsLatLng.create=function(def){if(!def||def.constructor!=Object)return def;return new AnwbMapsLatLng(def.lat,def.lng);}
AnwbMapsZoomBounds.create=function(def){if(!def||def.constructor==AnwbMapsZoomBounds)return def;if(typeof(def)=='number')return new AnwbMapsZoomBounds(def,def);return new AnwbMapsZoomBounds(def.min,def.max);}
AnwbMapsBoundaryMultipliers.create=function(def){if(!def||def.constructor==AnwbMapsBoundaryMultipliers)return def;return new AnwbMapsBoundaryMultipliers(def.x,def.y,def.z);}
AnwbMapsItemSet.create=function(def){if(!def||def.constructor!=Object)return def;var items=[];for(i=0;i<def.items.length;i++){items.push(AnwbMapsItem.create(def.items[i]));}
return new AnwbMapsItemSet(AnwbMapsBoundary.create(def.boundary||'EVERYTHING'),items);}
AnwbMapsItem.create=function(def){if(!def||def.constructor!=Object)return def;if(!def.type||def.type=='point'){delete def.type;return AnwbMapsPoint.create(def);}else if(def.type=='point-kml'){delete def.type;return AnwbMapsPointAndKML.create(def);}else if(def.type=='line'){delete def.type;return AnwbMapsPolyline.create(def);}}
AnwbMapsPoint.create=function(def){if(!def||def.constructor!=Object)return def;var point=new AnwbMapsPoint(def.id,AnwbMapsZoomBounds.create(def.zoomBounds),def.title,null,AnwbMapsLatLng.create(def.latLng||def.point),def.showInList,def.inert);for(key in def){if(key!='id'&&key!='zoomBounds'&&key!='title'&&key!='details'&&key!='latLng'&&key!='point'&&key!='showInList'&&key!='inert'){point[key]=def[key];}}
return point;}
AnwbMapsPointAndKML.create=function(def){if(!def||def.constructor!=Object)return def;var point=new AnwbMapsPointAndKML(def.id,AnwbMapsZoomBounds.create(def.zoomBounds),def.title,def.kmlUrl,AnwbMapsZoomBounds.create(def.kmlZoomBounds),AnwbMapsLatLng.create(def.latLng||def.point));for(key in def){if(key!='id'&&key!='zoomBounds'&&key!='title'&&key!='kmlUrl'&&key!='kmlZoomBounds'&&key!='latLng'&&key!='point'){point[key]=def[key];}}
return point;}
AnwbMapsPolyline.create=function(def){if(!def||def.constructor!=Object)return def;var polyline=new AnwbMapsPolyline(def.id,AnwbMapsBoundary.create(def.boundary),def.title,def.details,def.showInList,def.color,def.weight,def.opacity,def.inert,def.encodedPoints,def.zoomFactor,def.encodedLevels,def.numLevels);for(key in def){if(key!='id'&&key!='boundary'&&key!='title'&&key!='details'&&key!='showInList'&&key!='color'&&key!='weight'&&key!='opacity'&&key!='inert'&&key!='encodedPoints'&&key!='zoomFactor'&&key!='encodedLevels'&&key!='numLevels'){polyline[key]=def[key];}}
return polyline;}
AnwbMapsItemProcessor.create=function(def){if(!def||def.constructor!=Object)return def;if(def.type=='default-icon'){return new AnwbMapsDefaultIconItemProcessor.create(def);}else if(def.type=='group-icon'){return new AnwbMapsIconConfigurerItemProcessor.create(def);}}
AnwbMapsDefaultIconItemProcessor.create=function(def){if(!def||def.constructor!=Object)return def;return new AnwbMapsDefaultIconItemProcessor(def.nextProcessor,def.icon);}
AnwbMapsIconConfigurerItemProcessor.create=function(def){if(!def||def.constructor!=Object)return def;return new AnwbMapsIconConfigurerItemProcessor(def.nextProcessor,def.parameter,def.groups,def.defaultIcon);};