[Chameleon] Highlight search result in map
Julien-Samuel Lacroix
jlacroix at mapgears.com
Fri Mar 28 10:24:59 EDT 2008
Hi,
If you want to use the code in bug 1068, simply add the CWCRunQuery
function in the chameleon/htdocs/widgets/js/cwcjsapi.js file and add the
following at the bottom of the same file:
CWCApplication.prototype.RunQuery = CWCRunQuery;
Then add the big if() statement in chameleon/htdocs/UpdateMap.php around
line 1050, just before the following line:
$_SESSION["gszCurrentState"] = $oMapSession->saveState();
This will allow you to apply a filter like this:
goCWCJSAPI.RunQuery(layername, "field = value");
However I'm not sure I'll be able to help you more than that.
If you want to make your existing code work, I tried to add your
function in the sample_basic_jsapi.html and it worked with few modification.
I added this just before the myOnLoad function
function testzoom(x,y,x2,y2)
{
goCWCJSAPI.oMap.SetExtents(x,y,x2,y2)
}
function testselect(nX ,nY,nX2 ,nY2)
{
var queryCoords = nX + "," + nY + ";" + nX2 + "," + nY2;
var img = CWCDHTML_GetImage( 'MapLayerDivImg' );
var str_gMap=gMapDHTMLURL .split("&UniqId=");
img.src = str_gMap[0] + "&run_query=1&gszQueryCoords=" + queryCoords ;
window.status = img.src;
goCWCJSAPI.oMap.Refresh();
}
And this at the very beggining of the <form>:
<br><br>
<input type="button" name="ttt" value="Test zoom"
onclick="testzoom(1718420.8896, 39539.518383, 1884136.658,163826.344683)">
<input type="button" name="ttt" value="Test query"
onclick="testselect(279,237,299,257)">
When I click the "Test select" button it highlight Quebec city and when
I click "Test zoom" it zoom on it and keep it selected.
Hope that helps
Julien
Federica De Martin wrote:
> Hi, always me, Federica. Thank you Julien for the fast answer.
> The Highlight works fine for me in the query widget, also between zoom.
> My problem is when I make a search with some php code and then I use my
> funciton "AddSelection" and try to zoom setting the New Extents with
> goCWCJSAPI.oMap.SetExtents(x,y,x2,y2) function. In my opinion the
> features don't highlight because the second function is called before
> the first is over, but I don't know how to correct it.
> Finally I prefer to make something via php like this one
> http://lists.maptools.org/pipermail/chameleon-dev/2005-May/003973.html that
> is more sure, but I don't know where to put the php code to make it
> work. I also tried to put it in the function ParseUrl (that I have
> added) in the Update.widget.php but it doesn't work,
> any suggestion?
>
> Thanks.
>
> Federica
>
> 2008/3/27, Julien-Samuel Lacroix <jlacroix at mapgears.com
> <mailto:jlacroix at mapgears.com>>:
>
> Hi,
>
> Do the Chameleon samples work?
> If they work, you can try to go in sample_basic.phtml and
> sample-basic_jsapi.phtml and add the following parameter to the Query
> widget:
> HighlightResults="true"
>
> This should highlight the result of your query and keep it highlighted
> between zoom.
>
> Is that what you were looking for?
>
> Julien
>
> PS: If sample_basic.phtml works and not sample_basic_jsapi.phtml you may
> need to install Chameleon 2.6rc1.
>
>
> Federica De Martin wrote:
> >
> > Hi,
> > I write again and I hope somebody is going to answer me...
> > Now I use this function but it works only with Point layer and if
> I try
> > to zoom after or before it doesn't work...
> > function addSelection(nX ,nY,nX2 ,nY2){
> > var queryCoords = nX + "," + nY + "," + nX2 + "," + nY2;
> > var img = CWCDHTML_GetImage( 'MapLayerDivImg' );
> > var str_gMap=gMapDHTMLURL .split("&UniqId=");
> > mg.src = str_gMap[0] + "&run_query=1&gszQueryCoords=" +
> queryCoords ;
> > window.status = img.src;
> > goCWCJSAPI.oMap.Refresh();
> > }
> >
> > I also have tried with this function that create a new layer with a
> > point using the existing jsapi function but it doesen't work for me.
> > function AddSel(nX ,nY,szName){
> > goCWCJSAPI.oMap.CreateNewLayer("tmp_"+szName, "POINT", 1);
> > goCWCJSAPI.RefreshMap();
> > // var layer_orig=goCWCJSAPI.oMap.GetLayerByName(szName);
> > var layer_sel=goCWCJSAPI.oMap.GetLayerByName('tmp_'+szName);
> > // layer_sel=layer_orig;
> > var p=new CWCPoint();
> > p.x=nX ;
> > p.y=nY;
> > p.symbol=0;
> > p.symbol_size=40;
> > p.symbol_color="255,0,100";
> > p.symbol_outlinecolour = "255,255,255";
> > //layer_sel.SetStatus()="ON";
> > goCWCJSAPI.oMap.GetLayerByName('tmp_'+szName).SetStatus("ON");
> > layer_sel.SetProjection="epsg:26591";
> > layer_sel.Promote();
> > goCWCJSAPI.oMap.AddPoint("tmp_"+szName, p);
> > }
> >
> > I think that the right way to approch to the problem is this
>
> >
> <http://lists.maptools.org/pipermail/chameleon-dev/2005-May/003973.html>
> >
> <http://lists.maptools.org/pipermail/chameleon-dev/2005-May/003973.html>but
> > I am not able to make it work. I wait for some pieces of advice!
> > Tanks Federica.
> >
> > Hi everybody,
> > I'm working on how to highlight elements in map. I need a
> function to do
> >
> > this from a popup and from the same form of the map. I find out this
> >
> http://lists.maptools.org/pipermail/chameleon-dev/2005-May/003973.html
> but
> >
> > I'm not able to make it work.
> > I don't know where to put the php code, I also tried to use ajax
> but I get
> > an error in php file on the final istruction:
> >
> > $_SESSION["gszCurrentState"] = $oMapSession->saveState();
> >
> > ... saveState() on a non-object ...
> >
> > maybe because I don't include or call any other chameleon file
> (but if I try
> > I get many errors... maybe I include the wrong files...).
> > Can you help me to make that example work or can you give me an
> idea on how
> >
> > to proceed to solve this problem?
> >
> > Thank you,
> > Federica
> >
> >
>
> >
> ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Chameleon mailing list
> > Chameleon at lists.maptools.org <mailto:Chameleon at lists.maptools.org>
> > http://lists.maptools.org/mailman/listinfo/chameleon
>
>
> --
> Julien-Samuel Lacroix
> Mapgears
> http://www.mapgears.com/
>
>
--
Julien-Samuel Lacroix
Mapgears
http://www.mapgears.com/
More information about the Chameleon
mailing list