Page 141 - python
P. 141

115




                        <img src="https://dsdi.msu.ac.th/images/msu-i.png" style="width:30px;height:30px;

                    margin-right:5px;float:left;"/>
                            <h1 style="font-family:'Athiti';font-size:10px"> {data.iloc[i]['name']}</h1>
                            """
                        iframe = folium.IFrame(html=html, width=140, height=40)

                        popup = folium.Popup(iframe, max_width=2650)
                        folium.Marker(
                            location=[data.iloc[i]['lat'], data.iloc[i]['lng']],

                            popup=popup,
                            icon=folium.DivIcon(html=f"""<div><svg xmlns="http://www.w3.org/2000/svg">
                    <image href="https://dsdi.msu.ac.th/images/msu-i.png" height="50" width="50"/>
                    </svg></div>""")
                        ).add_to(m)


                    M


                   ผลลัพธ


































                          ภาพประกอบที่ 10.14 แสดงการวาดตรามหาวิทยาลัยลงบนแผนที่และแสดงรายละเอียด
                          ตัวอยางที่ 10.5 เปนการวาดภาพ msu-i.png ลงบนแผนที่และเมื่อคลิ๊กที่ตรามหาวิทยาลัยจะ
                   แสดงรายละเอียด ตัวแปร data จะเปนชนิด DataFrame ประกอบดวย lat, lng และ name ตัวแปร m
                   เปนแผนที่และแสดงขอมูลที่พิกัด data['lat'][0] , data['lng'][0] โดยขยายแผนท zoom_start=13
                                                                                     ี่
   136   137   138   139   140   141   142   143   144   145   146