[OpenLayers-Users] Mouseover should show attributes from a database

Jerome Freyre jerome.freyre at hispeed.ch
Mon Nov 3 06:04:51 EST 2008


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.




More information about the Users mailing list