【问题标题】:How to easily migrate javascript version to new one for google map?如何轻松地将 javascript 版本迁移到谷歌地图的新版本?
【发布时间】:2013-12-11 09:34:34
【问题描述】:

多年前,我很难为我的网络制作带有标记的谷歌地图。 我正在为贝宝植入 ssl,我刚刚检查了一下,发现地图不适用于 htts: 所以我进入谷歌地图寻求解决方案,发现 javascript 已被弃用,他们建议升级到版本 3。 有没有简单的方法或一些教程,因为我正忙于尝试集成贝宝,而上次并不容易。有什么建议吗?

这就是我的地图:

function createMarker(point,html) {
    var marker = new GMarker(point);
    GEvent.addListener(marker, "click", enter code herefunction() {
      marker.openInfoWindowHtml(html);
    });
    return marker;
  }

  // Display the map, with some controls and set the initial location 
  var map = new GMap2(document.getElementById("map"));
  map.addControl(new GLargeMapControl());
  map.addControl(new GMapTypeControl());
  map.setCenter(new GLatLng(36.51308543049258, -4.886341094970703), 13);

  // Set up three markers with info windows  

  var point = new GLatLng(36.50856685143835, -4.866085052490234);
  var marker = createMarker(point,'<div style="width:240px">Text here<a href="link here">Link<\/a><\/div>')
  map.addOverlay(marker);

谢谢

【问题讨论】:

    标签: javascript google-maps deprecated


    【解决方案1】:

    使用v2 referencemigration table 创建一个文本文件:

    v2 v3 GMap2 google.maps.Map GLatLng google.maps.LatLng GInfoWindow google.maps.InfoWindow GMapOptions google.map.MapOptions G_API_VERSION google.maps.version GPolyStyleOptions google.maps.PolygonOptions 或 google.maps.PolylineOptions

    然后以一种或另一种方式运行查找/替换:

       for func in `cat deprecated.txt`
         do
          grep -R $func /path/to/src
       done
    

    参考文献

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-08
      • 1970-01-01
      • 1970-01-01
      • 2013-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-14
      相关资源
      最近更新 更多