Re: [web2py] Re: show map on grid view
thanks manuele, i've tried that but the result is same (no error occured but the result is not expected, google maps show almost take the sqlform grid view entirely). e.g. def check_point_admin(row): scr0 = SCRIPT(""" function initMap() { var mapDiv = document.getElementById(%s); document.getElementById(%s).setAttribute("style","width:10px"); document.getElementById(%s).setAttribute("style","height:10px"); document.getElementById(%s).style.width='10px'; document.getElementById(%s).style.height='10px'; var latlon = new google.maps.LatLng( %s, %s ); var mapOptions = { center: latlon, zoom: 15 }; var map = new google.maps.Map(mapDiv, mapOptions); var marker = new google.maps.Marker({ position: latlon, map: map }); } """ % (row.id, row.id, row.id, row.id, row.id, row.lat, row.lon) ) scr1 = SCRIPT( _src="https://maps.googleapis.com/maps/api/js?callback=initMap; ) #return DIV(_id = row.id, _style="width: 1%; height: 1%"), scr0, scr1 #return DIV(DIV(_id = row.id, _style="width: 1%; height: 1%"), scr0, scr1) return SPAN(DIV(_id = row.id, _style="width: 1%; height: 1%"), scr0, scr1) def report_check_point(): table = db.check_point links = [dict(header = T('Image'), body = lambda row: check_point_admin(row) ) ] grid = SQLFORM.smartgrid(table, links = links) return locals() tried both suggestions (you and massimo) got the same result, i even set the style width & height on the SCRIPT(), but got the same result thanks and best regards, stifan -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: show map on grid view
Il 05/06/16 00:06, 黄祥 ha scritto: > what i want to achieve is showing a map in each row of > SQLFORM.smartgrid links (looks like in the attached file) > thanks massimo, tried your suggestion, but got the same result. any > idea or suggestion to achieve it in web2py? > Hi Stifan, what about introducing some code like that in your SQLFORM.grid object... assuming your coordinates are stored in columns lat and lng of your table... scriptbody = """ function initMap() { var myLatLng = {lat: %(lat)s, lng: %(lng)s}; var map = new google.maps.Map(document.getElementById('map_%(id)s'), { zoom: 4, center: myLatLng }); var marker = new google.maps.Marker({ position: myLatLng, map: map, title: 'Hello World!' }); } """ % r grid = SQLFORM.grid( links = [dict(header="Map", body=lambda r: SPAN(DIV(_id="map_%(id)s" % r, _style="width: 100%; height: 100%"), SCRIPT(scriptbody, _type="text/javascript")))], ) some useful reference documentation: 1) http://www.web2py.com/books/default/chapter/29/07/forms-and-validators#Virtual-fields-in-SQLFORMgrid-and-smartgrid 2) https://developers.google.com/maps/documentation/javascript/examples/marker-simple Cheers Manuele > thanks and best regards, > stifan -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: show map on grid view
I cannot see/download screen shots, is it just my problem? Dne neděle 5. června 2016 0:06:15 UTC+2 黄祥 napsal(a): > > what i want to achieve is showing a map in each row of SQLFORM.smartgrid > links (looks like in the attached file) > thanks massimo, tried your suggestion, but got the same result. any idea > or suggestion to achieve it in web2py? > > thanks and best regards, > stifan > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: show map on grid view
Please explain us better what you want to do. Form you code looks like you want one map (not one point) for each row in the grid. This is going to be awfully small. Anyway, Try change this: return DIV(_id = row.id), scr0, scr1 into return DIV(DIV(_id = row.id), scr0, scr1) On Tuesday, 31 May 2016 08:02:26 UTC-5, 黄祥 wrote: > > testing to put it on the SQLFORM.grid links no error occured but the > result is not expected > e.g. > *controllers* > def check_point_admin(row): > scr0 = SCRIPT(""" > function initMap() { > var mapDiv = document.getElementById(%s); > > var latlon = new google.maps.LatLng( %s, %s ); > > var mapOptions = { > center: latlon, > zoom: 15 > }; > > var map = new google.maps.Map(mapDiv, mapOptions); > > var marker = new google.maps.Marker({ >position: latlon, >map: map > }); > } > """ % (row.id, row.lat, row.lon) > ) > > scr1 = SCRIPT( > _src="https://maps.googleapis.com/maps/api/js?callback=initMap; > ) > > return DIV(_id = row.id), scr0, scr1 > > def report_check_point(): > table = db.check_point > links = [dict(header = T('Image'), > body = lambda row: check_point_admin(row) > ) > ] > grid = SQLFORM.smartgrid(table, links = links) > return locals() > > any idea how to achieve it on web2py? > > thanks and best regards, > stifan > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: show map on grid view
testing to put it on the SQLFORM.grid links no error occured but the result is not expected e.g. *controllers* def check_point_admin(row): scr0 = SCRIPT(""" function initMap() { var mapDiv = document.getElementById(%s); var latlon = new google.maps.LatLng( %s, %s ); var mapOptions = { center: latlon, zoom: 15 }; var map = new google.maps.Map(mapDiv, mapOptions); var marker = new google.maps.Marker({ position: latlon, map: map }); } """ % (row.id, row.lat, row.lon) ) scr1 = SCRIPT( _src="https://maps.googleapis.com/maps/api/js?callback=initMap; ) return DIV(_id = row.id), scr0, scr1 def report_check_point(): table = db.check_point links = [dict(header = T('Image'), body = lambda row: check_point_admin(row) ) ] grid = SQLFORM.smartgrid(table, links = links) return locals() any idea how to achieve it on web2py? thanks and best regards, stifan -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.