Hi. I've troubles using Google AJAX API Loader. With the code below I've no trouble with the old http://maps.google.com/maps?file=api so I don't see my mistake. I get an parse error with TextualZoomControl.prototype = new GControl() error GControl is not defined
<script type="text/javascript" src="http://www.google.com/jsapi? key=ABQIAAAAzr2EBOXUKnm_jVnk0YughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA"></ script> <script type="text/javascript"> var map = null; var geocoder = null; function initialize() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map-dove-siamo")); map.addControl(new TextualZoomControl()); geocoder = new GClientGeocoder(); showAddress('Bracelli, Beverino SP, Italy'); } } function showAddress(address) { if (geocoder) { geocoder.getLatLng( address, function(point) { if (!point) { alert(address + " not found"); } else { map.setCenter(point, 13); var marker = new GMarker(point); map.addOverlay(marker); var tooltip = '<div class="map-tooltip"><strong>Bracelli 19020 Beverino SP</strong></div><div class="map-tooltip"><a href="http://maps.google.it/maps? f=q&source=s_q&hl=it&geocode=&q=Bracelli&sll=41.442726,12.392578&sspn=14.252027,28.300781&ie=UTF8&ll=44.208788,9.758606&spn=0.402608,1.40625&z=10&iwloc=addr">Come arrivare da noi</a></div>'; GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(tooltip); }); GEvent.addListener(marker, 'infowindowclose', function() { map.recenterOrPanToLatLng(center, 2); }); marker.openInfoWindowHtml(tooltip); } } ); } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// google.load("maps", "2"); /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // A TextualZoomControl is a GControl that displays textual "Zoom In" // and "Zoom Out" buttons (as opposed to the iconic buttons used in // Google Maps). // We define the function first function TextualZoomControl() { } // To "subclass" the GControl, we set the prototype object to // an instance of the GControl object ///////////////////////////////////////////////////////////////////////////////////////////// TextualZoomControl.prototype = new GControl(); /////////////////////////////////////////////////////////////////////////////////////////// // Creates a one DIV for each of the buttons and places them in a container // DIV which is returned as our control element. We add the control to // to the map container and return the element for the map class to // position properly. TextualZoomControl.prototype.initialize = function(map) { var container = document.createElement("div"); var zoomOutDiv = document.createElement("div"); this.setButtonStyle_(zoomOutDiv); container.appendChild(zoomOutDiv); zoomOutDiv.appendChild(document.createTextNode("Zoom avanti")); GEvent.addDomListener(zoomOutDiv, "click", function() { map.zoomOut(); }); var zoomInDiv = document.createElement("div"); this.setButtonStyle_(zoomInDiv); container.appendChild(zoomInDiv); zoomInDiv.appendChild(document.createTextNode("Zoom indietro")); GEvent.addDomListener(zoomInDiv, "click", function() { map.zoomIn(); }); map.getContainer().appendChild(container); return container; } // By default, the control will appear in the top left corner of the // map with 7 pixels of padding. TextualZoomControl.prototype.getDefaultPosition = function() { return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7)); } // Sets the proper CSS for the given button element. TextualZoomControl.prototype.setButtonStyle_ = function(button) { button.style.textDecoration = "underline"; button.style.color = "#5C2E0D"; button.style.backgroundColor = "#E2D0BE"; button.style.borderLeft= "1px solid #5C2E0D"; button.style.font = "bold Arial"; button.style.padding = "2px"; button.style.marginBottom = "3px"; button.style.textAlign = "center"; button.style.width = "6em"; button.style.cursor = "pointer"; } ///////////////////////////////////////////////////////////////////////////////////////////// google.setOnLoadCallback(initialize) IMHO with google.load("maps", "2") the maps library should be available in the page, shouldn't it ? Can you help me, please ? Thanks in advance. Bye --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
