[OpenLayers-Users] some questions about popup extent & hyperlink

beppe beppenapo at gmail.com
Thu Dec 24 10:41:18 EST 2009


Il giorno lun, 21/12/2009 alle 10.32 -0500, users-request at openlayers.org
ha scritto:
> 
> On Mon, Dec 21, 2009 at 9:22 AM, beppe <beppenapo at gmail.com> wrote:
> > Hi,
> > I'm an italian OL's newbie, I come from a mapserver world and I'm
> very
> > happy to discover every day something about OpenLayers!
> > I've this code [1] and this mapfile [2], the geographic elements are
> > stored in a postgis table.
> > The code works but in the popup window, info are displayed like
> this:
> > "GetFeatureInfo results: Layer 'ut' Feature 78: paese = 'Coredo'
> > localita = 'S. Barbara'"
> > Obviously I don't want info about "GetFeatureInfo", "Layer" and
> > "Feature", but only about "paese" and "localita".
> > The info, then, are print like a "text string". I'd want print the
> info
> > in table style...but I don't know how !!!
> >
> 
> 
> You don't have a TEMPLATE in your mapfile... (it says TEMPLATE void).
> Define a TEMPLATE, and in that template (an HTML file), create your
> table like so
> 
> <TABLE>
> <TR><TD>Paese</TD><TD>[paese]</TR>
> <TR><TD>Localita</TD><TD>[localita]</TR>
> </TABLE>
> 
> 

Wow, thank you!!! Now works, but I've another problem...
...when I've many records from the spatial query, more than height of
popup, the sidebar does not appear.
I don't understand what is wrong in this code:

var createPopup = function(response) {
        var lonlat = map.getLonLatFromViewPortPx(this.xy);
        var popup = new OpenLayers.Popup.FramedCloud(
             "chicken",lonlat, null,response.responseText,null,true);
        popup.setBackgroundColor("#c1cdc1");
        popup.setOpacity(0.7);
	map.addPopup(popup, true);

	function onFeatureUnselect(event) {
        	var feature = event.feature;
        	if(feature.popup) {
                 map.removePopup(feature.popup);
                 feature.popup.destroy();
                 delete feature.popup;
                }
          }
}; 


> 
> > Question 2.
> > I'd like to have in popup an hyperlink to a page in wich print a map
> > with the extent of the selected feature, but:
> > 1. my feature are point
> > 2. I don't know how write the code!!!
> >
> > Any ideas, example or tutorial?
> > thanks

In the template file I've created an hyperlink in this way [1], but I
don't understand how to extract the right extent...
...maybe with a spatial query, something like:
#$id=$_GET['id'];
#$query=("select BOX(the_geom) from table where id = '$id';")
#$result = pg_query($connection, $query);
#$bounds = pg_result($result, $i, "BOX"); //I'm not sure that's works

and then create a variable in this way:
#var bounds = new OpenLayers.Bounds($bounds);

I don't know if is better to make a query with minx(), miny(), maxx(),
maxy(), instead of box()...

thanks a lot

-beppe-




[1]
#<table class="featureInfo">
#<tbody>
#  <tr>
#   <th>Paese</th>
#   <th> Località </th>
#  </tr>
#  <tr>
#   <td> 
#     <a
#href="http://localhost/vervoWeb/ammTerrViewPaese.php?id=[paese]"
#target="_blank">[paese]</a> 
#   </td>
#   <td> [localita] </td>
#  </tr>
#</tbody>
#</table> 




More information about the Users mailing list