Ko'proq

KML ma'lumotlarini qanday kiritish mumkin, lekin o'zgaruvchidan - urldan emas?

KML ma'lumotlarini qanday kiritish mumkin, lekin o'zgaruvchidan - urldan emas?


Menda KML -ni urldan oladigan ish xaritasi bor, lekin hozir uning o'rniga mahalliy o'zgaruvchidan KML ma'lumotlarini olishim kerak. Buni qo'llab -quvvatlayaptimi va agar shunday bo'lsa, sintaksis nima. Api va turli saytlarni qidirdim, lekin bu haqda hech narsa topa olmadim. Rahmat!

[Qo'shimcha]

map = yangi OpenLayers.Map ({div: "map", qatlamlar: [yangi OpenLayers.Layer.WMS ("WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0", {qatlamlar: ") asosiy "}), yangi OpenLayers.Layer.Vector (" KML ", {strategiyalar: [yangi OpenLayers.Strategy.Fixed ()], protokol: yangi OpenLayers.Protocol.HTTP ({url:" kml_large.kml ", format: yangi OpenLayers.Format.KML ({extractStyles: true, extractAttributes: true, maxDepth: 2})})})]], markaz: yangi OpenLayers.LonLat (-81, 28), kattalashtirish: 7});

OpenLayers.Format.KML.read ()

Bu KML satridan OpenLayers.Feature.Vector xususiyatlarini yaratadi.

Sizning ehtiyojlaringizga mos keladigan proektsion ma'lumotni o'zgartirishingiz kerak bo'lishi mumkin:

GetFeaturesFromKMLString (strKML) funktsiyasi {var format = new OpenLayers.Format.KML ({'internalProjection': myMapObject.baseLayer.projection, 'externalProjection': new OpenLayers.Projection ("EPSG: 4326")}); format.read (strKML) qaytish; };

Keyin siz shunday bir narsa qilishingiz mumkin:

myVectorLayer.addFeatures (GetFeaturesFromKMLString (myKMLString));

Videoni tomosha qiling: KML to GPX File Conversion Super Easy!