My code is below..
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas- microsoft-com:vml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/ > <title>Show InfoWindow on 'mouseover' event</title> <script src="http://maps.google.com/maps? file=api&v=2&key=DioG219lPJG3WTn3zmQqebsjVg" type="text/ javascript"></script> <script src="http://serverapi.arcgisonline.com/jsapi/gmaps/?v=1.4" type="text/javascript"></script> <script type="text/javascript"> var map, queryTask; function initialize() { if (GBrowserIsCompatible()) { // create the map control map = new GMap2(document.getElementById("map_canvas")); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(27, -95), 4); // create the query task queryTask = new esri.arcgis.gmaps.QueryTask("http:// sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ ESRI_Census_USA/MapServer/3"); } } function executeQuery(a) { // create the query var query = new esri.arcgis.gmaps.Query(); query.where = "STATE_NAME = '" + a + "'"; query.outFields = ["NAME", "POP2007"]; // execute the query queryTask.execute(query, false, function(featureSet, error) { // callback // display error message (if any) if (error) { alert("Error " + error.code + ": " + (error.message || (error.details && error.details.join(" ")) || "Unknown error" )); return; } // add the feature set to the map var features = featureSet.features, geometry, attributes; for (var i = 0; i < features.length; i++) { // process each county in the feature set geometry = features[i].geometry; attributes = features[i].attributes; for (var j = 0; j < geometry.length; j++) { // Feature.geometry is an array of GPolygon/GPolyline/GMarker var geom = geometry[j]; GEvent.addListener(geom, "mouseover", GEvent.callbackArgs (geom, onMouseOverFunc, attributes)); GEvent.addListener(geom, "mouseout", onMouseOutFunc); map.addOverlay(geom); } } } } // Note that we are not using the MapExtension class here to add the FeatureSet // to the map as it supports only "click-to-open-infowindow" workflow }); } function removeLayer(){ map.clearOVerlays(); } // show info window for the county when the user moves the mouse over it function onMouseOverFunc(attributes) { // highlight the county var polygon = this; polygon.setFillStyle({ color: "#FF0000" }); polygon.setStrokeStyle({ color: "#FF0000" }); // show the infowindow var html = "<b>Name:</b> " + attributes["NAME"] + "<br/ ><b>POP2007:</b> " + attributes["POP2007"]; map.openInfoWindowHtml(polygon.getBounds().getCenter(), html); } // close info window when the user moves the mouse out of a county function onMouseOutFunc() { // unhighlight the county var polygon = this; polygon.setFillStyle({ color: "#0000FF" }); polygon.setStrokeStyle({ color: "#0000FF" }); // hide the infowindow map.closeInfoWindow(); } </script> </head> <body onload="initialize();" onunload="GUnload();"> <form> Select a region? <select onchange="executeQuery(this.value);" > <option value="" selected>Choose One</option> <option value="Alabama">Alabama</option> <option value="Alaska">Alaska</option> <option value="American Samoa">American Samoa</option> <option value="Arizona">Arizona</option> <option value="Arkansas">Arkansas</option> <option value="California">California</option> <option value="Colorado">Colorado</option> <option value="Connecticut">Connecticut</option> <option value="Delaware">Delaware</option> <option value="District of Columbia">District of Columbia</option> <option value="Florida">Florida</option> <option value="Georgia">Georgia</option> <option value="Guam">Guam</option> <option value="Hawaii">Hawaii</option> <option value="Idaho">Idaho</option> <option value="Illinois">Illinois</option> <option value="Indiana">Indiana</option> <option value="Iowa">Iowa</option> <option value="Kansas">Kansas</option> <option value="Kentucky">Kentucky</option> <option value="Louisiana">Louisiana</option> <option value="Maine">Maine</option> <option value="Maryland">Maryland</option> <option value="Massachusetts">Massachusetts</option> <option value="Michigan">Michigan</option> <option value="Minnesota">Minnesota</option> <option value="Mississippi">Mississippi</option> <option value="Missouri">Missouri</option> <option value="Montana">Montana</option> <option value="Nebraska">Nebraska</option> <option value="Nevada">Nevada</option> <option value="New Hampshire">New Hampshire</option> <option value="New Jersey">New Jersey</option> <option value="New Mexico">New Mexico</option> <option value="New York">New York</option> <option value="North Carolina">North Carolina</option> <option value="North Dakota">North Dakota</option> <option value="Northern Marianas Islands ">Northern Marianas Islands </option> <option value="Ohio">Ohio</option> <option value="Oklahoma">Oklahoma</option> <option value="Oregon">Oregon</option> <option value="Pennsylvania">Pennsylvania</option> <option value="Puerto Rico">Puerto Rico</option> <option value="Rhode Island">Rhode Island</option> <option value="South Carolina">South Carolina</option> <option value="South Dakota">South Dakota</option> <option value="Tennessee">Tennessee</option> <option value="Texas">Texas</option> <option value="Utah">Utah</option> <option value="Vermont">Vermont</option> <option value="Virginia ">Virginia </option> <option value="Virgin Islands ">Virgin Islands </option> <option value="Washington">Washington</option> <option value="West Virginia">West Virginia</option> <option value="Wisconsin">Wisconsin</option> <option value="Wyoming ">Wyoming </option> </select> <input type="button" value="Clear Dynamic Map" onclick="removeLayer ()" /> </form> Move the mouse over each County to see more information. </p> <div id="map_canvas" style="width: 850px; height: 650px;"></div> </body> </html> On Oct 5, 5:30 pm, "[email protected]" <[email protected]> wrote: > On Oct 5, 8:23 am, leeah <[email protected]> wrote: > > > I created a button and called a function which execute > > map.clearOverlays() > > > it seems the object map = new GMap2(document.getElementById > > ("map_canvas")); > > > doesn;t recongize clearOverlays() > > > please advise > > Try making the map variable global. > > > > > On Oct 5, 4:17 am, Rossko <[email protected]> wrote: > > > > > I would like to add a button to clear all layers on map. please help > > > >http://code.google.com/apis/maps/documentation/reference.html#GMap2.c...Hide > > > quoted text - > > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
