本文介绍了在Google地图上从Excel文件绘制值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在编写代码,但其中有一些问题.
我正在开发一个代码,该代码将excel文件中的值作为经度和纬度,并将其放置在地图上作为标记.
我们遇到的问题是仅绘制了前两个单元(一个标记的平均经度和纬度).
我需要在excel工作表中提到的positios上放置几个标记.
代码附在这里.

Hi,
I am working on a code and having some problems in it.
I am developing a code,which takes values from excel file as lattitude and longitude and place it on map as a marker.
The problem we are encountering is that only first two cells(means lattitude and longitude for one marker) are plotted.
I need to place several markers at the positios mentioned in the excel sheet.
The code is attached here.

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Google Maps API Sample</title>

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAA1XbMiDxx_BTCY2_FkPh06RRaGTYH6UMl8mADNa0YKuWNNa8VNxQEerTAUcfkyrr6OwBovxn7TDAH5Q" type="text/javascript"></script>
    <script type="text/javascript">
</script></head></html>


function my_function()
{
   var Excel;
   Excel = new ActiveXObject("Excel.Application");
   Excel.Visible = false;
   return Excel.Workbooks.Open("C:/desktop/TEST.xls").ActiveSheet.Cells(l,i).Value;}
//where l is number of rows and i are columns...
var i=1;
var l=1;
do
{
  a = my_function()
  if (a!=null)
  {
    i++;
     b=my_function()
     if(b!=null)
        initialize()
     i++;
  }
  else
  {
     l++;
     i=1;
  }
}
while(a!=null || b!=null);
function initialize() {
  if (GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById("map_canvas"));
    map.setCenter(new GLatLng(24.884801, 67.056469), 13);
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());

    var point = new GLatLng(a , b);
    map.addOverlay(new GMarker(point));
  }
}


  <body onload="initialize()" onunload="GUnload()" style="font-family: Arial;border: 0 none;">
    <h1 align="center">Plotting</h1>
<hr width="50%">
    <div id="map_canvas" style="width: 900px; height: 1000px"></div>
  </hr></body> 


PS我猜do-while循环存在一些问题.
请帮帮我.
困惑的geminien


PS I guess there is some problem with do-while loop.
Please help me out.
Confused geminien

推荐答案


这篇关于在Google地图上从Excel文件绘制值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 21:57
查看更多