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

查看:144
本文介绍了如何在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放置在正确的文件中,我相信为您的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天全站免登陆