彰化一整天的論壇

 找回密碼
 立即註冊
查看: 635|回復: 0

google map v2與v3的差異

[複製鏈接]
發表於 2016-1-3 19:26:18 | 顯示全部樓層 |閱讀模式


v2v3
GMap2google.maps.Map
GLatLnggoogle.maps.LatLng
GInfoWindowgoogle.maps.InfoWindow
GMapOptionsgoogle.map.MapOptions
G_API_VERSIONgoogle.maps.version
GPolyStyleOptionsgoogle.maps.PolygonOptions
or google.maps.PolylineOptions

Removing Obsolete Code
The Google Maps JavaScript API v3 has parallels for most of the functionality in v2; however, there are some classes that are no longer supported. As part of your migration, you should either replace these classes with third party utility libraries, or remove these references from your code. Many excellent JavaScript libraries exist that provide similar functionality, such as Closure or jQuery.
The following classes have no parallel in the Google Maps JavaScript API v3:
GBoundsGLanguage
GBrowserIsCompatibleGLayer
GControlGLog
GControlAnchorGMercatorProjection
GControlImplGNavLabelControl
GControlPositionGObliqueMercator
GCopyrightGOverlay
GCopyrightCollectionGPhotoSpec
GDownloadUrlGPolyEditingOptions
GDraggableObjectGScreenOverlay
GDraggableObjectOptionsGStreetviewFeatures
GFactualGeocodeCacheGStreetviewLocation
GGeoAddressAccuracyGStreetviewOverlay
GGeocodeCacheGStreetviewUserPhotosOptions
GGoogleBarGTileLayerOptions
GGoogleBarAdsOptionsGTileLayerOverlayOptions
GGoogleBarLinkTargetGTrafficOverlayOptions
GGoogleBarListingTypesGUnload
GGoogleBarOptionsGXml
GGoogleBarResultListGXmlHttp
GInfoWindowTabGXslt
GKeyboardHandler

Comparing Code2.0
  1. <!DOCTYPE html>
  2. <html>
  3.   <head>
  4.     <script src="//maps.google.com/maps?file=api&v=2&key=YOUR_API_KEY&sensor=false"
  5.         type="text/javascript"></script>
  6.     <style type="text/css">
  7.       html, body, #map { height: 100%; margin: 0; }
  8.     </style>
  9.     <script type="text/javascript">
  10.     function initialize() {
  11.       if (GBrowserIsCompatible()) {
  12.         var map = new GMap2(
  13.             document.getElementById('map'));
  14.         map.setCenter(new GLatLng(37.4419, -122.1419), 13);
  15.         map.setUIToDefault();

  16.         map.addOverlay(new GMarker(new GLatLng(37.4419, -122.1419)));

  17.       }
  18.     }
  19.     </script>
  20.   </head>
  21.   <body onload="initialize()" onunload="GUnload()">
  22.     <div id="map"></div>
  23.   </body>
  24. </html>
複製代碼
v3.0
  1. <!DOCTYPE html>
  2. <html>
  3.   <head>
  4.     <script src="//maps.googleapis.com/maps/api/js?sensor=false"
  5.         type="text/javascript"></script>
  6.     <style type="text/css">
  7.       html, body, #map { height: 100%; margin: 0; }
  8.     </style>
  9.     <script type="text/javascript">
  10.     function initialize() {
  11.       var map = new google.maps.Map(
  12.         document.getElementById('map'), {
  13.           center: new google.maps.LatLng(37.4419, -122.1419),
  14.           zoom: 13,
  15.           mapTypeId: google.maps.MapTypeId.ROADMAP
  16.       });

  17.       var marker = new google.maps.Marker({
  18.             position: new google.maps.LatLng(37.4419, -122.1419),
  19.             map: map
  20.       });

  21.     }
  22.     google.maps.event.addDomListener(window, 'load', initialize);
  23.     </script>
  24.   </head>
  25.   <body>
  26.     <div id="map"></div>
  27.   </body>
  28. </html>
複製代碼
資料來源: https://developers.google.com/maps/articles/v2tov3

回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

 ㄚ母滴雞湯
 員林香純滴雞精

Archiver|手機版|小黑屋|彰化一整天的論壇(Excel,Office)  |网站地图

GMT+8, 2019-8-24 16:52 , Processed in 0.122833 second(s), 19 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表