> I found this difficult because your CSS is invalid, so Firefox doesn't > follow a lot of it. >
Apologies. FF doesn't seem to mind re. the map js though. > However, I did find this in your map script tag: > ...file=api&amp;v=2&amp;sensor=false&amp;key=ABQI... > Yes, I fixed it, but it still didn't work. I have now switched to using a script src of http://www.google.com/jsapi?key=XYZ way of loading JS which works much better -- it looks like there was a discrepancy between the onload/map-initialization temporal flow. > It looks like you use FrontPage or something similar to write your > HTML, and that has ended up double-encoding your & entities and > replaced the & character with & (as well as retaining the amp; you > used) > > The result is that only file=api is recognised as a parameter and the > API won't be passed a value for sensor or key. Yeah, it's using CL-WHO for html gen, iirc. I now send the sensor param through a javascript hash (the doc index page is specific about this being required with the old js load from maps.google, though it is not so specific about it being required for the new js load from jsapi). I am now using the "new" way of doing things and ended up changing all the Gfunc to google.map.func equivalents. It also lets me control the precise moment of load (which I would like to happen only when the popup displays). It appears GUnload is not mandatory, but I put that in there when the popup unloads anyway. So I've taken the liberty of posting the actual JS below (demo site is updated with this code too). The only thing that fails now is geocoding, but that may be because my Gfunc -> maps.google.func conversion was flawed. anyway, things work much better now. cheers! nb <script type="text/javascript"> // <![CDATA[ YAHOO.namespace('myProject'); YAHOO.myProject.modvar6503 = function () { var dialog; var map; var geocoder; minLat = 90.0 maxLat = -90.0 minLng = 180.0 maxLng = -180 function htm_esc (str) { return 'yay-str'; } function insert_api_key () { var oNew = document.createElement('script'); oNew.type = 'text/javascript'; document.getElementsByTagName('head')[0].appendChild(oNew); } function map_initialize() { map = new google.maps.Map2(document.getElementById('G6499')); map.setCenter(new google.maps.LatLng(43.100983,12.150879), 4); geocoder = new google.maps.ClientGeocoder(); } // not very clear on http://code.google.com/apis/maps/documentation/index.html // section 'Specifying the Sensor Parameter' --> but it appears you must, just as // we were doing when using the maps.google.com js script src link google.load('maps', '2', {"other_params":"sensor=false"}); google.setOnLoadCallback(map_initialize); function close_popup_and_cleanup () { dialog.hide(); google.maps.Unload(); } // addAddressToMap() is called when the geocoder returns an // answer. It adds a marker to the map with an open info window // showing the nicely formatted version of the address and the country code. function addAddressToMap(response) { map.clearOverlays(); if (!response || response.Status.code != 200) { alert('error:address-not-geo-locatable'); } else { var howmany = 3; if (response.Placemark.length < 3) { howmany = response.Placemark.length; } for (var i = 0; i < howmany ; i++) { place = response.Placemark[i]; point = new maps.google.LatLng(place.Point.coordinates[1], place.Point.coordinates[0]); var lng = point.lng(); var lat = point.lat(); marker = new maps.google.Marker(point); map.addOverlay(marker); var link = document.createElement('text'); link.innerHTML='<p>' + place.address+'</p>'; link.onclick = function() { update_location_chosen( place.address, lat, lng, place.AddressDetails); close_popup_and_cleanup();}; document.getElementById('G6497').appendChild(link); // Remember the range of coordinates that have been marked // so that we can make the map encompass all of them. minLat = Math.min (minLat, lat); maxLat = Math.max (maxLat, lat); minLng = Math.min (minLng, lng); maxLng = Math.max (maxLng, lng); } // Recenter the map to the middle of all locations that // we have marked so far. map.setCenter (new maps.google.LatLng ((minLat + maxLat) / 2, (minLng + maxLng) / 2)); // Find the maximum zoom level at which all of the requested addresses // will fit into the map (with a bit of margin), and zoom the map to // that level. Note that it doesn't seem to work to specify the // corners of the bounding box when creating the GLatLngBounds // object, so we need to use the alternate approach of calling the // extend method instead. var bounds = new maps.google.LatLngBounds; bounds.extend (new maps.google.LatLng (minLat - ((maxLat - minLat) / 12), minLng - ((maxLng - minLng) / 12))); bounds.extend (new maps.google.LatLng (maxLat + ((maxLat - minLat) / 12), maxLng + ((maxLng - minLng) / 12))); map.setZoom (map.getBoundsZoomLevel (bounds)); } } // showLocation() is called when you click on the Search button // in the form. It geocodes the address entered into the form // and adds a marker to the map at that location. function showLocation() { var address = document.getElementById('G6501').value; if(address.length > 4) { document.getElementById('G6497').innerHTML='<p> prompt:click- address-to-select </p>'; geocoder.getLocations(address, addAddressToMap); } } dialog = new YAHOO.widget.Panel('G6496', { modal : true, visible : false, constraintoviewport : true, //width:'16em', draggable:false, underlay: 'shadow', close:true}); // dialog = new YAHOO.widget.Panel('XX A', { width:'auto', visible:false, fixedcenter:true, constraintoviewport:false, modal:true, draggable:false, close:true } ); dialog.render(); dialog.hide(); //dialog.fireEvent('changeContent'); YAHOO.util.Event.on('G6500', 'click', function() { dialog.show(); //insert_api_key(); //map_initialize(); if (YAHOO.env.ua.opera && document.documentElement) { document.documentElement.style += ''; // Opera needs to force a repaint } }); YAHOO.util.Event.on('G6501', 'change', function() { showLocation (); }); }(); // ]]> </script> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
