Select to view content in your preferred language

GMAPS - mapExtension.addToMap - rendering polygons with holes

765
1
06-15-2010 12:29 AM
by Anonymous User
Not applicable
Original User: brownsm

There apppears to be a problem with the mapExtension class when using mapExtension.addMap to add a polygon that contains a hole. Attachment poly1.jpg shows how the displayed polygon should look and attachment poly2.jpg shows how the polygon is renedered using the following code. The image overlay from the ArcGIS Server Map service displays the polygon correctly (attachment poly3.jpg). Does anyone have a solution?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html debug=true>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Find Task:  Add FindResults with default styling</title>

    <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAbN-pn87tRTOhN5haEPTrxxRpW7RPLo8OuYpZjwqeJcN2phD..." type="text/javascript"></script>
    <script src="http://serverapi.arcgisonline.com/jsapi/gmaps/?v=1.6" type="text/javascript" ></script>

    <script type="text/javascript">

      var gmap = null;
      var findTask = null;
      var params = null;
      var mapExtension = null;
      var gOverlays = null;

      function initialize() {
        // GMap construction
        gmap = new GMap2(document.getElementById('gmap'));
        gmap.addMapType(G_NORMAL_MAP);
        gmap.addMapType(G_SATELLITE_MAP);
        gmap.addControl(new GLargeMapControl());
        gmap.addControl(new GMapTypeControl());
        gmap.setCenter(new GLatLng(-22.5886, 117.1802), 11);
        gmap.enableScrollWheelZoom();

        //Create MapExtension utility class
        mapExtension = new esri.arcgis.gmaps.MapExtension(gmap);

         // Find Task
        findTask = new esri.arcgis.gmaps.FindTask("http://pergis33/sdidev2/rest/services/Title_Information_Tiled/MapServer");

        // You can execute a task and listen for the complete event or use the callback to get the results
        GEvent.addListener(findTask, "executecomplete", function() {
          //console.debug("'find task complete' event fired!!!");
        });

        // Find Parameters
        params = new esri.arcgis.gmaps.FindParameters();
        params.layerIds = [1,2];
        params.searchFields = ["FMT_TENID"];
      }

      function executeFind(searchText) {
        // clear map overlays and event listeners using MapExtension removeFromMap
        mapExtension.removeFromMap(gOverlays);

        // set find parameters
        params.searchText = searchText;

        // execute find task
        findTask.execute(params, findCompleteCallback);

      }

      function findCompleteCallback(findResults) {
  
        // add the findresutls to google map without any style
        gOverlays = mapExtension.addToMap(findResults);
      }

    </script>

  </head>

  <body onload="initialize();" onunload="GUnload();">
  <table width="100%" height="100%">
    <tr>
      <td align="center">

        <table>
          <tr align="left">
            <td>
              Search Formatted TenID:  <input type="text" id="searchString" value="" size="10"/><input id="executeFind" type="button" value="Execute Find" onclick="executeFind(document.getElementById('searchString').value);" /> 

              <input id="clear" type="button" value="Clear Map Overlays" onclick="mapExtension.removeFromMap(gOverlays);" />
            </td>
          </tr>

          <tr align="left" valign="top">
            <td>
              <div id="gmap" style="width: 500px; height:500px;"></div>
            </td>
          </tr>
        </table>

      </td>
    </tr>
  </table>
  </body>
</html>
0 Kudos
1 Reply
NianweiLiu
Frequent Contributor
This is not a problem of the ESRI extension, it's the Google API limitation. It's v2 does not support rings with holes. However it's v3 does.
0 Kudos