コード例 #1
0
ファイル: Z2MPAPI.cpp プロジェクト: arksoftgit/10c
zOPER_EXPORT zSHORT OPERATION
MapPointSetPushPin( zCPCHAR cpcStreet, zCPCHAR cpcCity, zCPCHAR cpcOtherCity,
                    zCPCHAR cpcRegion, zCPCHAR cpcPostalCode,
                    zCPCHAR cpcMsg, zSHORT nPushPin, zLONG lFlag )
{
   AFX_MANAGE_STATE( AfxGetStaticModuleState( ) );
   SHORT nRC = 0;
   ZMapPointApp *pApp = (ZMapPointApp *) ::AfxGetApp( );
   if ( pApp )
   {
      TRY
      {
         if ( pApp->GetMapPointState( ) == 0 )  // not active
            return( zCALL_ERROR );

         _Application *pMP = pApp->GetMapPointApplication( );
         if ( pMP == 0 )
         {
            nRC = zCALL_ERROR;
         }
         else
         {
            _Map Map = pMP->GetActiveMap( );
         // if ( pMap == 0 )
         //    nRC = zCALL_ERROR;
         // else
            {
            // Item    item;
               zLONG   lCnt;
               VARIANT a;
               a.vt = VT_I4;
               a.lVal = 244; // geoMapNorthAmerica!
            // a.lVal = 1; // geoMapNorthAmerica!
            // a.lVal = 2; // geoMapEurope!

               FindResults FR = Map.FindAddressResults( cpcStreet, cpcCity,
                                                        cpcOtherCity,
                                                        cpcRegion,
                                                        cpcPostalCode, a );
               TraceLineI( "FindAddressResults Quality: ", FR.GetResultsQuality( ) );
               lCnt = FR.GetCount( );
               TraceLineI( "FindAddressResults Count: ", lCnt );
               for ( int k = 1; k <= lCnt; k++ )
               {
                  a.lVal = k;
                  Location L = FR.GetItem( &a );
                  long lType = L.GetType( );
                  long lX = Map.LocationToX( L );
                  long lY = Map.LocationToY( L );
                  TraceLine( "Location Name: %s  Type: %d  X: %d  Y: %d",
                             L.GetName( ), lType, lX, lY );

                  Pushpin pin;

                  if ( cpcMsg && &cpcMsg )
                     pin = Map.AddPushpin( L, cpcMsg );
                  else
                     pin = Map.AddPushpin( L, L.GetName( ) );

                  pin.SetSymbol( nPushPin );
                  if ( lFlag & 0x00000001 )
                     L.GoTo( );

                  PlaceCategory PC = L.GetPlaceCategory( );
                  TraceLineS( "The Place Category is: ", PC.GetName( ) );
               }
            }
         }
      }
      CATCH_ALL( e )
      {
         nRC = zCALL_ERROR;
      }
      END_CATCH_ALL
   }

   return( nRC );
}
コード例 #2
0
ファイル: Z2MPAPI.cpp プロジェクト: arksoftgit/10c
// geoCountryCanada          39   Canada
// geoCountryUnitedStates   244   United States
zOPER_EXPORT zSHORT OPERATION
MapPointValidateAddress( zPCHAR pchStreet, zPCHAR pchCity, zPCHAR pchOtherCity,
                         zPCHAR pchRegion, zPCHAR pchPostalCode,
                         zCPCHAR cpcStreetAddress, zLONG lFlag )
{
   AFX_MANAGE_STATE( AfxGetStaticModuleState( ) );
   SHORT nRC = 0;
   ZMapPointApp *pApp = (ZMapPointApp *) ::AfxGetApp( );

   *pchStreet = 0;
   *pchCity = 0;
   *pchOtherCity = 0;
   *pchRegion = 0;
   *pchPostalCode = 0;
   if ( pApp )
   {
      TRY
      {
         if ( pApp->GetMapPointState( ) == 0 )  // not active
            return( zCALL_ERROR );

         _Application *pMP = pApp->GetMapPointApplication( );
         if ( pMP == 0 )
         {
            nRC = zCALL_ERROR;
         }
         else
         {
            _Map Map = pMP->GetActiveMap( );
         // if ( pMap == 0 )
         //    nRC = zCALL_ERROR;
         // else
            {
            // Item    item;
               zLONG   lCnt;
               VARIANT a;
               a.vt = VT_I4;
               a.lVal = 244; // geoMapNorthAmerica!
            // a.lVal = 1; // geoMapNorthAmerica!
            // a.lVal = 2; // geoMapEurope!

               StreetAddress SA = Map.ParseStreetAddress( cpcStreetAddress );
               zstrcpy( pchStreet, SA.GetStreet( ) );
               zstrcpy( pchCity, SA.GetCity( ) );
               zstrcpy( pchOtherCity, SA.GetOtherCity( ) );
               zstrcpy( pchRegion, SA.GetRegion( ) );
               zstrcpy( pchPostalCode, SA.GetPostalCode( ) );
               FindResults FR = Map.FindAddressResults( pchStreet, pchCity,
                                                        pchOtherCity,
                                                        pchRegion,
                                                        pchPostalCode, a );
               TraceLineI( "FindAddressResults Quality: ", FR.GetResultsQuality( ) );
               lCnt = FR.GetCount( );
               TraceLineI( "FindAddressResults Count: ", lCnt );
#if 0
               for ( int k = 1; k <= lCnt; k++ )
               {
                  a.lVal = k;
                  Location L = FR.GetItem( &a );
                  long lType = L.GetType( );
                  long lX = Map.LocationToX( L );
                  long lY = Map.LocationToY( L );
                  TraceLine( "Location Name: %s  Type: %d  X: %d  Y: %d",
                             L.GetName( ), lType, lX, lY );

                  Map.AddPushpin( L, L.GetName( ) );
                  PlaceCategory PC = L.GetPlaceCategory( );
                  TraceLineS( "The Place Category is: ", PC.GetName( ) );
               }
#endif
            }
         }
      }
      CATCH_ALL( e )
      {
         nRC = zCALL_ERROR;
      }
      END_CATCH_ALL
   }

   return( nRC );
}