简体   繁体   中英

How to insert KML file into android mapview?

I have a bunch of kml files such as this one that I have been trying to insert into my app as a mapview overlay. I understand that I am supposed to parse this file in order to handle it. But I am not sure of the correct way to go about this. Suggestions are greatly appreciated.

clampToGround -77.91368,34.04805,-42.6 -77.91372,34.04801,-39.8 -77.91374,34.04796,-38.9 -77.91378,34.04792,-37 -77.91382,34.04788,-36.8 -77.91385,34.04783,-33.2 -77.91387,34.04779,-32.9 -77.91392,34.04775,-32.3 -77.91392,34.04769,-33.1 -77.91393,34.04763,-31.9 -77.91392,34.04758,-31.8 -77.91391,34.04752,-33.7 -77.91391,34.04747,-33.9 -77.91394,34.04742,-31.1 -77.91396,34.04737,-29.5 -77.91399,34.04733,-30.3 -77.91404,34.04731,-31.4 -77.9141,34.04731,-31.1 -77.91415,34.04734,-39.5 -77.9142,34.04736,-42.2 -77.91426,34.04736,-43.3 -77.91431,34.04734,-42.6 -77.91436,34.04731,-36.3 -77.91441,34.04728,-38.4 -77.91446,34.04727,-39.1 -77.91452,34.04726,-36.9 -77.91453,34.04721,-36.4 -77.91449,34.04717,-34.8 -77.91445,34.04714,-34.2 -77.91442,34.04709,-33.1 -77.91441,34.04704,-33 -77.91439,34.04699,-31.3 -77.9144,34.04694,-31.3 -77.91438,34.04689,-33.8 -77.91436,34.04683,-32.9 -77.91436,34.04677,-31.2 -77.91432,34.04672,-30.2 -77.91429,34.04668,-29.9 -77.91428,34.04663,-29.2 -77.91428,34.04658 ,-31.4 -77.91425,34.04654,-31.4 -77.91424,34.04649,-32.5 -77.91421,34.04643,-31.9 -77.91418,34.04639,-31.5 -77.91415,34.04634,-31.2 -77.9141,34.0463,-30.9 -77.91404,34.04629,-30.3 -77.91398,34.04631,-31 -77.91391,34.04634,-33.3 -77.91387,34.04637,-34.3 -77.91381,34.04639,-35.2 -77.91375,34.04638,-33.2 -77.91368,34.04637,-32.3 -77.91363,34.04636,-31.9 -77.91358,34.04635,-32.2 -77.91351,34.04635,-32.2 -77.91345,34.04637,-31.4 -77.91338,34.04635,-30.3 -77.91332,34.04634,-31.3 -77.91326,34.04635,-31.9 -77.91321,34.0464,-33.8 -77.91318,34.04644,-33.7 -77.91315,34.04648,-35.5 -77.9131,34.04653,-32.5 -77.91306,34.04656,-33.2 -77.91302,34.04661,-32.8 -77.913,34.04666,-34.5 -77.91297,34.04671,-35.9 -77.91296,34.04676,-34.6 -77.91295,34.04681,-34 -77.91295,34.04687,-36.1 -77.91297,34.04692,-36.5 -77.91298,34.04696,-37.5 -77.913,34.04701,-39 -77.91302,34.04705,-40.1 -77.91304,34.0471,-38 -77.91306,34.04714,-36.5 -77.9131,34.04718,-36.6 -77.91312,34.04723,-35.6 -77.91314,34.04729,-35.2 -77.91313,3 4.04734,-33.7 -77.9131,34.04738,-32.3 -77.9131,34.04743,-30.7 -77.9131,34.04749,-28.1 -77.91314,34.04754,-26.5 -77.91318,34.04759,-26.5 -77.9132,34.04763,-27.6 -77.91323,34.04768,-29.3 -77.91324,34.04775,-31 1 FF0000E6 4 Tracks 0 1 GPS Visualizer]]> 1 1

It seems that the Android framework provides no helper to handle such case (ie. automatically drawing a KML file on a MapView). So you'll have to do it manually.

To draw a path on a mapview, you can refer to the following implementation provided in another stackoverflow question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM