google maps - Cant get polygons to display in primefaces -
ok using primefaces gmap in order display multiple polygons retrieved database, cant display on page, know coordinates being passed in correctly , code code similar showcase on primefaces http://www.primefaces.org/showcase/ui/data/gmap/polygons.xhtml stumped. here backing bean code
@postconstruct public void init() { try { class.forname("com.mysql.jdbc.driver"); dbconn = drivermanager.getconnection("jdbc:mysql://localhost:3306/demeter2.0", "root", "root"); } catch (sqlexception ex) { logger.getlogger(animal.class.getname()).log(level.severe, null, ex); } catch (classnotfoundexception ex) { logger.getlogger(animal.class.getname()).log(level.severe, null, ex); } preparedstatement ps = null; try { if (dbconn != null) { string sql = "select st_astext(markers) paddock idpaddock > 0"; ps = (preparedstatement) dbconn.preparestatement(sql); resultset rs = ps.executequery(); polygonmodel = new defaultmapmodel(); if (!rs.next()) { //return null; } else { rs.beforefirst(); polygon polygon = new polygon(); while (rs.next()) { string value = rs.getstring(1); string valuereal = value.replaceall("[^0-9 .,]+", ""); arraylist<string> mylist = new arraylist<string>(arrays.aslist(valuereal.split(","))); mylist.remove(mylist.size() - 1); (string coordstring : mylist) { string[] parts = coordstring.split(" "); string lats = parts[0]; string lngs = parts[1]; double lat = double.parsedouble(lats); double lng = double.parsedouble(lngs); latlng coord = new latlng(lat, lng); polygon.getpaths().add(coord); system.out.println(coord); } polygon.setstrokecolor("#ff9900"); polygon.setfillcolor("#ff9900"); polygon.setstrokeopacity(0.7); polygon.setfillopacity(0.7); polygonmodel.addoverlay(polygon); }//end while } } } catch (exception e) { system.out.println(e); } { try { ps.close(); dbconn.close(); } catch (exception e) { e.printstacktrace(); } } }
and jsf code
<h:form prependid="false"> <p:growl id="growl" life="3000" showdetail="true" /> <p:gmap id="gmap" center="36.890257,30.707417" zoom="13" type="hybrid" style="width:100%;height:400px" model="#{paddock.polygonmodel}"> <p:ajax event="overlayselect" listener="#{paddock.onpolygonselect}" update="growl" /> </p:gmap> </h:form>
Comments
Post a Comment