Mouseover should show attributes from a database

8 messages Options Options
Embed this Post
Permalink
Rahn Hanno (rahn)

Mouseover should show attributes from a database

Reply Threaded MoreMore options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)

Hello list,

 

I have a problem and perhaps somebody can help me. I want to realise a mouseover event like it is used in many of the examples. If you move the mouse over the map the coordinates will be shown inside.

 

Now, I will use this, but instead of the coordinates I will show some attributes from a database. My map shows different districts. If I move the mouse over one district, the name of this should be shown. The name ist inside a database table.

I dont know if it is possible and I dont have an idea how I can realise it. Perhaps somebody have already realise something about this and can help me a little bit.

 

A lot of thanks for all your fantastic help.

 

Greetings

Hanno Rahn

 

 

------------------------------------------

Hanno Rahn, Dipl.-Ing. (FH) Geoinformatik

ZHAW Zürcher Hochschule für Angewandte Wissenschaften Umwelt und Natürliche Ressourcen

Fachstelle Geoinformatik

Grüental, Postfach CH-8820 Wädenswil

Tel +41 (0)58 934 5592

Fax +41 (0)58 934 5580

hanno.rahn@...

 

 


_______________________________________________
Users mailing list
Users@...
http://openlayers.org/mailman/listinfo/users
Jerome Freyre

Re: Mouseover should show attributes from a database

Reply Threaded MoreMore options
Print post
Permalink
Hi,

I don't know how you add the features on the map but in my case, i add my features with a geojson.
This geojson contains properties  with properties that contains my DB object id:

{"type": "FeatureCollection", "features": [{"type": "Feature","id": "60347", "properties": {  "myObjectID" : "123"},"geometry": {"type": "Point","coordinates": [-4.0281, 5.3411]} }]}

When my mouse is over the feature, I get the id like that :
var id = feature.attributes['myObjectID']

then i made an ajax request (in my case with jquery) that give me db informations of the object.

        var html = $.ajax({
                async:false,
                //sur la page
            url: "../include/getObjectInfos.php?id="+id,
        }).responseText;

Finally, I add a popup that contains the ajax response.

    // create popup located in the bottom right of the map
    var bounds = this.layer.map.getExtent();

       
        // creation of the popup
        var popup = new OpenLayers.Popup.FramedCloud("chicken",ll, size,  html,  null, true,  onPopupClose);
    map.addPopup(popup);


Hope it will be helpfull...

Sincerly,
Jérome

Eric Lemoine

Re: Mouseover should show attributes from a database

Reply Threaded MoreMore options
Print post
Permalink
Jerome, you could also have the GeoJSON include all the information
you need, thereby avoiding an extra client/server roundtrip, couldn't
you? Eric

2008/11/3, Jerome Freyre <jerome.freyre@...>:

>
> Hi,
>
> I don't know how you add the features on the map but in my case, i add my
> features with a geojson.
> This geojson contains properties  with properties that contains my DB object
> id:
>
> {"type": "FeatureCollection", "features": [{"type": "Feature","id": "60347",
> "properties": {  "myObjectID" : "123"},"geometry": {"type":
> "Point","coordinates": [-4.0281, 5.3411]} }]}
>
> When my mouse is over the feature, I get the id like that :
> var id = feature.attributes['myObjectID']
>
> then i made an ajax request (in my case with jquery) that give me db
> informations of the object.
>
> var html = $.ajax({
> async:false,
> //sur la page
>   url: "../include/getObjectInfos.php?id="+id,
> }).responseText;
>
> Finally, I add a popup that contains the ajax response.
>
>     // create popup located in the bottom right of the map
>     var bounds = this.layer.map.getExtent();
>
>
> // creation of the popup
> var popup = new OpenLayers.Popup.FramedCloud("chicken",ll, size,  html,
> null, true,  onPopupClose);
>     map.addPopup(popup);
>
>
> Hope it will be helpfull...
>
> Sincerly,
> Jérome
>
>
> --
> View this message in context:
> http://www.nabble.com/Mouseover-should-show-attributes-from-a-database-tp20299453p20300784.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Users mailing list
> Users@...
> http://openlayers.org/mailman/listinfo/users
>
_______________________________________________
Users mailing list
Users@...
http://openlayers.org/mailman/listinfo/users
Jerome Freyre

Re: Mouseover should show attributes from a database

Reply Threaded MoreMore options
Print post
Permalink
Of course it is easier,

But it depends on the numbers of informations you have to load and the number of features your are loading.

In my case, there is a lot of informations to load for a lot of points...

So I prefer to load only the id and then load only the information that are really useful for the users of my application.

Sincerly,
Jérome

Eric Lemoine-3 wrote:
Jerome, you could also have the GeoJSON include all the information
you need, thereby avoiding an extra client/server roundtrip, couldn't
you? Eric

2008/11/3, Jerome Freyre <jerome.freyre@hispeed.ch>:
>
> Hi,
>
> I don't know how you add the features on the map but in my case, i add my
> features with a geojson.
> This geojson contains properties  with properties that contains my DB object
> id:
>
> {"type": "FeatureCollection", "features": [{"type": "Feature","id": "60347",
> "properties": {  "myObjectID" : "123"},"geometry": {"type":
> "Point","coordinates": [-4.0281, 5.3411]} }]}
>
> When my mouse is over the feature, I get the id like that :
> var id = feature.attributes['myObjectID']
>
> then i made an ajax request (in my case with jquery) that give me db
> informations of the object.
>
> var html = $.ajax({
> async:false,
> //sur la page
>   url: "../include/getObjectInfos.php?id="+id,
> }).responseText;
>
> Finally, I add a popup that contains the ajax response.
>
>     // create popup located in the bottom right of the map
>     var bounds = this.layer.map.getExtent();
>
>
> // creation of the popup
> var popup = new OpenLayers.Popup.FramedCloud("chicken",ll, size,  html,
> null, true,  onPopupClose);
>     map.addPopup(popup);
>
>
> Hope it will be helpfull...
>
> Sincerly,
> Jérome
>
>
> --
> View this message in context:
> http://www.nabble.com/Mouseover-should-show-attributes-from-a-database-tp20299453p20300784.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Users mailing list
> Users@openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
_______________________________________________
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users
Eric Lemoine

Re: Mouseover should show attributes from a database

Reply Threaded MoreMore options
Print post
Permalink
It makes sense. I just wanted that Rhan didn't get the impression that
two requests were necessary. Thanks. Eric

2008/11/3, Jerome Freyre <jerome.freyre@...>:

>
> Of course it is easier,
>
> But it depends on the numbers of informations you have to load and the
> number of features your are loading.
>
> In my case, there is a lot of informations to load for a lot of points...
>
> So I prefer to load only the id and then load only the information that are
> really useful for the users of my application.
>
> Sincerly,
> Jérome
>
>
> Eric Lemoine-3 wrote:
>>
>> Jerome, you could also have the GeoJSON include all the information
>> you need, thereby avoiding an extra client/server roundtrip, couldn't
>> you? Eric
>>
>> 2008/11/3, Jerome Freyre <jerome.freyre@...>:
>>>
>>> Hi,
>>>
>>> I don't know how you add the features on the map but in my case, i add my
>>> features with a geojson.
>>> This geojson contains properties  with properties that contains my DB
>>> object
>>> id:
>>>
>>> {"type": "FeatureCollection", "features": [{"type": "Feature","id":
>>> "60347",
>>> "properties": {  "myObjectID" : "123"},"geometry": {"type":
>>> "Point","coordinates": [-4.0281, 5.3411]} }]}
>>>
>>> When my mouse is over the feature, I get the id like that :
>>> var id = feature.attributes['myObjectID']
>>>
>>> then i made an ajax request (in my case with jquery) that give me db
>>> informations of the object.
>>>
>>> var html = $.ajax({
>>> async:false,
>>> //sur la page
>>>   url: "../include/getObjectInfos.php?id="+id,
>>> }).responseText;
>>>
>>> Finally, I add a popup that contains the ajax response.
>>>
>>>     // create popup located in the bottom right of the map
>>>     var bounds = this.layer.map.getExtent();
>>>
>>>
>>> // creation of the popup
>>> var popup = new OpenLayers.Popup.FramedCloud("chicken",ll, size,  html,
>>> null, true,  onPopupClose);
>>>     map.addPopup(popup);
>>>
>>>
>>> Hope it will be helpfull...
>>>
>>> Sincerly,
>>> Jérome
>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Mouseover-should-show-attributes-from-a-database-tp20299453p20300784.html
>>> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users@...
>>> http://openlayers.org/mailman/listinfo/users
>>>
>> _______________________________________________
>> Users mailing list
>> Users@...
>> http://openlayers.org/mailman/listinfo/users
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/Mouseover-should-show-attributes-from-a-database-tp20299453p20306669.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Users mailing list
> Users@...
> http://openlayers.org/mailman/listinfo/users
>
_______________________________________________
Users mailing list
Users@...
http://openlayers.org/mailman/listinfo/users
Eric Lemoine

Re: Mouseover should show attributes from a database

Reply Threaded MoreMore options
Print post
Permalink
In reply to this post by Rahn Hanno (rahn)
Hi Rhan. What type of layer do you use to display your data on the
map? WMS? WFS? Something else? Eric

2008/11/3, Rahn Hanno (rahn) <rahn@...>:

> Hello list,
>
>
>
> I have a problem and perhaps somebody can help me. I want to realise a
> mouseover event like it is used in many of the examples. If you move the
> mouse over the map the coordinates will be shown inside.
>
>
>
> Now, I will use this, but instead of the coordinates I will show some
> attributes from a database. My map shows different districts. If I move the
> mouse over one district, the name of this should be shown. The name ist
> inside a database table.
>
> I dont know if it is possible and I dont have an idea how I can realise it.
> Perhaps somebody have already realise something about this and can help me a
> little bit.
>
>
>
> A lot of thanks for all your fantastic help.
>
>
>
> Greetings
>
> Hanno Rahn
>
>
>
>
>
> ------------------------------------------
>
> Hanno Rahn, Dipl.-Ing. (FH) Geoinformatik
>
> ZHAW Zürcher Hochschule für Angewandte Wissenschaften Umwelt und Natürliche
> Ressourcen
>
> Fachstelle Geoinformatik
>
> Grüental, Postfach CH-8820 Wädenswil
>
> Tel +41 (0)58 934 5592
>
> Fax +41 (0)58 934 5580
>
> hanno.rahn@...
>
>
>
>
>
>
_______________________________________________
Users mailing list
Users@...
http://openlayers.org/mailman/listinfo/users
Arnd Wippermann

Re: Mouseover should show attributes from a database

Reply Threaded MoreMore options
Print post
Permalink
In reply to this post by Rahn Hanno (rahn)
Some javascript/style in this post has been disabled (why?)
for non feature layers, ie WMS layers, there is an OpenLayers example
 
Arnd Wippermann


Von: users-bounces@... [mailto:users-bounces@...] Im Auftrag von Rahn Hanno (rahn)
Gesendet: Montag, 3. November 2008 10:22
An: users@...
Betreff: [OpenLayers-Users] Mouseover should show attributes from a database

Hello list,

 

I have a problem and perhaps somebody can help me. I want to realise a mouseover event like it is used in many of the examples. If you move the mouse over the map the coordinates will be shown inside.

 

Now, I will use this, but instead of the coordinates I will show some attributes from a database. My map shows different districts. If I move the mouse over one district, the name of this should be shown. The name ist inside a database table.

I dont know if it is possible and I dont have an idea how I can realise it. Perhaps somebody have already realise something about this and can help me a little bit.

 

A lot of thanks for all your fantastic help.

 

Greetings

Hanno Rahn

 

 

------------------------------------------

Hanno Rahn, Dipl.-Ing. (FH) Geoinformatik

ZHAW Zürcher Hochschule für Angewandte Wissenschaften Umwelt und Natürliche Ressourcen

Fachstelle Geoinformatik

Grüental, Postfach CH-8820 Wädenswil

Tel +41 (0)58 934 5592

Fax +41 (0)58 934 5580

hanno.rahn@...

 

 


_______________________________________________
Users mailing list
Users@...
http://openlayers.org/mailman/listinfo/users
Rahn Hanno (rahn)

Re: Mouseover should show attributes from a database

Reply Threaded MoreMore options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)

Hello list,

 

thank you for the lot of answers, I will try to solve my problem. I use a WMS for displying my data. The problem ist that I must have a dynamic style, because I show timelines from different geographic indikators. The map will be green in 1990 and red in the year 2000 for example. I realise it with a php file which generates a SLD and the SLD parameter.

After this I will show the name of the district like the coordinates using the mouseover.

 

I hope you could understand it a little bit better what I try to realise now. For your help I will tahnk you a lot.

 

Greetings

Hanno Rahn

 

 

------------------------------------------

Hanno Rahn, Dipl.-Ing. (FH) Geoinformatik

ZHAW Zürcher Hochschule für Angewandte Wissenschaften Umwelt und Natürliche Ressourcen

Fachstelle Geoinformatik

Grüental, Postfach CH-8820 Wädenswil

Tel +41 (0)58 934 5592

Fax +41 (0)58 934 5580

hanno.rahn@...

 

 


Von: arnd.wippermann@... [mailto:arnd.wippermann@...]
Gesendet: Montag, 3. November 2008 18:31
An: Rahn Hanno (rahn)
Cc: users@...
Betreff: AW: [OpenLayers-Users] Mouseover should show attributes from a database

 

for non feature layers, ie WMS layers, there is an OpenLayers example

http://openlayers.org/dev/examples/hover-handler.html

 

Arnd Wippermann

 


Von: users-bounces@... [mailto:users-bounces@...] Im Auftrag von Rahn Hanno (rahn)
Gesendet: Montag, 3. November 2008 10:22
An: users@...
Betreff: [OpenLayers-Users] Mouseover should show attributes from a database

Hello list,

 

I have a problem and perhaps somebody can help me. I want to realise a mouseover event like it is used in many of the examples. If you move the mouse over the map the coordinates will be shown inside.

 

Now, I will use this, but instead of the coordinates I will show some attributes from a database. My map shows different districts. If I move the mouse over one district, the name of this should be shown. The name ist inside a database table.

I dont know if it is possible and I dont have an idea how I can realise it. Perhaps somebody have already realise something about this and can help me a little bit.

 

A lot of thanks for all your fantastic help.

 

Greetings

Hanno Rahn

 

 

------------------------------------------

Hanno Rahn, Dipl.-Ing. (FH) Geoinformatik

ZHAW Zürcher Hochschule für Angewandte Wissenschaften Umwelt und Natürliche Ressourcen

Fachstelle Geoinformatik

Grüental, Postfach CH-8820 Wädenswil

Tel +41 (0)58 934 5592

Fax +41 (0)58 934 5580

hanno.rahn@...

 

 


_______________________________________________
Users mailing list
Users@...
http://openlayers.org/mailman/listinfo/users