Problem with clik and themes

Aug 11, 2007 at 9:36 PM
I have MNorm_Ajax3 web site, i try to modif. This to do that:

1) on click query and display info about anything, but when I click on map this steel work like zoom in/out, etc,

2) I have create a theme on roads, this work fine, but when on styles I set max and min visibility they not work.

This is the code of maphelper.cs and below is the code of ajax.aspx

//calles
SharpMap.Layers.VectorLayer layCalles = new SharpMap.Layers.VectorLayer("Calles");
layCalles.DataSource = new SharpMap.Data.Providers.ShapeFile(HttpContext.Current.Server.MapPath(@"~\App_Data\Mapas\Uruguay\calles.shp"), true);
layCalles.Style.EnableOutline = true;
layCalles.Style.Line = new Pen(Color.FromArgb(128, 255, 255, 0), 10);
SharpMap.Rendering.Thematics.CustomTheme iTheme = new SharpMap.Rendering.Thematics.CustomTheme(GetCustomStyleCalles);
SharpMap.Styles.VectorStyle defaultstyle = new SharpMap.Styles.VectorStyle();
// default style
defaultstyle.Outline = new Pen(Color.Black, 1);
defaultstyle.Line.Width = 4;
defaultstyle.Line.Color = Color.FromArgb(255, 198, 64);
defaultstyle.Line.EndCap = System.Drawing.Drawing2D.LineCap.Round;
defaultstyle.Line.StartCap = defaultstyle.Line.EndCap;
defaultstyle.Outline = (System.Drawing.Pen)defaultstyle.Line.Clone();
defaultstyle.Outline.Width += 1.5f;
defaultstyle.Outline.Color = Color.Black;
defaultstyle.EnableOutline = false;
iTheme.DefaultStyle = defaultstyle;
layCalles.Theme = iTheme;

public static SharpMap.Styles.VectorStyle GetCustomStyleCalles(SharpMap.Data.FeatureDataRow row)
{
SharpMap.Styles.VectorStyle style = new SharpMap.Styles.VectorStyle();
switch (row"TIPO".ToString().ToUpper())
{
case "":
style.Outline = new Pen(Color.Black, 1);
style.Line.Width = 4;
style.Line.Color = Color.FromArgb(255, 198, 64);
style.Line.EndCap = System.Drawing.Drawing2D.LineCap.Round;
style.Line.StartCap = style.Line.EndCap;
style.Outline = (System.Drawing.Pen)style.Line.Clone();
style.Outline.Width += 1.5f;
style.Outline.Color = Color.Black;
style.EnableOutline = false;
style.Enabled = false;
return style;
case "CAMINO":
style.Outline = new Pen(Color.Black, 1);
style.Line.Width = 5;
style.Line.Color = Color.FromArgb(255, 198, 64);
style.Line.EndCap = System.Drawing.Drawing2D.LineCap.Round;
style.Line.StartCap = style.Line.EndCap;
style.Outline = (System.Drawing.Pen)style.Line.Clone();
style.Outline.Width += 1.5f;
style.Outline.Color = Color.Black;
style.EnableOutline = false;
return style;
case "AVENIDA":
style.Outline = new Pen(Color.Black, 1);
style.Line.Width = 7;
style.Line.Color = Color.FromArgb(255, 198, 64);
style.Line.EndCap = System.Drawing.Drawing2D.LineCap.Round;
style.Line.StartCap = style.Line.EndCap;
style.Outline = (System.Drawing.Pen)style.Line.Clone();
style.Outline.Width += 1.5f;
style.Outline.Color = Color.Black;
style.EnableOutline = false;
return style;
default:
return null; //Return null which will render the default style
}
}
}



Ajax.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Ajax.aspx.cs" Inherits="Ajax" %>
<%@ Register TagPrefix="smap" Namespace="AjaxMap" Assembly="AjaxMap" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Montevideo</title>
<link rel="stylesheet" href="styles/main.css">
<script type="text/javascript">
//Fired when query is selected and map is clicked
function MapClicked(event,obj)
{
var mousePos = SharpMap_GetRelativePosition(event.clientX,event.clientY,obj.container);
var pnt = SharpMap_PixelToMap(mousePos.x,mousePos.y,obj);
var field = document.getElementById('dataContents');
field.innerHTML = "You clicked map at: " + pnt.x + "," + pnt.y;
}
//Fired when a new map starts to load
function ViewChanging(obj)
{
var field = document.getElementById('dataContents');
field.innerHTML = "Loading...";
}
//Fired when a map has loaded
function ViewChanged(obj)
{
var field = document.getElementById('dataContents');
field.innerHTML = "Current map center: " + obj.GetCenter().x + "," + obj.GetCenter().y;
}
</script>
</head>
<body>
<div id="dataContents"></div>
<form id="Form1" runat="server" action="Ajax.aspx">
<div style="text-align:center;padding:1em;">
<h2>Montevideo</h2>
<div style="background:#f3f2e7;color:#000;width:74em;text-align:left;height:54em;border:solid 1px #000">
<div style="position:relative;margin-left:18em;width:52em;">
<div id="clickTools" class="toolbar" style="width:6.5em">

<img id="zoomIn" src="images/zoom_in.gif" onclick="ajaxMapObj.disableClickEvent(); ajaxMapObj.zoomAmount = 3; togToolbar(this.id,'clickTools');" onmouseover="if(this.className=='button')this.className='raised';" onmouseout="if(this.className=='raised')this.className='button';" class="pressed" />
<img id="zoomOut" src="images/zoom_out.gif" onclick="ajaxMapObj.disableClickEvent(); ajaxMapObj.zoomAmount = 0.33; togToolbar(this.id,'clickTools');" onmouseover="if(this.className=='button')this.className='raised';" onmouseout="if(this.className=='raised')this.className='button';" class="button" />
<img id="info" src="images/zoom_out.gif" onclick="ajaxMapObj.enableClickEvent(); togToolbar(this.id,'clickTools');" onmouseover="if(this.className=='button')this.className='raised';" onmouseout="if(this.className=='raised')this.className='button';" class="button" />
</div>
<div id="dragTools" class="toolbar" style="width:6.5em;left:10em;">
<img id="pan" src="images/pan.gif" onclick="javascript:SharpMap_ToolSelect(ajaxMapObj,this.id); togToolbar(this.id,'dragTools');" onmouseover="if(this.className=='button')this.className='raised';" onmouseout="if(this.className=='raised')this.className='button';" class="pressed" />
<img id="boxZoom" src="images/zoomselected.gif" onclick="javascript:SharpMapToolSelect(ajaxMapObj,this.id); togToolbar(this.id,'dragTools');" onmouseover="if(this.className=='button')this.className='raised';" onmouseout="if(this.className=='raised')this.className='button';" class="button" />
<img id="measure" src="images/measure.gif" onclick="javascript:SharpMap_ToolSelect(ajaxMapObj,this.id); togToolbar(this.id,'dragTools');" onmouseover="if(this.className=='button')this.className='raised';" onmouseout="if(this.className=='raised')this.className='button';" class="button" />
</div>
<div id="tempTools" class="toolbar" style="width:2em;left:17em;">
<img id="zoomExtents" src="images/zoomfull.gif" onclick="javascript:SharpMapZoomExtents(ajaxMapObj);" onmouseover="this.className='raised';" onmouseout="this.className='button';" onmouseup="this.className='raised';" onmousedown="this.className='pressed';" class="button" />
</div>
</div>
<div id="divLayers" style="margin:2.5em 1em 0em 1em;width:15em;position:absolute;background:#fff;border:solid 1px #000;padding:0.5em"><h4>Layers</h4>
<asp:Panel ID="pnlLayers" runat="server" Height="170px" Width="191px" />
</div>
<div style="position:absolute;width:52em;height:48em;margin-top:2em;margin-left:18em;border:1px solid #000">
<smap:AjaxMapControl width="52em" height="48em" id="ajaxMap" runat="server" OnClickEvent="MapClicked" OnViewChange="ViewChanged" OnViewChanging="ViewChanging"/>
</div>
</div>
</div>
</form>
<asp:label id="Message" runat="server"/>
</body>
</html>

Aug 13, 2007 at 4:59 PM
anybody?
there is no support for this great engine???

tks
Aug 13, 2007 at 7:14 PM
Sorry,

I cant help much as I have no experience with web oriented programming - only desktop (Yes... I am old fashioned)

Bill
Aug 13, 2007 at 7:30 PM
I planning to do somthing in desktop, but i want to do a web app, there is anybody in sharpmap that can givme support on this?
tks

PS: in a desktop app, i can click on map and get feature id, i can do something like a AVL?

tks
Developer
Aug 14, 2007 at 3:56 AM
Hi!
You can use radio button: zoompan and query! When check query you choose a point click and return to server. Server will process and return info of object that you click!