【问题标题】:How to Use Variable as location url?如何使用变量作为位置 url?
【发布时间】:2017-08-29 11:20:35
【问题描述】:

大家好,如何将文件 URL 的位置替换为变量?

NgMap.getMap().then(function (map) {
                    $scope.map = map;
                    var myParser = new geoXML3.parser({ map: map });
                    myParser.parse('cta.kml');
                });

myParser.parse 只接受 url 但不接受变量?这可能吗?

    var result = "<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<!-- Data derived from:
       Ed Knittel - || tastypopsicle.com
       Feel free to use this file for your own purposes.
       Just leave the comments and credits when doing so.
-->
  <Document>
    <name>Chicago Transit Map</name>
    <description>Chicago Transit Authority train lines</description>

    <Style id="blueLine">
      <LineStyle>
        <color>ffff0000</color>
        <width>4</width>
      </LineStyle>
    </Style>
    <Style id="redLine">
      <LineStyle>
        <color>ff0000ff</color>" ........ so on...

如何替换 myParser.parse(result)????

我正在使用 ngMap。

【问题讨论】:

    标签: javascript angularjs kml filereader


    【解决方案1】:

    myParser.parse 只接受 url 但不接受变量?这可能吗?

    没有。

    NgMap.getMap().then(function (map) {
        $scope.map = map;
        var myParser = new geoXML3.parser({ map: map });
        var myUrl = 'cta.kml'; 
        myParser.parse(myUrl);
    });
    

    应该可以。

    但是:不太确定,如果这是您的问题?

    【讨论】:

    • myParser.parse(result) 怎么办?因为“结果”是可变的
    猜你喜欢
    • 1970-01-01
    • 2022-07-20
    • 1970-01-01
    • 1970-01-01
    • 2018-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-16
    相关资源
    最近更新 更多