javascript - 如何轻松地将 javascript 版本迁移到谷歌地图的新版本?

标签 javascript google-maps deprecated

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

我的 map 是这样的:

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);

谢谢

最佳答案

使用 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 or google.maps.PolylineOptions

then run find/replace in one way or another:

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

引用资料

关于javascript - 如何轻松地将 javascript 版本迁移到谷歌地图的新版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13668833/

相关文章:

javascript - 接收 var 声明字符串,只保存值

javascript - 在动态字符串之前和之后插入字符串

Monostate __new__ 的 Python 弃用警告——有人可以解释原因吗?

certificate - BouncycaSTLe:X509 证书的 X509 证书持有者?

javascript - 在 AngularJS 中如何独立呈现列表的不同项目

javascript - Internet Explorer 中的 Google Maps JavaScript API 错误

android - Android 上的谷歌地图 API

javascript - ACF Google map - 标记聚类

ios - 处理 EKEvent.recurrenceRule 属性的删除

javascript写一行带有按钮的html代码