ez projects / ezgmaplocation / forum / general / update to google maps api v3
You need to be logged in to post messages in the forums. New users may register here.
|
Member since: Posts: 6 |
Friday 22 July 2011 11:19:59 am Hi,
I updated the extension to use the Google Maps Api v3. It's easy, you have to override the file : /templates/content/datatype/view/ezgmaplocation.tpl and change the begining. Replace : {run-once} <script src="http://maps.google.com/maps?file=api&v=2&key={ezini('SiteSettings','GMapsKey')}" type="text/javascript"></script> <script type="text/javascript"> {literal} function eZGmapLocation_MapView( attributeId, latitude, longitude ) { if (GBrowserIsCompatible()) { if( latitude && longitude ) var startPoint = new GLatLng( latitude, longitude ), zoom = 13; else var startPoint = new GLatLng( 0, 0 ), zoom = 0; var map = new GMap2( document.getElementById( 'ezgml-map-' + attributeId ) ); map.addControl( new GSmallMapControl() ); map.setCenter( startPoint, zoom ); map.addOverlay( new GMarker(startPoint) ); } } {/literal} </script> {/run-once} By : {run-once} <script type="text/javascript" src="http://maps.google.com/maps/api/j...ensor=false"></script> <script type="text/javascript"> {literal} function eZGmapLocation_MapView( attributeId, latitude, longitude ) { if( latitude && longitude ){ var latlng = new google.maps.LatLng(latitude,longitude); } else { var latlng = new google.maps.LatLng(0,0); } var myOptions = { zoom: 12, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById( 'ezgml-map-' + attributeId ), myOptions); var marker = new google.maps.Marker({ position: latlng }); // To add the marker to the map, call setMap(); marker.setMap(map); } {/literal} </script> {/run-once} You no longer need the API key ! |
|
|
Member since: Posts: 21 |
Tuesday 06 September 2011 5:17:37 pm You should keep the version number when you call the js file from google :
for exemple <script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3.5 ...You don't know how the API evolves. If a v4 is released, you don't know if your script will be ok with the new one. |
You need to be logged in to post messages in the forums. New users may register here.