Skip to content

Commit

Permalink
jd: [trunk/SharpLayers] adding a couple of files present in the tagge…
Browse files Browse the repository at this point in the history
…d version but not the trunk. additional functionality for a Measure/MeasureTool.js, OSM layer and Yahoo Layer
  • Loading branch information
jaundice committed Aug 31, 2011
1 parent ffc464c commit d1442fa
Show file tree
Hide file tree
Showing 13 changed files with 269 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,28 @@ SharpMap.Presentation.Web.SharpLayers.Controls.Measure.MeasureTool.prototype = {
var call = options.onClientMeasure;
delete options.onClientMeasure;


options.type = OpenLayers.Control.TYPE_TOOL;
options.displayClass = (options.displayClass) || "olControlMeasure";
call = (call) ? call : function(e) { alert(Math.round(e.measure) + e.units, "Measurement"); };

if (options.mode == 'Area') {
options.displayClass = (options.displayClass) || "olControlMeasureArea";

}
else {
options.displayClass = (options.displayClass) || "olControlMeasure";
}
call = (call) ? call : function(e) {


if (options.mode == 'Area') {
alert("Approx " + Math.round(e.measure,2) + " square " + e.units, "Measurement");
}
else {
alert("Approx " + Math.round(e.measure,2) + " " + e.units, "Measurement");
}


};



Expand All @@ -83,7 +102,7 @@ SharpMap.Presentation.Web.SharpLayers.Controls.Measure.MeasureTool.prototype = {
OpenLayers.Control.Panel.onPanelActivated(this);
return this._onClick(ctl, evt);
};

p.addControls([m]);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public class MeasureToolBuilderParams : ToolBuilderParamsBase
private MeasureToolMode _mode = MeasureToolMode.Distance;
private MeasureToolUnits _unit = MeasureToolUnits.Metric;

[ExtenderControlProperty]
[ClientPropertyName("mode")]
[ComponentReference]
public MeasureToolMode Mode
{
get { return _mode; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class LayerBuilderParamsBase : ILayerBuilderParams
[ClientPropertyName("resolutions")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible),
PersistenceMode(PersistenceMode.InnerProperty)]
public CollectionBase<DoubleValue> Resolutions
public virtual CollectionBase<DoubleValue> Resolutions
{
get { return _resolutions; }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* The attached / following is part of SharpMap.Presentation.Web.SharpLayers
* SharpMap.Presentation.Web.SharpLayers is free software © 2008 Newgrove Consultants Limited,
* www.newgrove.com; you can redistribute it and/or modify it under the terms
* of the current GNU Lesser General Public License (LGPL) as published by and
* available from the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA: http://fsf.org/
* This program is distributed without any warranty;
* without even the implied warranty of merchantability or fitness for purpose.
* See the GNU Lesser General Public License for the full details.
*
* Author: John Diss 2010
*
*/
using System.ComponentModel;
using System.Web.UI;
using AjaxControlToolkit;

namespace SharpMap.Presentation.Web.SharpLayers.Layers.Osm
{
public class OsmLayerBuilderParams : LayerBuilderParamsBase, IGridBasedLayerBuilderParams
{
#region IGridBasedLayerBuilderParams Members

[ExtenderControlProperty(true, true)]
[ClientPropertyName("tileSize")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible),
PersistenceMode(PersistenceMode.InnerProperty)]
public Size TileSize { get; set; }

[ExtenderControlProperty]
[ClientPropertyName("transitionEffect")]
public TransitionEffects TransitionEffect { get; set; }

[ExtenderControlProperty]
[ClientPropertyName("buffer")]
public int Buffer { get; set; }

#endregion
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* The attached / following is part of SharpMap.Presentation.Web.SharpLayers
* SharpMap.Presentation.Web.SharpLayers is free software © 2008 Newgrove Consultants Limited,
* www.newgrove.com; you can redistribute it and/or modify it under the terms
* of the current GNU Lesser General Public License (LGPL) as published by and
* available from the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA: http://fsf.org/
* This program is distributed without any warranty;
* without even the implied warranty of merchantability or fitness for purpose.
* See the GNU Lesser General Public License for the full details.
*
* Author: John Diss 2010
*
*/

using System.Web.UI;
using AjaxControlToolkit;
[assembly: WebResource("SharpMap.Presentation.Web.SharpLayers.Layers.Osm.OsmLayerComponent.js", "text/javascript")]
namespace SharpMap.Presentation.Web.SharpLayers.Layers.Osm
{
[ClientScriptResource("SharpMap.Presentation.Web.SharpLayers.Layers.Osm.OsmLayerComponent",
"SharpMap.Presentation.Web.SharpLayers.Layers.Osm.OsmLayerComponent.js")]
[TargetControlType(typeof (Control))]
public class OsmLayerComponent : LayerComponent<OsmLayerBuilderParams>
{
protected override string ScriptComponentName
{
get { return "SharpMap.Presentation.Web.SharpLayers.Layers.Osm.OsmLayerComponent"; }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* The attached / following is part of SharpMap.Presentation.Web.SharpLayers
* SharpMap.Presentation.Web.SharpLayers is free software © 2008 Newgrove Consultants Limited,
* www.newgrove.com; you can redistribute it and/or modify it under the terms
* of the current GNU Lesser General Public License (LGPL) as published by and
* available from the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA: http://fsf.org/
* This program is distributed without any warranty;
* without even the implied warranty of merchantability or fitness for purpose.
* See the GNU Lesser General Public License for the full details.
*
* Author: John Diss 2010
*
*/
Type.registerNamespace('SharpMap.Presentation.Web.SharpLayers.Layers.Osm');

SharpMap.Presentation.Web.SharpLayers.Layers.Osm.OsmLayerComponent = function() {
SharpMap.Presentation.Web.SharpLayers.Layers.Osm.OsmLayerComponent.initializeBase(this);


}
SharpMap.Presentation.Web.SharpLayers.Layers.Osm.OsmLayerComponent.prototype = {
initialize: function() {
this._builderDelegate = Function.createDelegate(this, this._layerBuilderDelegate);
SharpMap.Presentation.Web.SharpLayers.Layers.Osm.OsmLayerComponent.callBaseMethod(this, 'initialize');
},
dispose: function() {
SharpMap.Presentation.Web.SharpLayers.Layers.Osm.OsmLayerComponent.callBaseMethod(this, 'dispose');
},
_layerBuilderDelegate: function() {
var options = this.get_builderParams();
var url = options.url;
delete options.url;
return new OpenLayers.Layer.OSM(this.get_name(), url, options);
}
}
SharpMap.Presentation.Web.SharpLayers.Layers.Osm.OsmLayerComponent.registerClass('SharpMap.Presentation.Web.SharpLayers.Layers.Osm.OsmLayerComponent', SharpMap.Presentation.Web.SharpLayers.Layers.LayerComponent);
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System.ComponentModel;
using System.Linq;
using System.Web.UI;
using AjaxControlToolkit;

namespace SharpMap.Presentation.Web.SharpLayers.Layers.Yahoo
{
public class YahooLayerBuilderParams : LayerBuilderParamsBase, IGridBasedLayerBuilderParams
{

[ExtenderControlProperty(true, true)]
[ClientPropertyName("tileSize")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible),
PersistenceMode(PersistenceMode.InnerProperty)]
public Size TileSize { get; set; }

[ExtenderControlProperty]
[ClientPropertyName("transitionEffect")]
public TransitionEffects TransitionEffect { get; set; }

[ExtenderControlProperty]
[ClientPropertyName("buffer")]
public int Buffer { get; set; }


[ExtenderControlProperty]
[ClientPropertyName("sphericalMercator")]
public bool SphericalMercator
{
get;
set;
}


[ClientPropertyName("resolutions")]
public override CollectionBase<DoubleValue> Resolutions
{
get
{
return base.Resolutions;
}
}
//[ExtenderControlProperty]
//[ClientPropertyName("mapType")]
//public YahooMapType MapType //enabling this breaks everything else
//{
// get;
// set;
//}

}

//public enum YahooMapType
//{
// YAHOO_MAP_REG = 0,
// YAHOO_MAP_HYB,
// YAHOO_MAP_SAT
//}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Web.UI;
using AjaxControlToolkit;

[assembly: WebResource("SharpMap.Presentation.Web.SharpLayers.Layers.Yahoo.YahooLayerComponent.js", "text/javascript")]

namespace SharpMap.Presentation.Web.SharpLayers.Layers.Yahoo
{
[ClientScriptResource("SharpMap.Presentation.Web.SharpLayers.Layers.Yahoo.YahooLayerComponent",
"SharpMap.Presentation.Web.SharpLayers.Layers.Yahoo.YahooLayerComponent.js")]
[TargetControlType(typeof (Control))]
public class YahooLayerComponent : LayerComponent<YahooLayerBuilderParams>
{
protected override string ScriptComponentName
{
get { return "SharpMap.Presentation.Web.SharpLayers.Layers.Yahoo.YahooLayerComponent"; }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* The attached / following is part of SharpMap.Presentation.Web.SharpLayers
* SharpMap.Presentation.Web.SharpLayers is free software © 2008 Newgrove Consultants Limited,
* www.newgrove.com; you can redistribute it and/or modify it under the terms
* of the current GNU Lesser General Public License (LGPL) as published by and
* available from the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA: http://fsf.org/
* This program is distributed without any warranty;
* without even the implied warranty of merchantability or fitness for purpose.
* See the GNU Lesser General Public License for the full details.
*
* Author: John Diss 2010
*
*/
Type.registerNamespace('SharpMap.Presentation.Web.SharpLayers.Layers.Yahoo');

SharpMap.Presentation.Web.SharpLayers.Layers.Yahoo.YahooLayerComponent = function() {
SharpMap.Presentation.Web.SharpLayers.Layers.Yahoo.YahooLayerComponent.initializeBase(this);


}
SharpMap.Presentation.Web.SharpLayers.Layers.Yahoo.YahooLayerComponent.prototype = {
initialize: function() {
this._builderDelegate = Function.createDelegate(this, this._layerBuilderDelegate);
SharpMap.Presentation.Web.SharpLayers.Layers.Yahoo.YahooLayerComponent.callBaseMethod(this, 'initialize');
},
dispose: function() {
SharpMap.Presentation.Web.SharpLayers.Layers.Yahoo.YahooLayerComponent.callBaseMethod(this, 'dispose');
},
_layerBuilderDelegate: function() {
var options = this.get_builderParams();
var mapType = options.mapType;
delete options.mapType;
if ((mapType))
options.type = mapType;
return new OpenLayers.Layer.Yahoo(this.get_name(), options);
}
}
SharpMap.Presentation.Web.SharpLayers.Layers.Yahoo.YahooLayerComponent.registerClass('SharpMap.Presentation.Web.SharpLayers.Layers.Yahoo.YahooLayerComponent', SharpMap.Presentation.Web.SharpLayers.Layers.LayerComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ SharpMap.Presentation.Web.SharpLayers.MapHostBehavior.prototype = {
},
set_initialExtent: function(value) {
this._initialExtent = value;
if ((this._initialExtent))
this.zoomToInitialExtent();
},
_mapBuilderDelegate: function() {
var options = this.get_builderParams();
Expand All @@ -54,9 +56,14 @@ SharpMap.Presentation.Web.SharpLayers.MapHostBehavior.prototype = {
this.get_hostedItem().addControl(cntrl);
},
zoomToInitialExtent: function() {
SharpMap.Presentation.Web.SharpLayers.InitSync.addPostLoad(Function.createDelegate(this, function() { this._realZoomToInitialExtent(); }))
SharpMap.Presentation.Web.SharpLayers.InitSync.addPostLoad(Function.createDelegate(this, function() {
var f = Function.createDelegate(this, this._zoomToInitialExtent)
window.setTimeout(f, 20);
}));
/*hideous hack to allow other postload items to complete before this one actually does its work.
necessary because of IE/ a complex page layout utilising a sucky splitter panel which inits at its own pace*/
},
_realZoomToInitialExtent: function() {
_zoomToInitialExtent: function() {
if (!(this.get_hostedItem()))
return;
var bounds = this.get_initialExtent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
using System.Runtime.InteropServices;
using AjaxControlToolkit;

[assembly: ScriptCombine]
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: ScriptCombine]
[assembly: AssemblyTitle("SharpLayers")]
[assembly: AssemblyDescription("Asp.Net Wrapper for OpenLayers")]
[assembly: AssemblyConfiguration("")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@
<Compile Include="Layers\ILayerBuilderParams.cs" />
<Compile Include="Layers\LayerBuilderParamsBase.cs" />
<Compile Include="Layers\LayerComponent.cs" />
<Compile Include="Layers\Osm\OsmLayerBuilderParams.cs" />
<Compile Include="Layers\Osm\OsmLayerComponent.cs" />
<Compile Include="Layers\Tms\TmsLayerBuilderParams.cs" />
<Compile Include="Layers\Tms\TmsLayerComponent.cs" />
<Compile Include="Layers\TransitionEffects.cs" />
Expand All @@ -214,6 +216,8 @@
<Compile Include="Layers\Vector\VectorLayerComponent.cs" />
<Compile Include="Layers\Wms\WmsLayerBuilderParams.cs" />
<Compile Include="Layers\Wms\WmsLayerComponent.cs" />
<Compile Include="Layers\Yahoo\YahooLayerBuilderParams.cs" />
<Compile Include="Layers\Yahoo\YahooLayerComponent.cs" />
<Compile Include="SharpLayersScriptObjectBuilder.cs" />
<Compile Include="StringValue.cs" />
<Compile Include="Layers\Wms\WmsParameters.cs" />
Expand Down Expand Up @@ -271,6 +275,8 @@
<ItemGroup>
<EmbeddedResource Include="Controls\Measure\MeasureTool.js" />
<EmbeddedResource Include="Controls\Measure\MeasureToolButton.js" />
<EmbeddedResource Include="Layers\Osm\OsmLayerComponent.js" />
<EmbeddedResource Include="Layers\Yahoo\YahooLayerComponent.js" />
<Content Include="OpenLayers\Build\build.py" />
<Content Include="OpenLayers\Build\buildUncompressed.py" />
<Content Include="OpenLayers\Build\ipy.exe" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ object IUICollectionItem.Value
}

#endregion


}
}

0 comments on commit d1442fa

Please sign in to comment.