如何在 drupal 7 中添加 KMZ 文件? [英] How to add KMZ file in drupal 7?

查看:36
本文介绍了如何在 drupal 7 中添加 KMZ 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 KMZ 文件,但我不知道如何从 drupal 显示它.所以,我研究并找到了这些代码.

I have got KMZ file and I don't know how to show it from drupal. So, I research and found those codes.

function CoverageMap() {

  var map = new google.maps.Map(document.getElementById('coverageMap'), {
    zoom: 15,
    center: {lat: 16.800915763233845, lng: 96.1567211141123}
   });

   var kmzLayer = new google.maps.KmlLayer('http://test.dev/sites/all/themes/bootstrap_business/coverage/ygn_mdy.kmz');
   kmzLayer.setMap(map);

}

我放了这段代码并保存了文件Coverage.js.
但是,文件位置是静态位置,我想更改动态位置,因为当我将文件上传到服务器时,位置不会像这样.
我可以把这段代码 <?php echo base_path().path_to_theme() ?>/coverage/ygn_mdy.kmz
KMZ 文件应该像这样离线放置还是有其他方法?
请帮我解决这个问题.自 2 周前以来,我一直在尝试找到它.

I put this code and save the file Coverage.js.
But, the file location is static location and I would like to change dynamic because the location will not be like this when I upload the file in server.
Can I put this code <?php echo base_path().path_to_theme() ?>/coverage/ygn_mdy.kmz
Should KMZ file put like this as an offline or is there other ways?
Please help me to solve this problem. I've been trying to find this since 2wks ago.

推荐答案

我相信,只要将 KML 放在正确的文件中,动态路径就不是问题.将 <?php echo base_path().path_to_theme() ?> 添加到 javascript 文件 Coverage.js 可能不会起作用,因为它只会被视为普通文件字符串.

I believe having a dynamic path for your KMLs is not a problem as long as you place them in the correct file. Adding <?php echo base_path().path_to_theme() ?> into a javascript file Coverage.js will likely wont work because it will just be treated as an ordinary string.

我建议所有涉及 PHP 的 javascript 代码都应保存在 PHP 文件中.在您的情况下,将其保存为 Coverage.php 之类的代码,代码应如下所示:

I would suggest all the javascript codes that there's a PHP involvement should be saved in a PHP file. In your case, saving it to something like Coverage.php and the code should look something like this:

function CoverageMap() {
  var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 11,
      center: {lat: 16.800915763233845, lng: 96.1567211141123 }
  });
  var kmzLayer = new google.maps.KmlLayer("<?php echo $base_path().$path_to_theme().'/coverage/ygn_mdy.kmz'; ?>");
  kmzLayer.setMap(map);
}

检查Google Maps Javascript API KML 层 了解更多信息.您还可以查看显示 KML 了解详情关于显示 KML 文件的信息.

Check Google Maps Javascript API KML Layers to learn more. You can also check Displaying KML to learn more on displaying information of a KML file.

希望这会有所帮助!

这篇关于如何在 drupal 7 中添加 KMZ 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆