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

Eric Lemoine eric.c2c at gmail.com
Mon Nov 3 12:21:29 EST 2008


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 at hispeed.ch>:
>
> 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 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
>>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> 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 at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>


More information about the Users mailing list