Category Archives: Google Maps

Google Maps , Flex and JSP

The sample application provided on this post explains a simple way of using Google Maps API on Flex to mark some places and add a discription to the Marker.

Google Maps & JSP

Google Maps API Sample

To use the jsp, we first define a HttpService objet in our MXML  with a result and an error handler:

<mx:HTTPService id="saveCoordSrv"
url="http://[server:port]/googleMapToMySql/insert.jsp"
result="handleListResult(event)"
fault="errorFault(event)"/>

then we need a model for our entity to manage , I preferred to make it binded to input fields(inAdress,inLat,…):

<!-- The marker model -->
<mx:Model id="coordToSave">
	<root>
            <adress>{inAdress.text}</adress>
            <lat>{inLat.text}</lat>
            <lng>{inLng.text}</lng>
            <commentaire>{inComment.text}</commentaire>
	</root>
</mx:Model>

and then just make the call :

saveCoordSrv.send(coordToSave);

In the insert JSP, we just collect sent params using request.getParameter(“param_name”) :

String adr = request.getParameter("adress");
String lat = request.getParameter("lat");

and then manipulate your database driver to make an insert/delete/update query. In this sample i used MySql.

Next time we’ll be discussing google maps events use.  If you need any explanation about the code, please do not hesitate 🙂

Send me an email (salemba@live.fr) to get Source Code(I uploaded it in many providers but links are dead).