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

Eric Lemoine eric.c2c at gmail.com
Mon Nov 3 11:51:44 EST 2008


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 at 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 at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>


More information about the Users mailing list